Skip to content

Commit 6974962

Browse files
committed
MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf on table with virtual columns and indexes
Cause Stale thd->m_stmt_da->m_sql_errno which is from different invocation. Fix Reset error state before attempt to open table.
1 parent af5b0db commit 6974962

File tree

7 files changed

+118
-0
lines changed

7 files changed

+118
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf on table with virtual columns and indexes
3+
#
4+
set @saved_frequency= @@global.innodb_purge_rseg_truncate_frequency;
5+
set global innodb_purge_rseg_truncate_frequency= 1;
6+
set @saved_dbug= @@global.debug_dbug;
7+
set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2";
8+
create table t1 (
9+
pk serial, vb tinyblob as (b) virtual, b tinyblob,
10+
primary key(pk), index (vb(64)))
11+
engine innodb;
12+
insert ignore into t1 (b) values ('foo');
13+
select * into outfile 'load.data' from t1;
14+
load data infile 'load.data' replace into table t1;
15+
set debug_sync= "now WAIT_FOR latch_released";
16+
set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1";
17+
drop table t1;
18+
set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table";
19+
create table t1 (
20+
pk serial, vb tinyblob as (b) virtual, b tinyblob,
21+
primary key(pk), index (vb(64)))
22+
engine innodb;
23+
insert ignore into t1 (b) values ('foo');
24+
select * into outfile 'load.data' from t1;
25+
load data infile 'load.data' replace into table t1;
26+
set debug_sync= "now WAIT_FOR got_no_such_table";
27+
set global debug_dbug= @saved_dbug;
28+
drop table t1;
29+
set global innodb_purge_rseg_truncate_frequency= @saved_frequency;
30+
set debug_sync= "RESET";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--innodb-purge-threads=1
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--source include/have_debug.inc
2+
--source include/have_innodb.inc
3+
4+
--echo #
5+
--echo # MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf on table with virtual columns and indexes
6+
--echo #
7+
8+
--let $datadir= `select @@datadir`
9+
set @saved_frequency= @@global.innodb_purge_rseg_truncate_frequency;
10+
set global innodb_purge_rseg_truncate_frequency= 1;
11+
set @saved_dbug= @@global.debug_dbug;
12+
set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2";
13+
14+
create table t1 (
15+
pk serial, vb tinyblob as (b) virtual, b tinyblob,
16+
primary key(pk), index (vb(64)))
17+
engine innodb;
18+
19+
insert ignore into t1 (b) values ('foo');
20+
21+
select * into outfile 'load.data' from t1;
22+
load data infile 'load.data' replace into table t1;
23+
24+
set debug_sync= "now WAIT_FOR latch_released";
25+
set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1";
26+
drop table t1;
27+
--remove_file $datadir/test/load.data
28+
29+
set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table";
30+
31+
create table t1 (
32+
pk serial, vb tinyblob as (b) virtual, b tinyblob,
33+
primary key(pk), index (vb(64)))
34+
engine innodb;
35+
36+
insert ignore into t1 (b) values ('foo');
37+
38+
select * into outfile 'load.data' from t1;
39+
load data infile 'load.data' replace into table t1;
40+
41+
set debug_sync= "now WAIT_FOR got_no_such_table";
42+
# FIXME: Racing condition here:
43+
# 1. purge thread goes into sending got_no_such_table
44+
# 2. test thread finishes debug_sync= "RESET" below
45+
# 3. purge thread sends got_no_such_table
46+
set global debug_dbug= @saved_dbug;
47+
48+
# cleanup
49+
drop table t1;
50+
--remove_file $datadir/test/load.data
51+
52+
set global innodb_purge_rseg_truncate_frequency= @saved_frequency;
53+
set debug_sync= "RESET";

sql/sql_class.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4826,6 +4826,11 @@ unsigned long long thd_get_query_id(const MYSQL_THD thd)
48264826
return((unsigned long long)thd->query_id);
48274827
}
48284828

4829+
void thd_clear_error(MYSQL_THD thd)
4830+
{
4831+
thd->clear_error();
4832+
}
4833+
48294834
extern "C" const struct charset_info_st *thd_charset(MYSQL_THD thd)
48304835
{
48314836
return(thd->charset());

sql/sql_table.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,11 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, bool if_exists,
21082108
}
21092109
}
21102110

