List:Commits« Previous MessageNext Message »
From:marko.makela Date:May 16 2012 11:22am
Subject:bzr push into mysql-trunk-wl6255 branch (marko.makela:3837 to 3838) WL#6255
View as plain text  
 3838 Marko Mäkelä	2012-05-16
      WL#6255 preparation: Add rollback assertions on DB_TRX_ID == trx->id.
      
      rec_get_trx_id(): New function, available in debug builds.
      
      row_undo_ins_remove_clust_rec(), row_undo_mod_clust_low(): Assert that
      rec_get_trx_id() matches trx->id.
      
      row_undo_mod_remove_clust_low(): Assert that rec_get_trx_id() matches
      trx->id and the record is not delete-marked, or the transaction is
      TRX_DICT_OP_TABLE.  For some reason, these assertions would fail during
      a rollback in ADD FOREIGN KEY (innodb-index.test, innodb_16k.test).

    modified:
      storage/innobase/include/rem0rec.h
      storage/innobase/rem/rem0rec.cc
      storage/innobase/row/row0uins.cc
      storage/innobase/row/row0umod.cc
 3837 Marko Mssert that it is not a fulltext index.

    modified:
      storage/innobase/include/dict0dict.ic
=== modified file 'storage/innobase/include/rem0rec.h'
--- a/storage/innobase/include/rem0rec.h	revid:marko.makela@stripped0515194611-11m6s50pesyyagf1
+++ b/storage/innobase/include/rem0rec.h	revid:marko.makela@stripped0hnm86r887fcvj5c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -420,8 +420,9 @@ rec_offs_make_valid(
 /*================*/
 	const rec_t*		rec,	/*!< in: record */
 	const dict_index_t*	index,	/*!< in: record descriptor */
-	ulint*			offsets);/*!< in: array returned by
+	ulint*			offsets)/*!< in: array returned by
 					rec_get_offsets() */
+	__attribute__((nonnull));
 #else
 # define rec_offs_make_valid(rec, index, offsets) ((void) 0)
 #endif /* UNIV_DEBUG */
@@ -836,6 +837,19 @@ rec_print(
 	FILE*			file,	/*!< in: file where to print */
 	const rec_t*		rec,	/*!< in: physical record */
 	const dict_index_t*	index);	/*!< in: record descriptor */
+
+# ifdef UNIV_DEBUG
+/************************************************************//**
+Reads the DB_TRX_ID of a clustered index record.
+@return	the value of DB_TRX_ID */
+UNIV_INTERN
+trx_id_t
+rec_get_trx_id(
+/*===========*/
+	const rec_t*		rec,	/*!< in: record */
+	const dict_index_t*	index)	/*!< in: clustered index */
+	__attribute__((nonnull, warn_unused_result));
+# endif /* UNIV_DEBUG */
 #endif /* UNIV_HOTBACKUP */
 
 /* Maximum lengths for the data in a physical record if the offsets

=== modified file 'storage/innobase/rem/rem0rec.cc'
--- a/storage/innobase/rem/rem0rec.cc	revid:marko.makela@stripped15194611-11m6s50pesyyagf1
+++ b/storage/innobase/rem/rem0rec.cc	revid:marko.makela@stripped6r887fcvj5c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -29,6 +29,7 @@ Created 5/30/1994 Heikki Tuuri
 #include "rem0rec.ic"
 #endif
 
+#include "page0page.h"
 #include "mtr0mtr.h"
 #include "mtr0log.h"
 #include "fts0fts.h"
@@ -1792,4 +1793,50 @@ rec_print(
 		}
 	}
 }
+
+# ifdef UNIV_DEBUG
+/************************************************************//**
+Reads the DB_TRX_ID of a clustered index record.
+@return	the value of DB_TRX_ID */
+UNIV_INTERN
+trx_id_t
+rec_get_trx_id(
+/*===========*/
+	const rec_t*		rec,	/*!< in: record */
+	const dict_index_t*	index)	/*!< in: clustered index */
+{
+	const page_t*	page
+		= page_align(rec);
+	ulint		trx_id_col
+		= dict_index_get_sys_col_pos(index, DATA_TRX_ID);
+	const byte*	trx_id;
+	ulint		len;
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets		= offsets_;
+	rec_offs_init(offsets_);
+
+	ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX);
+	ut_ad(mach_read_from_8(page + PAGE_HEADER + PAGE_INDEX_ID)
+	      == index->id);
+	ut_ad(dict_index_is_clust(index));
+	ut_ad(trx_id_col > 0);
+	ut_ad(trx_id_col != ULINT_UNDEFINED);
+
+	offsets = rec_get_offsets(rec, index, offsets, trx_id_col + 1, &heap);
+
+	trx_id = rec_get_nth_field(rec, offsets, trx_id_col, &len);
+
+	ut_ad(len == DATA_TRX_ID_LEN);
+#  if DATA_TRX_ID_LEN != 6
+#   error
+#  endif
+
+	if (heap) {
+		mem_heap_free(heap);
+	}
+
+	return(mach_read_from_6(trx_id));
+}
+# endif /* UNIV_DEBUG */
 #endif /* !UNIV_HOTBACKUP */

