diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2022-01-05 11:52:33 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2022-01-10 08:58:56 +0200 |
commit | 5a6de6f40c8ca955d9c0b5159d8ea3afdca626ed (patch) | |
tree | afb7eaa2e9407a1b5f4c2888ba976cb52b627bbb /sql | |
parent | c6a890a795595a2049a42a7c7039e03e674b13a1 (diff) | |
download | mariadb-git-5a6de6f40c8ca955d9c0b5159d8ea3afdca626ed.tar.gz |
MDEV-18848 : Galera: 10.4 node crashed with Assertion `client_state.transaction().active()` after altering SEQUENCE table's engine to myisam and back to innodbbb-10.4-24845
We need to start Galera transaction for select NEXT VALUE FOR
sequence if it is not yet started. Note that ALTER is handled
as TOI and transaction is already started.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_sequence.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sql/ha_sequence.cc b/sql/ha_sequence.cc index 260f2c202fa..b0611c1505a 100644 --- a/sql/ha_sequence.cc +++ b/sql/ha_sequence.cc @@ -30,6 +30,10 @@ #include "sql_base.h" #include "log_event.h" +#ifdef WITH_WSREP +#include "wsrep_trans_observer.h" /* wsrep_start_transaction() */ +#endif + /* Table flags we should inherit and disable from the original engine. We add HA_STATS_RECORDS_IS_EXACT as ha_sequence::info() will ensure @@ -199,6 +203,7 @@ int ha_sequence::write_row(const uchar *buf) int error; sequence_definition tmp_seq; bool sequence_locked; + THD *thd= table->in_use; DBUG_ENTER("ha_sequence::write_row"); DBUG_ASSERT(table->record[0] == buf); @@ -235,8 +240,6 @@ int ha_sequence::write_row(const uchar *buf) on master and slaves - Check that the new row is an accurate SEQUENCE object */ - - THD *thd= table->in_use; if (table->s->tmp_table == NO_TMP_TABLE && thd->mdl_context.upgrade_shared_lock(table->mdl_ticket, MDL_EXCLUSIVE, @@ -255,6 +258,16 @@ int ha_sequence::write_row(const uchar *buf) sequence->write_lock(table); } +#ifdef WITH_WSREP + /* We need to start Galera transaction for select NEXT VALUE FOR + sequence if it is not yet started. Note that ALTER is handled + as TOI. */ + if (WSREP_ON && WSREP(thd) && + !thd->wsrep_trx().active() && + wsrep_thd_is_local(thd)) + wsrep_start_transaction(thd, thd->wsrep_next_trx_id()); +#endif + if (likely(!(error= file->update_first_row(buf)))) { Log_func *log_func= Write_rows_log_event::binlog_row_logging_function; |