Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-37985

Assertion `thd->transaction->stmt.is_empty()' failed in bool trans_check(THD*)

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      Galera cluster secondary node crashes when running following RQG test
      Test case

      perl gendata.pl --dsn=dbi:mysql:host=127.0.0.1:port=11430:user=root:database=test --spec=conf/mariadb/MDEV-34124-seq.zz
      perl gentest.pl --dsn=dbi:mysql:host=127.0.0.1:port=11430:user=root:database=test --grammar=conf/mariadb/MDEV-34124-seq.yy --threads=32 --duration=10300 --queries=100000000 &
      perl gentest.pl --dsn=dbi:mysql:host=127.0.0.1:port=11953:user=root:database=test --grammar=conf/mariadb/MDEV-34124-seq.yy --threads=32 --duration=10300 --queries=100000000 &
      

      Attached RQG grammar and cnf files

      Leads to

      CS 12.2.0 49c3c2ab3642dbbabc8cba71210ad3c468dd8540 (Debug) Build 21/10/2025

      Core was generated by `/test/GAL_MD211025-mariadb-12.2.0-linux-x86_64-dbg/bin/mariadbd --defaults-file'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 4065228)]
      (gdb) bt
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
      #1  __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
      #2  __GI___pthread_kill (threadid=<optimized out>, signo=6) at ./nptl/pthread_kill.c:89
      #3  0x0000571fd7f78969 in my_write_core (sig=6) at /test/12.2_dbg/mysys/stacktrace.c:424
      #4  0x0000571fd75f7e91 in handle_fatal_signal (sig=6) at /test/12.2_dbg/sql/signal_handler.cc:298
      #5  <signal handler called>
      #6  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
      #7  __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
      #8  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
      #9  0x00007b8a6444527e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
      #10 0x00007b8a644288ff in __GI_abort () at ./stdlib/abort.c:79
      #11 0x00007b8a6442881b in __assert_fail_base (fmt=0x7b8a645d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x571fd82f4398 "thd->transaction->stmt.is_empty()", 
          file=file@entry=0x571fd82f43c0 "/test/12.2_dbg/sql/transaction.cc", line=line@entry=74, function=function@entry=0x571fd82f43e2 "bool trans_check(THD*)") at ./assert/assert.c:96
      #12 0x00007b8a6443b517 in __assert_fail (assertion=0x571fd82f4398 "thd->transaction->stmt.is_empty()", file=0x571fd82f43c0 "/test/12.2_dbg/sql/transaction.cc", line=74, 
          function=0x571fd82f43e2 "bool trans_check(THD*)") at ./assert/assert.c:105
      #13 0x0000571fd73cddb2 in trans_check (thd=0x7b76f8094348) at /test/12.2_dbg/sql/transaction.cc:74
      #14 0x0000571fd73ceba3 in trans_rollback (thd=0x7b76f8094348) at /test/12.2_dbg/sql/transaction.cc:379
      #15 0x0000571fd712d064 in THD::cleanup (this=0x7b76f8094348) at /test/12.2_dbg/sql/sql_class.cc:1697
      #16 0x0000571fd712d542 in THD::free_connection (this=0x7b76f8094348) at /test/12.2_dbg/sql/sql_class.cc:1770
      #17 0x0000571fd712d9ac in THD::~THD (this=0x7b76f8094348, __in_chrg=<optimized out>) at /test/12.2_dbg/sql/sql_class.cc:1865
      #18 0x0000571fd712df8c in THD::~THD (this=0x7b76f8094348, __in_chrg=<optimized out>) at /test/12.2_dbg/sql/sql_class.cc:1930
      #19 0x0000571fd79e3192 in Wsrep_schema::replay_transaction (this=0x571ff801e3e0, orig_thd=0x7b76f8077258, rli=0x7b76f807f580, ws_meta=..., fragments=std::__debug::vector of length 1, capacity 1 = {...})
          at /test/12.2_dbg/sql/wsrep_schema.cc:1497
      #20 0x0000571fd799c6e7 in Wsrep_replayer_service::apply_write_set (this=0x7b7ed85fd450, ws_meta=..., data=..., err=...) at /test/12.2_dbg/sql/wsrep_high_priority_service.cc:760
      #21 0x0000571fd82065f6 in apply_write_set (server_state=..., high_priority_service=..., ws_handle=..., ws_meta=..., data=...) at /test/12.2_dbg/wsrep-lib/src/server_state.cpp:407
      #22 0x0000571fd820a2fd in wsrep::server_state::on_apply (this=0x571ff79e6d10, high_priority_service=..., ws_handle=..., ws_meta=..., data=...) at /test/12.2_dbg/wsrep-lib/src/server_state.cpp:1131
      #23 0x0000571fd8233a23 in wsrep::high_priority_service::apply (this=0x7b7ed85fd450, ws_handle=..., ws_meta=..., data=...) at /test/12.2_dbg/wsrep-lib/include/wsrep/high_priority_service.hpp:47
      #24 0x0000571fd82300e0 in (anonymous namespace)::apply_cb (ctx=0x7b7ed85fd450, wsh=0x7b7ed85fcc10, flags=9, buf=0x7b7ed85fcc20, meta=0x7b7ed85fcf00, exit_loop=0x7b7ed85fcec0)
          at /test/12.2_dbg/wsrep-lib/src/wsrep_provider_v26.cpp:510
      #25 0x00007b8a63278c15 in galera::TrxHandleSlave::apply (this=this@entry=0x7b5c100859a0, recv_ctx=recv_ctx@entry=0x7b7ed85fd450, 
          apply_cb=0x571fd822fea4 <(anonymous namespace)::apply_cb(void*, wsrep_ws_handle_t const*, uint32_t, wsrep_buf_t const*, wsrep_trx_meta_t const*, wsrep_bool_t*)>, meta=..., exit_loop=@0x7b7ed85fcec0: false)
          at /test/galera_4x/galera/src/trx_handle.cpp:404
      #26 0x00007b8a632a301e in galera::ReplicatorSMM::replay_trx (this=0x571ff7c3af50, trx=..., lock=..., trx_ctx=0x7b7ed85fd450) at /test/galera_4x/galera/src/replicator_smm.cpp:1112
      #27 0x00007b8a63268103 in galera_replay_trx (gh=<optimized out>, trx_handle=<optimized out>, recv_ctx=0x7b7ed85fd450) at /test/galera_4x/galera/src/wsrep_provider.cpp:341
      #28 0x0000571fd8232401 in wsrep::wsrep_provider_v26::replay (this=0x571ff79cb360, ws_handle=..., reply_service=0x7b7ed85fd450) at /test/12.2_dbg/wsrep-lib/src/wsrep_provider_v26.cpp:1040
      #29 0x0000571fd7994509 in Wsrep_client_service::replay (this=0x7b76f8007710) at /test/12.2_dbg/sql/wsrep_client_service.cc:303
      #30 0x0000571fd8225a6f in wsrep::transaction::replay (this=0x7b76f80077b0, lock=...) at /test/12.2_dbg/wsrep-lib/src/transaction.cpp:2069
      #31 0x0000571fd8220ca6 in wsrep::transaction::after_statement (this=0x7b76f80077b0, lock=...) at /test/12.2_dbg/wsrep-lib/src/transaction.cpp:893
      #32 0x0000571fd81ef402 in wsrep::client_state::after_statement (this=0x7b76f8007728) at /test/12.2_dbg/wsrep-lib/src/client_state.cpp:264
      #33 0x0000571fd71ba1cf in wsrep_after_statement (thd=0x7b76f8000d58) at /test/12.2_dbg/sql/wsrep_trans_observer.h:487
      #34 0x0000571fd71d109f in wsrep_mysql_parse (thd=0x7b76f8000d58, rawbuf=0x7b76f8015a10 "START TRANSACTION /* QNO 207 CON_ID 29 */", length=41, parser_state=0x7b7ed85fe2a0)
          at /test/12.2_dbg/sql/sql_parse.cc:7726
      #35 0x0000571fd71be36e in dispatch_command (command=COM_QUERY, thd=0x7b76f8000d58, packet=0x7b76f800b2e9 "START TRANSACTION /* QNO 207 CON_ID 29 */ ", packet_length=42, blocking=true)
          at /test/12.2_dbg/sql/sql_parse.cc:1865
      #36 0x0000571fd71bd035 in do_command (thd=0x7b76f8000d58, blocking=true) at /test/12.2_dbg/sql/sql_parse.cc:1417
      #37 0x0000571fd73b03a5 in do_handle_one_connection (connect=0x571ff7d4c7a8, put_in_cache=true) at /test/12.2_dbg/sql/sql_connect.cc:1503
      #38 0x0000571fd73b0150 in handle_one_connection (arg=0x571ff7d4c7a8) at /test/12.2_dbg/sql/sql_connect.cc:1415
      #39 0x00007b8a6449caa4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447
      #40 0x00007b8a64529c3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      (gdb)
      

      Release build stack is different

      CS 12.2.0 49c3c2ab3642dbbabc8cba71210ad3c468dd8540 (Optimized) Build 21/10/2025

      Core was generated by `/test/GAL_MD211025-mariadb-12.2.0-linux-x86_64-opt/bin/mariadbd --defaults-file'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 658351)]
      (gdb) bt
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
      #1  __pthread_kill_internal (signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:78
      #2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)at ./nptl/pthread_kill.c:89
      #3  0x00007d41a804527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x00007d41a80288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x00007d41a84bd48a in __gnu_cxx::__verbose_terminate_handler() ()
         from /lib/x86_64-linux-gnu/libstdc++.so.6
      #6  0x00007d41a84bb0da in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
      #7  0x00007d41a84a5a55 in std::terminate() ()
         from /lib/x86_64-linux-gnu/libstdc++.so.6
      #8  0x00007d41a84bb391 in __cxa_throw ()
         from /lib/x86_64-linux-gnu/libstdc++.so.6
      #9  0x00005d4cc1413377 in wsrep::server_state::provider (this=<optimized out>)at /test/12.2_opt/wsrep-lib/include/wsrep/server_state.hpp:329
      #10 wsrep::client_state::provider (this=this@entry=0x7d31c4007338)at /test/12.2_opt/wsrep-lib/src/client_state.cpp:39
      #11 0x00005d4cc1f6d073 in wsrep::transaction::bf_abort (this=0x7d31c40073a0, lock=@0x7ffc80471150: {_M_device = 0x7ffc80471140, _M_owns = true}, bf_seqno={seqno_ = 6059}, victim_ctx=@0x7d31c4007320: {_vptr.client_service = 0x5d4cc27ef4c0 <vtable for Wsrep_client_service+16>})at /test/12.2_opt/wsrep-lib/src/transaction.cpp:1028
      #12 0x00005d4cc1f4e3e5 in wsrep::client_state::bf_abort (this=<optimized out>, lock=<optimized out>, bf_seqno=<optimized out>)at /test/12.2_opt/wsrep-lib/src/client_state.cpp:514
      #13 0x00005d4cc1ac43f5 in wsrep_bf_abort_low (bf_thd=0x7d31c4000c68, victim_thd=0x7d31c4000c68) at /test/12.2_opt/sql/wsrep_thd.cc:340
      #14 0x00005d4cc1ac44c3 in wsrep_abort_thd (bf_thd=bf_thd@entry=0x7d31c4000c68, victim_thd=victim_thd@entry=0x7d31c4000c68, signal=signal@entry=1 '\001')at /test/12.2_opt/sql/wsrep_thd.cc:375
      #15 0x00005d4cc1aaed54 in abort_replicated (thd=0x7d31c4000c68)at /test/12.2_opt/sql/wsrep_mysqld.cc:3434
      #16 kill_all_threads (caller_thd=<optimized out>, thd=0x7d31c4000c68)at /test/12.2_opt/sql/wsrep_mysqld.cc:3528
      #17 kill_all_threads (caller_thd=<optimized out>, thd=0x7d31c4000c68)at /test/12.2_opt/sql/wsrep_mysqld.cc:3505
      #18 THD_list_iterator::iterate<THD> (this=<optimized out>, action=<optimized out>, arg=0x0) at /test/12.2_opt/sql/sql_class.h:1207
      #19 wsrep_close_client_connections (wait_to_end=1 '\001', except_caller_thd=0x0) at /test/12.2_opt/sql/wsrep_mysqld.cc:3566
      #20 0x00005d4cc1aaf0d8 in wsrep_stop_replication_common (thd=0x0)at /test/12.2_opt/sql/wsrep_mysqld.cc:1152
      #21 0x00005d4cc1aaf1c4 in wsrep_shutdown_replication ()at /test/12.2_opt/sql/wsrep_mysqld.cc:1169
      #22 0x00005d4cc14650fd in mysqld_main (argc=<optimized out>, argv=<optimized out>) at /test/12.2_opt/sql/mysqld.cc:6187
      #23 0x00007d41a802a1ca in __libc_start_call_main (main=main@entry=0x5d4cc141f4c0 <main(int, char**)>, argc=argc@entry=3, argv=argv@entry=0x7ffc804718f8)at ../sysdeps/nptl/libc_start_call_main.h:58
      #24 0x00007d41a802a28b in __libc_start_main_impl (main=0x5d4cc141f4c0 <main(int, char**)>, argc=3, argv=0x7ffc804718f8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffc804718e8) at ../csu/libc-start.c:360
      #25 0x00005d4cc1459c15 in _start ()
      

      Attachments

        1. MDEV-34124-seq.yy
          8 kB
        2. MDEV-34124-seq.zz
          1 kB
        3. n1.cnf
          1.0 kB
        4. n2.cnf
          1.0 kB

        Activity

          People

            janlindstrom Jan Lindström
            ramesh Ramesh Sivaraman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: