List:Commits« Previous MessageNext Message »
From:marko.makela Date:June 29 2011 7:35am
Subject:bzr push into mysql-5.1 branch (marko.makela:3658 to 3659) Bug#12612184
View as plain text  
 3659 Marko Mäkelä	2011-06-29
      Bug #12612184 BLOB debug code cleanup:
      Refactor the !rec_offs_any_extern relaxation in row_build().
      
      trx_assert_active(trx_id): Assert that the given transaction is active.
      (In the 5.1 built-in InnoDB, there is no trx->is_recovered field.)
      
      trx_assert_recovered(trx_id): Assert that the given transaction is
      active and has been recovered after a crash.
      
      row_build(): Replace a bunch of code with an assertion that invokes
      trx_assert_active() or trx_assert_recovered() and row_get_rec_trx_id().
      
      row_get_trx_id_offset(): Make the function inlined. Remove the unused
      parameter rec, and make all parameters const.
      
      row_get_rec_trx_id(), row_get_rec_roll_ptr(): Make all parameters const.
      
      rb:691 approved by Jimmy Yang

    modified:
      storage/innobase/include/trx0sys.h
      storage/innobase/include/trx0sys.ic
      storage/innobase/row/row0row.c
      storage/innodb_plugin/include/row0row.h
      storage/innodb_plugin/include/row0row.ic
      storage/innodb_plugin/include/row0upd.ic
      storage/innodb_plugin/include/trx0sys.h
      storage/innodb_plugin/include/trx0sys.ic
      storage/innodb_plugin/row/row0row.c
 3658 Marko Mäkelä	2011-06-28
      Bug#12595087 - 61191: Question about page_zip_available (clean up page0zip.c)
      
      page_zip_dir_elems(): New function, refactored from page_zip_dir_size().
      
      page_zip_dir_size(): Use page_zip_dir_elems()
      
      page_zip_dir_start_offs(): New function: Gets an offset to the
      compressed page trailer (the dense page directory), including deleted
      records (the free list)
      
      page_zip_dir_start_low(page_zip, n_dense): Constness-preserving
      wrapper macro for page_zip_dir_start_offs().
      
      page_zip_dir_start(page_zip): Constness-preserving
      wrapper macro for page_zip_dir_start_offs().
      
      page_zip_decompress_node_ptrs(), page_zip_decompress_clust(): Replace
      a formula with a fully equivalent page_zip_dir_start_low() call.
      
      page_zip_write_rec(), page_zip_parse_write_node_ptr(),
      page_zip_write_node_ptr(), page_zip_write_trx_id_and_roll_ptr(),
      page_zip_clear_rec(): Replace a formula with an almost equivalent
      page_zip_dir_start() call.
      It is OK to replace page_dir_get_n_heap(page) with
      page_dir_get_n_heap(page_zip->data), because
      ut_ad(page_zip_header_cmp(page_zip, page)) or
      page_zip_validate(page_zip, page) asserts that the
      page headers are identical.
      
      rb:687 approved by Jimmy Yang

    modified:
      storage/innodb_plugin/page/page0zip.c