2111+
DBUG_EXECUTE_IF("ib_purge_virtual_mdev_16222_1",
2112+
DBUG_ASSERT(!debug_sync_set_action(
2113+
thd,
2114+
STRING_WITH_LEN("now SIGNAL drop_started"))););
2115+
21112116
/* mark for close and remove all cached entries */
21122117
thd->push_internal_handler(&err_handler);
21132118
error= mysql_rm_table_no_locks(thd, tables, if_exists, drop_temporary,

sql/table.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8256,6 +8256,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
82568256

82578257
int TABLE::update_virtual_field(Field *vf)
82588258
{
8259+
DBUG_ASSERT(!in_use->is_error());
82598260
Query_arena backup_arena;
82608261
DBUG_ENTER("TABLE::update_virtual_field");
82618262
in_use->set_n_backup_active_arena(expr_arena, &backup_arena);

storage/innobase/handler/ha_innodb.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ this program; if not, write to the Free Software Foundation, Inc.,
118118

119119
extern "C" void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all);
120120
unsigned long long thd_get_query_id(const MYSQL_THD thd);
121+
void thd_clear_error(MYSQL_THD thd);
122+
121123
TABLE *find_fk_open_table(THD *thd, const char *db, size_t db_len,
122124
const char *table, size_t table_len);
123125
MYSQL_THD create_thd();
@@ -20244,6 +20246,8 @@ static TABLE* innodb_acquire_mdl(THD* thd, dict_table_t* table)
2024420246
return NULL;
2024520247
}
2024620248

20249+
DEBUG_SYNC(thd, "ib_purge_virtual_latch_released");
20250+
2024720251
const table_id_t table_id = table->id;
2024820252
retry_mdl:
2024920253
const bool unaccessible = !table->is_readable() || table->corrupted;
@@ -20255,6 +20259,10 @@ static TABLE* innodb_acquire_mdl(THD* thd, dict_table_t* table)
2025520259

2025620260
TABLE* mariadb_table = open_purge_table(thd, db_buf, db_buf_len,
2025720261
tbl_buf, tbl_buf_len);
20262+
if (!mariadb_table)
20263+
thd_clear_error(thd);
20264+
20265+
DEBUG_SYNC(thd, "ib_purge_virtual_got_no_such_table");
2025820266

2025920267
table = dict_table_open_on_id(table_id, false, DICT_TABLE_OP_NORMAL);
2026020268

@@ -20304,6 +20312,20 @@ static TABLE* innodb_acquire_mdl(THD* thd, dict_table_t* table)
2030420312
for purge thread */
2030520313
static TABLE* innodb_find_table_for_vc(THD* thd, dict_table_t* table)
2030620314
{
20315+
DBUG_EXECUTE_IF(
20316+
"ib_purge_virtual_mdev_16222_1",
20317+
DBUG_ASSERT(!debug_sync_set_action(
20318+
thd,
20319+
STRING_WITH_LEN("ib_purge_virtual_latch_released "
20320+
"SIGNAL latch_released "
20321+
"WAIT_FOR drop_started"))););
20322+
DBUG_EXECUTE_IF(
20323+
"ib_purge_virtual_mdev_16222_2",
20324+
DBUG_ASSERT(!debug_sync_set_action(
20325+
thd,
20326+
STRING_WITH_LEN("ib_purge_virtual_got_no_such_table "
20327+
"SIGNAL got_no_such_table"))););
20328+
2030720329
if (THDVAR(thd, background_thread)) {
2030820330
/* Purge thread acquires dict_sys.latch while
2030920331
processing undo log record. Release it
@@ -20639,6 +20661,7 @@ innobase_get_computed_value(
2063920661
dbug_tmp_restore_column_map(mysql_table->write_set, old_write_set);
2064020662

2064120663
if (ret != 0) {
20664+
// FIXME: Why this error message is macro-hidden?
2064220665
#ifdef INNODB_VIRTUAL_DEBUG
2064320666
ib::warn() << "Compute virtual column values failed ";
2064420667
fputs("InnoDB: Cannot compute value for following record ",

0 commit comments

Comments
 (0)