[MDEV-26753] Assertion `state == TRX_STATE_PREPARED || state == TRX_STATE_PREPARED_RECOVERED || state == TRX_STATE_ACTIVE' failed Created: 2021-10-04  Updated: 2022-04-26  Resolved: 2022-04-26

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.6, 10.7
Fix Version/s: 10.6.8, 10.7.4, 10.8.3, 10.9.1

Type: Bug Priority: Major
Reporter: Ramesh Sivaraman Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: not-10.2, not-10.3, not-10.4, not-10.5


 Description   

SET SESSION transaction isolation level SERIALIZABLE;
CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY);
XA START 'test';
SELECT * FROM mysql.innodb_index_stats WHERE table_name='t2' AND index_name='SECOND';
INSERT INTO t2 VALUES (1);
INSERT INTO t2 VALUES (2);
UPDATE mysql.innodb_table_stats SET last_update="2020-01-01" WHERE database_name="mysql" AND table_name="t2";

Leads to:

10.7.0 92e52a0c582e435e2b8fe4c4d6c615e19080e9be (Debug)

mysqld: /test/10.7_dbg/storage/innobase/trx/trx0trx.cc:461: void trx_t::commit_state(): Assertion `state == TRX_STATE_PREPARED || state == TRX_STATE_PREPARED_RECOVERED || state == TRX_STATE_ACTIVE' failed.

10.7.0 92e52a0c582e435e2b8fe4c4d6c615e19080e9be (Debug)

Core was generated by `/test/GAL_MD300921-mariadb-10.7.0-linux-x86_64-dbg/bin/mysqld --no-defaults --c'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x14e3599f4700 (LWP 1613957))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055b926594b16 in my_write_core (sig=sig@entry=6) at /test/10.7_dbg/mysys/stacktrace.c:424
#2  0x000055b925d8c445 in handle_fatal_signal (sig=6) at /test/10.7_dbg/sql/signal_handler.cc:345
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x000014e37d2cd859 in __GI_abort () at abort.c:79
#6  0x000014e37d2cd729 in __assert_fail_base (fmt=0x14e37d463588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55b9269f0278 "state == TRX_STATE_PREPARED || state == TRX_STATE_PREPARED_RECOVERED || state == TRX_STATE_ACTIVE", file=0x55b9269ef5b0 "/test/10.7_dbg/storage/innobase/trx/trx0trx.cc", line=461, function=<optimized out>) at assert.c:92
#7  0x000014e37d2def36 in __GI___assert_fail (assertion=assertion@entry=0x55b9269f0278 "state == TRX_STATE_PREPARED || state == TRX_STATE_PREPARED_RECOVERED || state == TRX_STATE_ACTIVE", file=file@entry=0x55b9269ef5b0 "/test/10.7_dbg/storage/innobase/trx/trx0trx.cc", line=line@entry=461, function=function@entry=0x55b9269f02da "void trx_t::commit_state()") at assert.c:101
#8  0x000055b92636f49e in trx_t::commit_state (this=0x14e37c114390) at /usr/include/c++/9/atomic:250
#9  0x000055b92636fa9a in trx_t::commit_in_memory (this=this@entry=0x14e37c114390, mtr=mtr@entry=0x0) at /test/10.7_dbg/storage/innobase/trx/trx0trx.cc:1269
#10 0x000055b92636af57 in trx_t::commit_low (this=this@entry=0x14e37c114390, mtr=0x0) at /test/10.7_dbg/storage/innobase/trx/trx0trx.cc:1448
#11 0x000055b92636b1cf in trx_t::commit_persist (this=this@entry=0x14e37c114390) at /test/10.7_dbg/storage/innobase/trx/trx0trx.cc:1462
#12 0x000055b92636b3a1 in trx_t::commit (this=this@entry=0x14e37c114390) at /test/10.7_dbg/storage/innobase/trx/trx0trx.cc:1468
#13 0x000055b926479b31 in dict_stats_save (table_orig=table_orig@entry=0x14e324021718, only_for_index=only_for_index@entry=0x0) at /test/10.7_dbg/storage/innobase/dict/dict0stats.cc:2729
#14 0x000055b92647cd14 in dict_stats_update (table=table@entry=0x14e324021718, stats_upd_option=stats_upd_option@entry=DICT_STATS_RECALC_PERSISTENT) at /test/10.7_dbg/storage/innobase/dict/dict0stats.cc:3469
#15 0x000055b92647f0f6 in dict_stats_process_entry_from_recalc_pool (thd=0x14e3500046d8) at /test/10.7_dbg/storage/innobase/dict/dict0stats_bg.cc:340
#16 dict_stats_func () at /test/10.7_dbg/storage/innobase/dict/dict0stats_bg.cc:393
#17 0x000055b9265220ee in tpool::thread_pool_generic::timer_generic::run (this=0x55b929207a60) at /test/10.7_dbg/tpool/tpool_generic.cc:313
#18 tpool::thread_pool_generic::timer_generic::execute (arg=0x55b929207a60) at /test/10.7_dbg/tpool/tpool_generic.cc:333
#19 0x000055b92652305d in tpool::task::execute (this=0x55b929207aa0) at /test/10.7_dbg/tpool/task.cc:52
#20 0x000055b926521c07 in tpool::thread_pool_generic::worker_main (this=0x55b928e6b060, thread_var=0x55b928e7ac80) at /test/10.7_dbg/tpool/tpool_generic.cc:550
#21 0x000055b926521f40 in std::__invoke_impl<void, void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*> (__t=<optimized out>, __f=<optimized out>) at /usr/include/c++/9/bits/invoke.h:89
#22 std::__invoke<void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*> (__fn=<optimized out>) at /usr/include/c++/9/bits/invoke.h:95
#23 std::thread::_Invoker<std::tuple<void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*> >::_M_invoke<0ul, 1ul, 2ul> (this=<optimized out>) at /usr/include/c++/9/thread:244
#24 std::thread::_Invoker<std::tuple<void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*> >::operator() (this=<optimized out>) at /usr/include/c++/9/thread:251
#25 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*> > >::_M_run (this=<optimized out>) at /usr/include/c++/9/thread:195
#26 0x000014e37d6c1d84 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#27 0x000014e37d7db609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#28 0x000014e37d3ca293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.6.5 (dbg), 10.7.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.41 (dbg), 10.3.32 (dbg), 10.4.22 (dbg), 10.5.13 (dbg)



 Comments   
Comment by Alice Sherepa [ 2022-04-05 ]

I am getting on 10.9 smth similar:

preview-10.9-MDEV-27021-explain 0e62bfe92647ab4b5a2a85

mysqld: /git/10.9/storage/innobase/trx/trx0trx.cc:461: void trx_t::commit_state(): Assertion `state == TRX_STATE_PREPARED || state == TRX_STATE_PREPARED_RECOVERED || state == TRX_STATE_ACTIVE' failed.
220405 10:52:21 [ERROR] mysqld got signal 6 ;
 