=== modified file 'storage/innobase/include/trx0sys.h'
--- a/storage/innobase/include/trx0sys.h	revid:marko.makela@strippedh1mvibntaq
+++ b/storage/innobase/include/trx0sys.h	revid:marko.makela@stripped
@@ -256,6 +256,16 @@ trx_in_trx_list(
 /*============*/
 			/* out: TRUE if is in */
 	trx_t*	in_trx);/* in: trx */
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+/********************************************************
+Assert that a transaction is active. */
+UNIV_INLINE
+ibool
+trx_assert_active(
+/*==============*/
+				/* out: TRUE */
+	dulint	trx_id);	/* in: transaction identifier */
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
 /*********************************************************************
 Updates the offset information about the end of the MySQL binlog entry
 which corresponds to the transaction just being committed. In a MySQL

=== modified file 'storage/innobase/include/trx0sys.ic'
--- a/storage/innobase/include/trx0sys.ic	revid:marko.makela@stripped-20110628085709-kckbvih1mvibntaq
+++ b/storage/innobase/include/trx0sys.ic	revid:marko.makela@stripped65715-b4d2feoxu7j88id2
@@ -257,6 +257,27 @@ trx_get_on_id(
 	return(NULL);
 }
 
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+/********************************************************
+Assert that a transaction is active. */
+UNIV_INLINE
+ibool
+trx_assert_active(
+/*==============*/
+				/* out: TRUE */
+	dulint	trx_id)		/* in: transaction identifier */
+{
+	trx_t*	trx;
+
+	mutex_enter(&kernel_mutex);
+	trx = trx_get_on_id(trx_id);
+	ut_a(trx);
+	mutex_exit(&kernel_mutex);
+
+	return(TRUE);
+}
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
+
 /********************************************************************
 Returns the minumum trx id in trx list. This is the smallest id for which
 the trx can possibly be active. (But, you must look at the trx->conc_state to

=== modified file 'storage/innobase/row/row0row.c'
--- a/storage/innobase/row/row0row.c	revid:marko.makela@stripped0628085709-kckbvih1mvibntaq
+++ b/storage/innobase/row/row0row.c	revid:marko.makela@strippedfeoxu7j88id2
@@ -212,35 +212,23 @@ row_build(
 	}
 
 #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
-	if (UNIV_LIKELY_NULL(rec_offs_any_null_extern(rec, offsets))) {
-		/* This condition can occur during crash recovery before
-		trx_rollback_or_clean_all_without_sess() has completed
-		execution.
+	/* This condition can occur during crash recovery before
+	trx_rollback_or_clean_all_without_sess() has completed
+	execution.
+
+	This condition is possible if the server crashed
+	during an insert or update before
+	btr_store_big_rec_extern_fields() did mtr_commit() all
+	BLOB pointers to the clustered index record.
+
+	If the record contains a null BLOB pointer, look up the
+	transaction that holds the implicit lock on this record, and
+	assert that it is active. (In this version of InnoDB, we
+	cannot assert that it was recovered, because there is no
+	trx->is_recovered field.) */
 
-		This condition is possible if the server crashed
-		during an insert or update before
-		btr_store_big_rec_extern_fields() did mtr_commit() all
-		BLOB pointers to the clustered index record.
-
-		Look up the transaction that holds the implicit lock
-		on this record, and assert that it was recovered (and
-		will soon be rolled back). */
-
-		ulint	trx_id_pos	= dict_index_get_sys_col_pos(
-			index, DATA_TRX_ID);
-		ulint	len;
-		dulint	trx_id		= trx_read_trx_id(
-			rec_get_nth_field(rec, offsets, trx_id_pos, &len));
-		trx_t*	trx;
-		ut_a(len == 6);
-
-		mutex_enter(&kernel_mutex);
-		trx = trx_get_on_id(trx_id);
-		ut_a(trx);
-		/* This field does not exist in this version of InnoDB. */
-		/* ut_a(trx->is_recovered); */
-		mutex_exit(&kernel_mutex);
-	}
+	ut_a(!rec_offs_any_null_extern(rec, offsets)
+	     || trx_assert_active(row_get_rec_trx_id(rec, index, offsets)));
 #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
 
 	if (type != ROW_COPY_POINTERS) {

=== modified file 'storage/innodb_plugin/include/row0row.h'
--- a/storage/innodb_plugin/include/row0row.h	revid:marko.makela@stripped
+++ b/storage/innodb_plugin/include/row0row.h	revid:marko.makela@stripped
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, 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
@@ -38,16 +38,16 @@ Created 4/20/1996 Heikki Tuuri
 #include "btr0types.h"
 
 /*********************************************************************//**
-Gets the offset of the trx id field, in bytes relative to the origin of
+Gets the offset of the DB_TRX_ID field, in bytes relative to the origin of
 a clustered index record.
 @return	offset of DATA_TRX_ID */
-UNIV_INTERN
+UNIV_INLINE
 ulint
 row_get_trx_id_offset(
 /*==================*/
-	const rec_t*	rec,	/*!< in: record */
-	dict_index_t*	index,	/*!< in: clustered index */
-	const ulint*	offsets);/*!< in: rec_get_offsets(rec, index) */
+	const dict_index_t*	index,	/*!< in: clustered index */
+	const ulint*		offsets)/*!< in: record offsets */
+	__attribute__((nonnull, warn_unused_result));
 /*********************************************************************//**
 Reads the trx id field from a clustered index record.
 @return	value of the field */
