row0sel.c, btr0pcur.c, btr0pcur.ic, btr0pcur.h:

  Add diagnostic code to track assertion failure in ut_a(cursor->old_stored == BTR_PCUR_OLD_STORED); the failure happened in OPTIMIZE TABLE, and in 4.0.24 in some other context
parent 0134a2b2
...@@ -14,6 +14,7 @@ Created 2/23/1996 Heikki Tuuri ...@@ -14,6 +14,7 @@ Created 2/23/1996 Heikki Tuuri
#include "ut0byte.h" #include "ut0byte.h"
#include "rem0cmp.h" #include "rem0cmp.h"
#include "trx0trx.h"
/****************************************************************** /******************************************************************
Allocates memory for a persistent cursor object and initializes the cursor. */ Allocates memory for a persistent cursor object and initializes the cursor. */
...@@ -203,7 +204,14 @@ btr_pcur_restore_position( ...@@ -203,7 +204,14 @@ btr_pcur_restore_position(
ut_a(cursor->pos_state == BTR_PCUR_WAS_POSITIONED ut_a(cursor->pos_state == BTR_PCUR_WAS_POSITIONED
|| cursor->pos_state == BTR_PCUR_IS_POSITIONED); || cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_a(cursor->old_stored == BTR_PCUR_OLD_STORED); if (cursor->old_stored != BTR_PCUR_OLD_STORED) {
ut_print_buf(stderr, (const byte*)cursor, sizeof(btr_pcur_t));
if (cursor->trx_if_known) {
trx_print(stderr, cursor->trx_if_known);
}
ut_a(0);
}
if (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE if (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE
|| cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE) { || cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE) {
......
...@@ -477,6 +477,10 @@ struct btr_pcur_struct{ ...@@ -477,6 +477,10 @@ struct btr_pcur_struct{
BTR_PCUR_WAS_POSITIONED, BTR_PCUR_WAS_POSITIONED,
BTR_PCUR_NOT_POSITIONED */ BTR_PCUR_NOT_POSITIONED */
ulint search_mode; /* PAGE_CUR_G, ... */ ulint search_mode; /* PAGE_CUR_G, ... */
trx_t* trx_if_known; /* the transaction, if we know it;
otherwise this field is not defined;
can ONLY BE USED in error prints in
fatal assertion failures! */
/*-----------------------------*/ /*-----------------------------*/
/* NOTE that the following fields may possess dynamically allocated /* NOTE that the following fields may possess dynamically allocated
memory which should be freed if not needed anymore! */ memory which should be freed if not needed anymore! */
......
...@@ -493,6 +493,8 @@ btr_pcur_open( ...@@ -493,6 +493,8 @@ btr_pcur_open(
btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode,
btr_cursor, 0, mtr); btr_cursor, 0, mtr);
cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->pos_state = BTR_PCUR_IS_POSITIONED;
cursor->trx_if_known = NULL;
} }
/****************************************************************** /******************************************************************
...@@ -535,6 +537,8 @@ btr_pcur_open_with_no_init( ...@@ -535,6 +537,8 @@ btr_pcur_open_with_no_init(
cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->pos_state = BTR_PCUR_IS_POSITIONED;
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
cursor->trx_if_known = NULL;
} }
/********************************************************************* /*********************************************************************
...@@ -568,6 +572,8 @@ btr_pcur_open_at_index_side( ...@@ -568,6 +572,8 @@ btr_pcur_open_at_index_side(
pcur->pos_state = BTR_PCUR_IS_POSITIONED; pcur->pos_state = BTR_PCUR_IS_POSITIONED;
pcur->old_stored = BTR_PCUR_OLD_NOT_STORED; pcur->old_stored = BTR_PCUR_OLD_NOT_STORED;
pcur->trx_if_known = NULL;
} }
/************************************************************************** /**************************************************************************
...@@ -592,6 +598,8 @@ btr_pcur_open_at_rnd_pos( ...@@ -592,6 +598,8 @@ btr_pcur_open_at_rnd_pos(
btr_pcur_get_btr_cur(cursor), mtr); btr_pcur_get_btr_cur(cursor), mtr);
cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->pos_state = BTR_PCUR_IS_POSITIONED;
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
cursor->trx_if_known = NULL;
} }
/****************************************************************** /******************************************************************
...@@ -617,4 +625,6 @@ btr_pcur_close( ...@@ -617,4 +625,6 @@ btr_pcur_close(
cursor->latch_mode = BTR_NO_LATCHES; cursor->latch_mode = BTR_NO_LATCHES;
cursor->pos_state = BTR_PCUR_NOT_POSITIONED; cursor->pos_state = BTR_PCUR_NOT_POSITIONED;
cursor->trx_if_known = NULL;
} }
...@@ -2507,6 +2507,8 @@ row_sel_get_clust_rec_for_mysql( ...@@ -2507,6 +2507,8 @@ row_sel_get_clust_rec_for_mysql(
clust_rec = btr_pcur_get_rec(prebuilt->clust_pcur); clust_rec = btr_pcur_get_rec(prebuilt->clust_pcur);
prebuilt->clust_pcur->trx_if_known = trx;
/* Note: only if the search ends up on a non-infimum record is the /* Note: only if the search ends up on a non-infimum record is the
low_match value the real match to the search tuple */ low_match value the real match to the search tuple */
...@@ -3222,6 +3224,8 @@ row_search_for_mysql( ...@@ -3222,6 +3224,8 @@ row_search_for_mysql(
btr_pcur_open_with_no_init(index, search_tuple, mode, btr_pcur_open_with_no_init(index, search_tuple, mode,
BTR_SEARCH_LEAF, BTR_SEARCH_LEAF,
pcur, 0, &mtr); pcur, 0, &mtr);
pcur->trx_if_known = trx;
} else { } else {
if (mode == PAGE_CUR_G) { if (mode == PAGE_CUR_G) {
btr_pcur_open_at_index_side(TRUE, index, btr_pcur_open_at_index_side(TRUE, index,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment