Skip to content

Commit cf5f0ff

Browse files
hemantdangi-gcjanlindstrom
authored andcommitted
MDEV-37581: Assertion failure sql_base.cc:3927: bool open_and_process_routine
Issue: The testcase galera.galera_as_slave_gtid_myisam fails with below error: mariadb-10.11-build/sql/sql_base.cc:3927: bool open_and_process_routine(THD*, Query_tables_list*, Sroutine_hash_entry*, Prelocking_strategy*, bool, Open_table_context*, bool*, bool*): Assertion `0' failed. The error happens when rollback is applied to replicate MyISAM tables, but the query table list (sroutines_list) is not restored to it's original value before executing this statement. Solution: Backup and restore the query table list to it's original value.
1 parent bf60478 commit cf5f0ff

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

sql/wsrep_schema.cc

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static int open_table(THD *thd, const LEX_CSTRING *schema_name,
343343
(thd->get_stmt_da()->sql_errno() == ER_QUERY_INTERRUPTED));
344344

345345
if (interrupted ||
346-
!open_n_lock_single_table(thd, table_list, table_list->lock_type, flags))
346+
!open_n_lock_single_table(thd, table_list, lock_type, flags))
347347
{
348348
close_thread_tables(thd);
349349
DBUG_RETURN(1);
@@ -805,11 +805,17 @@ int Wsrep_schema::store_view(THD* thd, const Wsrep_view& view)
805805
#ifdef WSREP_SCHEMA_MEMBERS_HISTORY
806806
TABLE* members_history_table= 0;
807807
#endif /* WSREP_SCHEMA_MEMBERS_HISTORY */
808+
Query_tables_list query_tables_list_backup;
808809

809810
Wsrep_schema_impl::wsrep_off wsrep_off(thd);
810811
Wsrep_schema_impl::binlog_off binlog_off(thd);
811812
Wsrep_schema_impl::sql_safe_updates sql_safe_updates(thd);
812813

814+
/*
815+
Backup and restore the query table list changes.
816+
*/
817+
thd->lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
818+
813819
if (trans_begin(thd, MYSQL_START_TRANS_OPT_READ_WRITE))
814820
{
815821
WSREP_ERROR("Failed to start transaction for store view");
@@ -925,6 +931,7 @@ int Wsrep_schema::store_view(THD* thd, const Wsrep_view& view)
925931
thd->release_transactional_locks();
926932

927933
out_not_started:
934+
thd->lex->restore_backup_query_tables_list(&query_tables_list_backup);
928935
DBUG_RETURN(ret);
929936
}
930937

@@ -949,11 +956,17 @@ Wsrep_view Wsrep_schema::restore_view(THD* thd, const Wsrep_id& own_id) const {
949956
int proto_ver= 0;
950957
wsrep_cap_t capabilities= 0;
951958
std::vector<Wsrep_view::member> members;
959+
Query_tables_list query_tables_list_backup;
952960

953961
// we don't want causal waits for reading non-replicated private data
954962
int const wsrep_sync_wait_saved= thd->variables.wsrep_sync_wait;
955963
thd->variables.wsrep_sync_wait= 0;
956964

965+
/*
966+
Backup and restore the query table list changes.
967+
*/
968+
thd->lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
969+
957970
if (trans_begin(thd, MYSQL_START_TRANS_OPT_READ_ONLY)) {
958971
WSREP_ERROR("wsrep_schema::restore_view(): Failed to start transaction");
959972
goto out;
@@ -1068,12 +1081,14 @@ Wsrep_view Wsrep_schema::restore_view(THD* thd, const Wsrep_id& own_id) const {
10681081
os << "Restored cluster view:\n" << ret_view;
10691082
WSREP_INFO("%s", os.str().c_str());
10701083
}
1084+
thd->lex->restore_backup_query_tables_list(&query_tables_list_backup);
10711085
DBUG_RETURN(ret_view);
10721086
}
10731087
else
10741088
{
10751089
WSREP_ERROR("wsrep_schema::restore_view() failed.");
10761090
Wsrep_view ret_view;
1091+
thd->lex->restore_backup_query_tables_list(&query_tables_list_backup);
10771092
DBUG_RETURN(ret_view);
10781093
}
10791094
}
@@ -1460,6 +1475,7 @@ int Wsrep_schema::replay_transaction(THD* orig_thd,
14601475
{
14611476
DBUG_ENTER("Wsrep_schema::replay_transaction");
14621477
DBUG_ASSERT(!fragments.empty());
1478+
Query_tables_list query_tables_list_backup;
14631479

14641480
THD *thd= new THD(next_thread_id(), true);
14651481
if (!thd)
@@ -1471,7 +1487,13 @@ int Wsrep_schema::replay_transaction(THD* orig_thd,
14711487
thd->thread_stack= (orig_thd ? orig_thd->thread_stack : (char *) &thd);
14721488
wsrep_assign_from_threadvars(thd);
14731489

1490+
1491+
/*
1492+
Backup and restore the query table list changes.
1493+
*/
1494+
orig_thd->lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
14741495
int ret= ::replay_transaction(thd, orig_thd, rli, ws_meta, fragments);
1496+
orig_thd->lex->restore_backup_query_tables_list(&query_tables_list_backup);
14751497

14761498
delete thd;
14771499
DBUG_RETURN(ret);
@@ -1774,6 +1796,7 @@ void Wsrep_schema::store_allowlist(std::vector<std::string>& ip_allowlist)
17741796
TABLE* allowlist_table= 0;
17751797
TABLE_LIST allowlist_table_l;
17761798
int error;
1799+
17771800
Wsrep_schema_impl::init_stmt(thd);
17781801
if (Wsrep_schema_impl::open_for_write(thd, allowlist_table_str.c_str(),
17791802
&allowlist_table_l))

0 commit comments

Comments
 (0)