@@ -55,9 +55,10 @@ UNIV_INLINE
 trx_id_t
 row_get_rec_trx_id(
 /*===============*/
-	const rec_t*	rec,	/*!< in: record */
-	dict_index_t*	index,	/*!< in: clustered index */
-	const ulint*	offsets);/*!< in: rec_get_offsets(rec, index) */
+	const rec_t*		rec,	/*!< in: record */
+	const dict_index_t*	index,	/*!< in: clustered index */
+	const ulint*		offsets)/*!< in: rec_get_offsets(rec, index) */
+	__attribute__((nonnull, warn_unused_result));
 /*********************************************************************//**
 Reads the roll pointer field from a clustered index record.
 @return	value of the field */
@@ -65,9 +66,10 @@ UNIV_INLINE
 roll_ptr_t
 row_get_rec_roll_ptr(
 /*=================*/
-	const rec_t*	rec,	/*!< in: record */
-	dict_index_t*	index,	/*!< in: clustered index */
-	const ulint*	offsets);/*!< in: rec_get_offsets(rec, index) */
+	const rec_t*		rec,	/*!< in: record */
+	const dict_index_t*	index,	/*!< in: clustered index */
+	const ulint*		offsets)/*!< in: rec_get_offsets(rec, index) */
+	__attribute__((nonnull, warn_unused_result));
 /*****************************************************************//**
 When an insert or purge to a table is performed, this function builds
 the entry to be inserted into or purged from an index on the table.

=== modified file 'storage/innodb_plugin/include/row0row.ic'
--- a/storage/innodb_plugin/include/row0row.ic	revid:marko.makela@strippedkbvih1mvibntaq
+++ b/storage/innodb_plugin/include/row0row.ic	revid:marko.makela@strippedxu7j88id2
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, 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
@@ -28,15 +28,42 @@ Created 4/20/1996 Heikki Tuuri
 #include "trx0undo.h"
 
 /*********************************************************************//**
+Gets the offset of the DB_TRX_ID field, in bytes relative to the origin of
+a clustered index record.
+@return	offset of DATA_TRX_ID */
+UNIV_INLINE
+ulint
+row_get_trx_id_offset(
+/*==================*/
+	const dict_index_t*	index,	/*!< in: clustered index */
+	const ulint*		offsets)/*!< in: record offsets */
+{
+	ulint	pos;
+	ulint	offset;
+	ulint	len;
+
+	ut_ad(dict_index_is_clust(index));
+	ut_ad(rec_offs_validate(NULL, index, offsets));
+
+	pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
+
+	offset = rec_get_nth_field_offs(offsets, pos, &len);
+
+	ut_ad(len == DATA_TRX_ID_LEN);
+
+	return(offset);
+}
+
+/*********************************************************************//**
 Reads the trx id field from a clustered index record.
 @return	value of the field */
 UNIV_INLINE
 trx_id_t
 row_get_rec_trx_id(
 /*===============*/
-	const rec_t*	rec,	/*!< in: record */
-	dict_index_t*	index,	/*!< in: clustered index */
-	const ulint*	offsets)/*!< in: rec_get_offsets(rec, index) */
+	const rec_t*		rec,	/*!< in: record */
+	const dict_index_t*	index,	/*!< in: clustered index */
+	const ulint*		offsets)/*!< in: rec_get_offsets(rec, index) */
 {
 	ulint	offset;
 
@@ -46,7 +73,7 @@ row_get_rec_trx_id(
 	offset = index->trx_id_offset;
 
 	if (!offset) {
-		offset = row_get_trx_id_offset(rec, index, offsets);
+		offset = row_get_trx_id_offset(index, offsets);
 	}
 
 	return(trx_read_trx_id(rec + offset));
@@ -59,9 +86,9 @@ UNIV_INLINE
 roll_ptr_t
 row_get_rec_roll_ptr(
 /*=================*/
-	const rec_t*	rec,	/*!< in: record */
-	dict_index_t*	index,	/*!< in: clustered index */
-	const ulint*	offsets)/*!< in: rec_get_offsets(rec, index) */
+	const rec_t*		rec,	/*!< in: record */
+	const dict_index_t*	index,	/*!< in: clustered index */
+	const ulint*		offsets)/*!< in: rec_get_offsets(rec, index) */
 {
 	ulint	offset;
 
@@ -71,7 +98,7 @@ row_get_rec_roll_ptr(
 	offset = index->trx_id_offset;
 
 	if (!offset) {
-		offset = row_get_trx_id_offset(rec, index, offsets);
+		offset = row_get_trx_id_offset(index, offsets);
 	}
 
 	return(trx_read_roll_ptr(rec + offset + DATA_TRX_ID_LEN));

=== modified file 'storage/innodb_plugin/include/row0upd.ic'
--- a/storage/innodb_plugin/include/row0upd.ic	revid:marko.makela@stripped
+++ b/storage/innodb_plugin/include/row0upd.ic	revid:marko.makela@stripped
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, 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
@@ -171,7 +171,7 @@ row_upd_rec_sys_fields(
 		ulint	offset = index->trx_id_offset;
 
 		if (!offset) {
-			offset = row_get_trx_id_offset(rec, index, offsets);
+			offset = row_get_trx_id_offset(index, offsets);
 		}
 
 #if DATA_TRX_ID + 1 != DATA_ROLL_PTR

=== modified file 'storage/innodb_plugin/include/trx0sys.h'
--- a/storage/innodb_plugin/include/trx0sys.h	revid:marko.makela@stripped-kckbvih1mvibntaq
+++ b/storage/innodb_plugin/include/trx0sys.h	revid:marko.makela@strippedeoxu7j88id2
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, 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
@@ -284,6 +284,15 @@ ibool
 trx_in_trx_list(
 /*============*/
 	trx_t*	in_trx);/*!< in: trx */
+/***********************************************************//**
+Assert that a transaction has been recovered.
+@return TRUE */
+UNIV_INLINE
+ibool
+trx_assert_recovered(
+/*=================*/
+	trx_id_t	trx_id)		/*!< in: transaction identifier */
+	__attribute__((warn_unused_result));
 /*****************************************************************//**
 Updates the offset information about the end of the MySQL binlog entry
 which corresponds to the transaction just being committed. In a MySQL

=== modified file 'storage/innodb_plugin/include/trx0sys.ic'
--- a/storage/innodb_plugin/include/trx0sys.ic	revid:marko.makela@oracle.com-20110628085709-kckbvih1mvibntaq
+++ b/storage/innodb_plugin/include/trx0sys.ic	revid:marko.makela@oracle.com-20110629065715-b4d2feoxu7j88id2
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, 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
@@ -277,6 +277,28 @@ trx_get_on_id(
 	return(NULL);
 }
 
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+/***********************************************************//**
+Assert that a transaction has been recovered.
+@return TRUE */
+UNIV_INLINE
+ibool
+trx_assert_recovered(
+/*=================*/
+	trx_id_t	trx_id)		/*!< in: transaction identifier */
+{
+	trx_t*		trx;
+
+	mutex_enter(&kernel_mutex);
+	trx = trx_get_on_id(trx_id);
+	ut_a(trx);
+	ut_a(trx->is_recovered);
+	mutex_exit(&kernel_mutex);
+
+	return(TRUE);
+}
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
+
 /****************************************************************//**
 Returns the minumum trx id in trx list. This is the smallest id for which
 the trx can possibly be active. (But, you must look at the trx->conc_state to

=== modified file 'storage/innodb_plugin/row/row0row.c'
--- a/storage/innodb_plugin/row/row0row.c	revid:marko.makela@oracle.com-20110628085709-kckbvih1mvibntaq
+++ b/storage/innodb_plugin/row/row0row.c	revid:marko.makela@stripped10629065715-b4d2feoxu7j88id2
@@ -47,35 +47,6 @@ Created 4/20/1996 Heikki Tuuri
 #include "read0read.h"
 #include "ut0mem.h"
 
-/*********************************************************************//**
-Gets the offset of trx id field, in bytes relative to the origin of
-a clustered index record.
-@return	offset of DATA_TRX_ID */
-UNIV_INTERN
-ulint
-row_get_trx_id_offset(
-/*==================*/
-	const rec_t*	rec __attribute__((unused)),
-				/*!< in: record */
-	dict_index_t*	index,	/*!< in: clustered index */
-	const ulint*	offsets)/*!< in: rec_get_offsets(rec, index) */
-{
-	ulint	pos;
-	ulint	offset;
-	ulint	len;
-
-	ut_ad(dict_index_is_clust(index));
-	ut_ad(rec_offs_validate(rec, index, offsets));
-
-	pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
-
-	offset = rec_get_nth_field_offs(offsets, pos, &len);
-
-	ut_ad(len == DATA_TRX_ID_LEN);
-
-	return(offset);
-}
-
 /*****************************************************************//**
 When an insert or purge to a table is performed, this function builds
 the entry to be inserted into or purged from an index on the table.
@@ -233,33 +204,19 @@ row_build(
 	}
 
 #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
-	if (UNIV_LIKELY_NULL(rec_offs_any_null_extern(rec, offsets))) {
-		/* This condition can occur during crash recovery before
-		trx_rollback_active() has completed execution.
-
-		This condition is possible if the server crashed
-		during an insert or update before
-		btr_store_big_rec_extern_fields() did mtr_commit() all
-		BLOB pointers to the clustered index record.
-
-		Look up the transaction that holds the implicit lock
-		on this record, and assert that it was recovered (and
-		will soon be rolled back). */
-
-		ulint		trx_id_pos	= dict_index_get_sys_col_pos(
-				index, DATA_TRX_ID);
-		ulint		len;
-		trx_id_t	trx_id		= trx_read_trx_id(
-			rec_get_nth_field(rec, offsets, trx_id_pos, &len));
-		trx_t*		trx;
-		ut_a(len == 6);
-
-		mutex_enter(&kernel_mutex);
-		trx = trx_get_on_id(trx_id);
-		ut_a(trx);
-		ut_a(trx->is_recovered);
-		mutex_exit(&kernel_mutex);
-	}
+	/* This condition can occur during crash recovery before
+	trx_rollback_active() has completed execution.
+
+	This condition is possible if the server crashed
+	during an insert or update before
+	btr_store_big_rec_extern_fields() did mtr_commit() all
+	BLOB pointers to the clustered index record.
+
+	If the record contains a null BLOB pointer, look up the
+	transaction that holds the implicit lock on this record, and
+	assert that it was recovered (and will soon be rolled back). */
+	ut_a(!rec_offs_any_null_extern(rec, offsets)
+	     || trx_assert_recovered(row_get_rec_trx_id(rec, index, offsets)));
 #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
 
 	if (type != ROW_COPY_POINTERS) {

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1 branch (marko.makela:3658 to 3659) Bug#12612184marko.makela29 Jun