=== modified file 'storage/innobase/row/row0uins.cc'
--- a/storage/innobase/row/row0uins.cc	revid:marko.makela@stripped-11m6s50pesyyagf1
+++ b/storage/innobase/row/row0uins.cc	revid:marko.makela@strippedvj5c
@@ -78,6 +78,10 @@ row_undo_ins_remove_clust_rec(
 					    &mtr);
 	ut_a(success);
 
+	ut_ad(rec_get_trx_id(btr_pcur_get_rec(&node->pcur),
+			     node->pcur.btr_cur.index)
+	      == node->trx->id);
+
 	if (node->table->id == DICT_INDEXES_ID) {
 		ut_ad(node->trx->dict_operation_lock_mode == RW_X_LATCH);
 

=== modified file 'storage/innobase/row/row0umod.cc'
--- a/storage/innobase/row/row0umod.cc	revid:marko.makela@strippedm6s50pesyyagf1
+++ b/storage/innobase/row/row0umod.cc	revid:marko.makela@strippedc
@@ -128,6 +128,10 @@ row_undo_mod_clust_low(
 
 	ut_ad(success);
 
+	ut_ad(rec_get_trx_id(btr_cur_get_rec(btr_cur),
+			     btr_cur_get_index(btr_cur))
+	      == thr_get_trx(thr)->id);
+
 	if (mode == BTR_MODIFY_LEAF) {
 
 		err = btr_cur_optimistic_update(BTR_NO_LOCKING_FLAG
@@ -190,6 +194,17 @@ row_undo_mod_remove_clust_low(
 
 	btr_cur = btr_pcur_get_btr_cur(&node->pcur);
 
+	ut_ad(rec_get_trx_id(btr_cur_get_rec(btr_cur),
+			     btr_cur_get_index(btr_cur))
+	      == thr_get_trx(thr)->id
+	      /* TODO: why is the below needed?
+	      innodb.innodb-index innodb.innodb_16k fails otherwise */
+	      || thr_get_trx(thr)->dict_operation == TRX_DICT_OP_TABLE);
+	ut_ad(!rec_get_deleted_flag(btr_cur_get_rec(btr_cur),
+				    dict_table_is_comp(node->table))
+	      /* TODO: remove the below */
+	      || thr_get_trx(thr)->dict_operation == TRX_DICT_OP_TABLE);
+
 	if (mode == BTR_MODIFY_LEAF) {
 		err = btr_cur_optimistic_delete(btr_cur, 0, mtr)
 			? DB_SUCCESS

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl6255 branch (marko.makela:3837 to 3838) WL#6255marko.makela16 May