Server version: 10.9.0-MariaDB-debug-log
 
linux/raise.c:51(__GI_raise)[0x7f1c02a777bb]
stdlib/abort.c:81(__GI_abort)[0x7f1c02a62535]
intl/loadmsgcat.c:1177(_nl_load_domain)[0x7f1c02a6240f]
??:0(__assert_fail)[0x7f1c02a70102]
trx/trx0trx.cc:461(trx_t::commit_low(mtr_t*))[0x5643148923d5]
trx/trx0trx.cc:1446(trx_t::commit_persist())[0x564314892db1]
trx/trx0trx.cc:1460(trx_t::commit())[0x564314892e16]
dict/dict0stats.cc:3116(dict_stats_save(dict_table_t*, unsigned long const*))[0x564314982922]
dict/dict0stats.cc:3867(dict_stats_update(dict_table_t*, dict_stats_upd_option_t))[0x5643149847eb]
dict/dict0stats_bg.cc:346(dict_stats_process_entry_from_recalc_pool(THD*))[0x56431498ac8b]
dict/dict0stats_bg.cc:382(dict_stats_func(void*))[0x56431498aed9]
tpool/tpool_generic.cc:314(tpool::thread_pool_generic::timer_generic::run())[0x564314a29736]
tpool/tpool_generic.cc:333(tpool::thread_pool_generic::timer_generic::execute(void*))[0x564314a2984c]
tpool/task.cc:38(tpool::task::execute())[0x564314a2e87f]
tpool/tpool_generic.cc:547(tpool::thread_pool_generic::worker_main(tpool::worker_data*))[0x564314a27fd0]
bits/invoke.h:73(void std::__invoke_impl<void, void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*>(std::__invoke_memfun_deref, void (tpool::thread_pool_generic::*&&)(tpool::worker_data*), tpool::thread_pool_generic*&&, tpool::worker_data*&&))[0x564314a2b624]
bits/invoke.h:96(std::__invoke_result<void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*>::type std::__invoke<void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*>(void (tpool::thread_pool_generic::*&&)(tpool::worker_data*), tpool::thread_pool_generic*&&, tpool::worker_data*&&))[0x564314a2a757]
8/thread:244(decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)(), (_S_declval<2ul>)())) std::thread::_Invoker<std::tuple<void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*> >::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>))[0x564314a2e291]
8/thread:253(std::thread::_Invoker<std::tuple<void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*> >::operator()())[0x564314a2e230]
8/thread:196(std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (tpool::thread_pool_generic::*)(tpool::worker_data*), tpool::thread_pool_generic*, tpool::worker_data*> > >::_M_run())[0x564314a2e214]
??:0(std::error_code::default_error_condition() const)[0x7f1c02e58b2f]
nptl/pthread_create.c:487(start_thread)[0x7f1c02f2dfa3]
x86_64/clone.S:97(clone)[0x7f1c02b38eff]

Generated at Thu Feb 08 09:47:41 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.