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

Assertion `!trx->read_only' failed in trx_undo_report_row_operation on CREATE TABLE

Details

    Description

      Different from MDEV-24812, and possibly related to MDEV-24859, we have:

      SET GLOBAL innodb_limit_optimistic_insert_debug=2;
      SET GLOBAL tx_read_only=1;
      CREATE TABLE t (c1 INT(1),c2 CHAR(1), KEY A (c1,c2 (1))) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
      SET GLOBAL innodb_defragment_stats_accuracy=10;
      CREATE TABLE t2 (a INT,b INT,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e));
      

      Leads to:

      10.8.0 ccdf5711a8fff0cd610a91fdcf37c8ff1182878c (Debug)

      mysqld: /test/10.8_dbg/storage/innobase/trx/trx0rec.cc:2081: dberr_t trx_undo_report_row_operation(que_thr_t*, dict_index_t*, const dtuple_t*, const upd_t*, ulint, const rec_t*, const rec_offs*, roll_ptr_t*): Assertion `!trx->read_only' failed.
      

      10.8.0 ccdf5711a8fff0cd610a91fdcf37c8ff1182878c (Debug)

      Core was generated by `/test/MD121221-mariadb-10.8.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      [Current thread is 1 (Thread 0x14c56a0f8700 (LWP 4072538))]
      (gdb) bt
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x000014c5a09b8859 in __GI_abort () at abort.c:79
      #2  0x000014c5a09b8729 in __assert_fail_base (fmt=0x14c5a0b4e588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55fa9148a90b "!trx->read_only", file=0x55fa9148ab80 "/test/10.8_dbg/storage/innobase/trx/trx0rec.cc", line=2081, function=<optimized out>) at assert.c:92
      #3  0x000014c5a09c9f36 in __GI___assert_fail (assertion=assertion@entry=0x55fa9148a90b "!trx->read_only", file=file@entry=0x55fa9148ab80 "/test/10.8_dbg/storage/innobase/trx/trx0rec.cc", line=line@entry=2081, function=function@entry=0x55fa9148b770 "dberr_t trx_undo_report_row_operation(que_thr_t*, dict_index_t*, const dtuple_t*, const upd_t*, ulint, const rec_t*, const rec_offs*, roll_ptr_t*)") at assert.c:101
      #4  0x000055fa90de9c0b in trx_undo_report_row_operation (thr=thr@entry=0x14c4fc012e88, index=index@entry=0x14c53800c0e8, clust_entry=clust_entry@entry=0x14c4fc0151c8, update=update@entry=0x0, cmpl_info=cmpl_info@entry=0, rec=rec@entry=0x0, offsets=0x0, roll_ptr=0x14c56a0f6030) at /test/10.8_dbg/storage/innobase/trx/trx0rec.cc:2081
      #5  0x000055fa90e44b14 in btr_cur_ins_lock_and_undo (flags=flags@entry=0, cursor=cursor@entry=0x14c56a0f61c0, entry=entry@entry=0x14c4fc0151c8, thr=thr@entry=0x14c4fc012e88, mtr=mtr@entry=0x14c56a0f6770, inherit=inherit@entry=0x14c56a0f60cb) at /test/10.8_dbg/storage/innobase/btr/btr0cur.cc:3288
      #6  0x000055fa90e4889e in btr_cur_pessimistic_insert (flags=flags@entry=0, cursor=cursor@entry=0x14c56a0f61c0, offsets=offsets@entry=0x14c56a0f6188, heap=heap@entry=0x14c56a0f6180, entry=entry@entry=0x14c4fc0151c8, rec=rec@entry=0x14c56a0f6198, big_rec=0x14c56a0f6178, n_ext=<optimized out>, thr=0x14c4fc012e88, mtr=0x14c56a0f6770) at /test/10.8_dbg/storage/innobase/btr/btr0cur.cc:3704
      #7  0x000055fa90d2e295 in row_ins_clust_index_entry_low (flags=flags@entry=0, mode=<optimized out>, mode@entry=33, index=index@entry=0x14c53800c0e8, n_uniq=n_uniq@entry=4, entry=entry@entry=0x14c4fc0151c8, n_ext=n_ext@entry=0, thr=<optimized out>) at /test/10.8_dbg/storage/innobase/row/row0ins.cc:2794
      #8  0x000055fa90d2f071 in row_ins_clust_index_entry (index=index@entry=0x14c53800c0e8, entry=entry@entry=0x14c4fc0151c8, thr=thr@entry=0x14c4fc012e88, n_ext=n_ext@entry=0) at /test/10.8_dbg/storage/innobase/row/row0ins.cc:3263
      #9  0x000055fa90d33d2d in row_ins_index_entry (thr=0x14c4fc012e88, entry=0x14c4fc0151c8, index=0x14c53800c0e8) at /test/10.8_dbg/storage/innobase/row/row0ins.cc:3380
      #10 row_ins_index_entry_step (thr=0x14c4fc012e88, node=0x14c4fc012bd0) at /test/10.8_dbg/storage/innobase/row/row0ins.cc:3548
      #11 row_ins (thr=0x14c4fc012e88, node=0x14c4fc012bd0) at /test/10.8_dbg/storage/innobase/row/row0ins.cc:3694
      #12 row_ins_step (thr=thr@entry=0x14c4fc012e88) at /test/10.8_dbg/storage/innobase/row/row0ins.cc:3840
      #13 0x000055fa90ce8e95 in que_thr_step (thr=0x14c4fc012e88) at /test/10.8_dbg/storage/innobase/que/que0que.cc:632
      #14 que_run_threads_low (thr=0x14c4fc012e88) at /test/10.8_dbg/storage/innobase/que/que0que.cc:709
      #15 que_run_threads (thr=0x14c4fc012e88) at /test/10.8_dbg/storage/innobase/que/que0que.cc:729
      #16 0x000055fa90ce95a8 in que_eval_sql (info=info@entry=0x14c4fc010828, sql=sql@entry=0x55fa914aa220 "PROCEDURE INDEX_STATS_SAVE () IS\nBEGIN\nDELETE FROM \"mysql/innodb_index_stats\"\nWHERE\ndatabase_name = :database_name AND\ntable_name = :table_name AND\nindex_name = :index_name AND\nstat_name = :stat_name;"..., trx=trx@entry=0x14c58bd95390) at /test/10.8_dbg/storage/innobase/que/que0que.cc:768
      #17 0x000055fa90f0bd3c in dict_stats_exec_sql (pinfo=pinfo@entry=0x14c4fc010828, sql=sql@entry=0x55fa914aa220 "PROCEDURE INDEX_STATS_SAVE () IS\nBEGIN\nDELETE FROM \"mysql/innodb_index_stats\"\nWHERE\ndatabase_name = :database_name AND\ntable_name = :table_name AND\nindex_name = :index_name AND\nstat_name = :stat_name;"..., trx=trx@entry=0x14c58bd95390) at /test/10.8_dbg/storage/innobase/dict/dict0stats.cc:532
      #18 0x000055fa90f0c396 in dict_stats_save_index_stat (index=index@entry=0x14c53800c0e8, last_update=last_update@entry=1641902500, stat_name=<optimized out>, stat_name@entry=0x55fa914a957a "n_page_split", stat_value=10, sample_size=sample_size@entry=0x0, stat_description=stat_description@entry=0x55fa914abf68 "Number of new page splits on leaves since last defragmentation.", trx=0x14c58bd95390) at /test/10.8_dbg/storage/innobase/dict/dict0stats.cc:2968
      #19 0x000055fa90f17a7b in dict_stats_save_defrag_stats (index=0x14c53800c0e8) at /test/10.8_dbg/storage/innobase/dict/dict0defrag_bg.cc:398
      #20 0x000055fa90f18133 in dict_stats_process_entry_from_defrag_pool (thd=0x14c4fc004538) at /test/10.8_dbg/storage/innobase/dict/dict0defrag_bg.cc:198
      #21 dict_defrag_process_entries_from_defrag_pool (thd=thd@entry=0x14c4fc004538) at /test/10.8_dbg/storage/innobase/dict/dict0defrag_bg.cc:209
      #22 0x000055fa90f15e53 in dict_stats_func () at /test/10.8_dbg/storage/innobase/dict/dict0stats_bg.cc:382
      #23 0x000055fa90fb9966 in tpool::thread_pool_generic::timer_generic::run (this=0x55fa93b0e970) at /test/10.8_dbg/tpool/tpool_generic.cc:313
      #24 tpool::thread_pool_generic::timer_generic::execute (arg=0x55fa93b0e970) at /test/10.8_dbg/tpool/tpool_generic.cc:332
      #25 0x000055fa90fba7f9 in tpool::task::execute (this=0x55fa93b0e9b0) at /test/10.8_dbg/tpool/task.cc:37
      #26 0x000055fa90fb9481 in tpool::thread_pool_generic::worker_main (this=0x55fa93785220, thread_var=0x55fa937942c0) at /test/10.8_dbg/tpool/tpool_generic.cc:549
      #27 0x000055fa90fb97b8 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
      #28 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
      #29 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
      #30 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
      #31 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
      #32 0x000014c5a0dacde4 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
      #33 0x000014c5a0ec7609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #34 0x000014c5a0ab5293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.6.6 (dbg), 10.7.2 (dbg), 10.8.0 (dbg)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.2.42 (dbg), 10.2.42 (opt), 10.3.33 (dbg), 10.3.33 (opt), 10.4.23 (dbg), 10.4.23 (opt), 10.5.14 (dbg), 10.5.14 (opt), 10.6.6 (opt), 10.7.2 (opt), 10.8.0 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

      Attachments

        Issue Links

          Activity

            I am unable to repeat any crash on mariadb-10.6.5 or the current 10.6 or 10.8. Can you please provide an mtr test case? I tried the following (adding explicit ENGINE=InnoDB because it is not implied by default):

            --source include/have_innodb.inc
            SET GLOBAL innodb_limit_optimistic_insert_debug=2;
            SET GLOBAL tx_read_only=1;
            CREATE TABLE t (c1 INT(1),c2 CHAR(1), KEY A (c1,c2 (1))) ENGINE=InnoDB;
            SET GLOBAL innodb_defragment_stats_accuracy=10;
            CREATE TABLE t2 (a INT,b INT,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ENGINE=InnoDB;
            

            marko Marko Mäkelä added a comment - I am unable to repeat any crash on mariadb-10.6.5 or the current 10.6 or 10.8. Can you please provide an mtr test case? I tried the following (adding explicit ENGINE=InnoDB because it is not implied by default): --source include/have_innodb.inc SET GLOBAL innodb_limit_optimistic_insert_debug=2; SET GLOBAL tx_read_only=1; CREATE TABLE t (c1 INT (1),c2 CHAR (1), KEY A (c1,c2 (1))) ENGINE=InnoDB; SET GLOBAL innodb_defragment_stats_accuracy=10; CREATE TABLE t2 (a INT ,b INT ,c CHAR (1),d CHAR (1),e VARCHAR (1),f VARCHAR (1),g BLOB,h BLOB,id INT , KEY (b), KEY (e)) ENGINE=InnoDB;
            Roel Roel Van de Paar added a comment - - edited

            The issue readily reproduces at the CLI using a 10.8 debug build from today.

            10.8.0 347f6d01e3b570dce49aa1ab42cb83021905a14d (Debug)

            10.8.0-dbg>SET GLOBAL innodb_limit_optimistic_insert_debug=2;
            Query OK, 0 rows affected (0.000 sec)
             
            10.8.0-dbg>SET GLOBAL tx_read_only=1;
            Query OK, 0 rows affected (0.000 sec)
             
            10.8.0-dbg>CREATE TABLE t (c1 INT(1),c2 CHAR(1), KEY A (c1,c2 (1))) ENGINE=InnoDB DEFAULT CHARSET=latin1;
            Query OK, 0 rows affected (0.037 sec)
             
            10.8.0-dbg>SET GLOBAL innodb_defragment_stats_accuracy=10;
            Query OK, 0 rows affected (0.000 sec)
             
            10.8.0-dbg>CREATE TABLE t2 (a INT,b INT,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e));
            ERROR 2013 (HY000): Lost connection to server during query
            

            CLI commands if it matters/helps

            /test/MD150122-mariadb-10.8.0-linux-x86_64-dbg/bin/mysql -A -uroot -S/test/MD150122-mariadb-10.8.0-linux-x86_64-dbg/socket.sock --force --binary-mode test
            

            Roel Roel Van de Paar added a comment - - edited The issue readily reproduces at the CLI using a 10.8 debug build from today. 10.8.0 347f6d01e3b570dce49aa1ab42cb83021905a14d (Debug) 10.8.0-dbg>SET GLOBAL innodb_limit_optimistic_insert_debug=2; Query OK, 0 rows affected (0.000 sec)   10.8.0-dbg>SET GLOBAL tx_read_only=1; Query OK, 0 rows affected (0.000 sec)   10.8.0-dbg>CREATE TABLE t (c1 INT(1),c2 CHAR(1), KEY A (c1,c2 (1))) ENGINE=InnoDB DEFAULT CHARSET=latin1; Query OK, 0 rows affected (0.037 sec)   10.8.0-dbg>SET GLOBAL innodb_defragment_stats_accuracy=10; Query OK, 0 rows affected (0.000 sec)   10.8.0-dbg>CREATE TABLE t2 (a INT,b INT,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)); ERROR 2013 (HY000): Lost connection to server during query CLI commands if it matters/helps /test/MD150122-mariadb-10.8.0-linux-x86_64-dbg/bin/mysql -A -uroot -S/test/MD150122-mariadb-10.8.0-linux-x86_64-dbg/socket.sock --force --binary-mode test

            Roel, I can say for sure that the statements cannot possibly crash with the default settings of the server, because the CREATE TABLE statement for t2 is missing ENGINE=InnoDB.

            I was finally able to reproduce a crash with the command line client, with the following. Note: --no-defaults should prevent any dependency on any configuration files:

            cd mysql-test
            ./mtr main.1st
            mkdir rr
            _RR_TRACE_DIR=rr rr record ../sql/mariadbd --no-defaults --gdb --datadir $(pwd)/var/install.db/ --socket /dev/shm/mariadb.sock
            

            Then, in a different shell:

            ../client/mysql --no-defaults -uroot test --binary-mode --socket /dev/shm/mariadb.sock
            

            and input the statements from the description:

            SET GLOBAL innodb_limit_optimistic_insert_debug=2;
            SET GLOBAL tx_read_only=1;
            CREATE TABLE t (c1 INT(1),c2 CHAR(1), KEY A (c1,c2 (1))) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
            SET GLOBAL innodb_defragment_stats_accuracy=10;
            CREATE TABLE t2 (a INT,b INT,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e));
            DROP TABLE t2;
            # wait a few seconds
            CREATE TABLE t2 (a INT,b INT,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ENGINE=InnoDB;
            

            This is 2 statements more than in the Description.
            Timing is probably significant here, because executing the same statements in mtr does not reproduce anything.

            Based on an analysis of the trace, I tried a simpler test case, but unfortunately it did not reproduce a crash.

            --source include/have_innodb.inc
            SET GLOBAL tx_read_only=1;
            SET GLOBAL innodb_defragment_stats_accuracy=10;
            CREATE TABLE t1(c1 INT(1),c2 CHAR(1), KEY A (c1,c2 (1))) ENGINE=InnoDB;
            SELECT SLEEP(5);
            CREATE TABLE t2 (b INT,e VARCHAR(1),KEY(b),KEY(e)) ENGINE=InnoDB;
            SELECT SLEEP(5);
            DROP TABLE t1,t2;
            

            The problem is in dict_defrag_process_entries_from_defrag_pool(): It should refrain from updating any statistics when SET GLOBAL tx_read_only is in effect.

            marko Marko Mäkelä added a comment - Roel , I can say for sure that the statements cannot possibly crash with the default settings of the server, because the CREATE TABLE statement for t2 is missing ENGINE=InnoDB . I was finally able to reproduce a crash with the command line client, with the following. Note: --no-defaults should prevent any dependency on any configuration files: cd mysql-test ./mtr main.1st mkdir rr _RR_TRACE_DIR=rr rr record ../sql/mariadbd --no-defaults --gdb --datadir $(pwd)/var/install.db/ --socket /dev/shm/mariadb.sock Then, in a different shell: ../client/mysql --no-defaults -uroot test --binary-mode --socket /dev/shm/mariadb.sock and input the statements from the description: SET GLOBAL innodb_limit_optimistic_insert_debug=2; SET GLOBAL tx_read_only=1; CREATE TABLE t (c1 INT (1),c2 CHAR (1), KEY A (c1,c2 (1))) ENGINE=InnoDB DEFAULT CHARSET=latin1; SET GLOBAL innodb_defragment_stats_accuracy=10; CREATE TABLE t2 (a INT ,b INT ,c CHAR (1),d CHAR (1),e VARCHAR (1),f VARCHAR (1),g BLOB,h BLOB,id INT , KEY (b), KEY (e)); DROP TABLE t2; # wait a few seconds CREATE TABLE t2 (a INT ,b INT ,c CHAR (1),d CHAR (1),e VARCHAR (1),f VARCHAR (1),g BLOB,h BLOB,id INT , KEY (b), KEY (e)) ENGINE=InnoDB; This is 2 statements more than in the Description. Timing is probably significant here, because executing the same statements in mtr does not reproduce anything. Based on an analysis of the trace, I tried a simpler test case, but unfortunately it did not reproduce a crash. --source include/have_innodb.inc SET GLOBAL tx_read_only=1; SET GLOBAL innodb_defragment_stats_accuracy=10; CREATE TABLE t1(c1 INT (1),c2 CHAR (1), KEY A (c1,c2 (1))) ENGINE=InnoDB; SELECT SLEEP(5); CREATE TABLE t2 (b INT ,e VARCHAR (1), KEY (b), KEY (e)) ENGINE=InnoDB; SELECT SLEEP(5); DROP TABLE t1,t2; The problem is in dict_defrag_process_entries_from_defrag_pool() : It should refrain from updating any statistics when SET GLOBAL tx_read_only is in effect.

            I was unable to create an mtr test case for this, but I am able to repeat this when running the client manually. Also innodb_limit_optimistic_insert_debug=2 is important here, because it will cause something to be added to the defrag_pool:

            10.6 16b87f9890145ff344bfd8cd751e6356a5a8139b

            #2  dict_stats_defrag_pool_add (index=0x7f3f98004958)
                at /mariadb/10.6/storage/innobase/dict/dict0defrag_bg.cc:132
            #3  0x0000561a7e31d511 in btr_defragment_save_defrag_stats_if_needed (
                index=0x7f3f98004958)
                at /mariadb/10.6/storage/innobase/btr/btr0defragment.cc:231
            #4  0x0000561a7e2c8e06 in btr_page_split_and_insert (flags=flags@entry=0, 
                cursor=cursor@entry=0x7f3fc40f1660, 
                offsets=offsets@entry=0x7f3fc40f1650, heap=heap@entry=0x7f3fc40f1648, 
                tuple=tuple@entry=0x7f3f9c020e98, n_ext=0, mtr=0x7f3fc40f19b0)
                at /mariadb/10.6/storage/innobase/btr/btr0btr.cc:2791
            #5  0x0000561a7e2e7ede in btr_cur_pessimistic_insert (flags=flags@entry=0, 
                cursor=cursor@entry=0x7f3fc40f1660, 
                heap=heap@entry=0x7f3fc40f1648, entry=entry@entry=0x7f3f9c020e98, rec=rec@entry=0x7f3fc40f1658, big_rec=0x7f3fc40f1640, n_ext=<optimized out>, thr=0x7f3f9c089608, 
                mtr=0x7f3fc40f19b0) at /mariadb/10.6/storage/innobase/btr/btr0cur.cc:3762
            #6  0x0000561a7e1d84ce in row_ins_clust_index_entry_low (flags=flags@entry=0, mode=<optimized out>, mode@entry=33, index=index@entry=0x7f3f98004958, n_uniq=n_uniq@entry=4, entry=entry@entry=0x7f3f9c020e98, 
                n_ext=n_ext@entry=0, thr=<optimized out>) at /mariadb/10.6/storage/innobase/row/row0ins.cc:2779
            #7  0x0000561a7e1d8ade in row_ins_clust_index_entry (index=index@entry=0x7f3f98004958, entry=entry@entry=0x7f3f9c020e98, thr=thr@entry=0x7f3f9c089608, n_ext=n_ext@entry=0)
                at /mariadb/10.6/storage/innobase/row/row0ins.cc:3248
            #8  0x0000561a7e1dacb5 in row_ins_index_entry (index=0x7f3f98004958, entry=0x7f3f9c020e98, thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/row/row0ins.cc:3357
            #9  0x0000561a7e1dad69 in row_ins_index_entry_step (node=node@entry=0x7f3f9c089350, thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/row/row0ins.cc:3525
            #10 0x0000561a7e1daf44 in row_ins (node=node@entry=0x7f3f9c089350, thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/row/row0ins.cc:3671
            #11 0x0000561a7e1dbc14 in row_ins_step (thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/row/row0ins.cc:3817
            #12 0x0000561a7e1948f0 in que_thr_step (thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/que/que0que.cc:632
            #13 0x0000561a7e194f48 in que_run_threads_low (thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/que/que0que.cc:709
            #14 0x0000561a7e19500b in que_run_threads (thr=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/que/que0que.cc:729
            #15 0x0000561a7e195727 in que_eval_sql (info=info@entry=0x7f3f9c01efc8, 
                sql=sql@entry=0x561a7e80bd30 "PROCEDURE INDEX_STATS_SAVE () IS\nBEGIN\nDELETE FROM \"mysql/innodb_index_stats\"\nWHERE\ndatabase_name = :database_name AND\ntable_name = :table_name AND\nindex_name = :index_name AND\nstat_name = :stat_name;"..., trx=trx@entry=0x7f3fd0be5540) at /mariadb/10.6/storage/innobase/que/que0que.cc:768
            #16 0x0000561a7e397fd6 in dict_stats_exec_sql (pinfo=pinfo@entry=0x7f3f9c01efc8, 
                sql=sql@entry=0x561a7e80bd30 "PROCEDURE INDEX_STATS_SAVE () IS\nBEGIN\nDELETE FROM \"mysql/innodb_index_stats\"\nWHERE\ndatabase_name = :database_name AND\ntable_name = :table_name AND\nindex_name = :index_name AND\nstat_name = :stat_name;"..., trx=trx@entry=0x7f3fd0be5540) at /mariadb/10.6/storage/innobase/dict/dict0stats.cc:532
            #17 0x0000561a7e3985c9 in dict_stats_save_index_stat (index=index@entry=0x7f3f9c0858a8, last_update=last_update@entry=1642410239, stat_name=<optimized out>, stat_name@entry=0x561a7e80afc8 "n_leaf_pages", 
                stat_value=1, sample_size=sample_size@entry=0x0, stat_description=stat_description@entry=0x561a7e80c630 "Number of leaf pages in the index", trx=0x7f3fd0be5540)
                at /mariadb/10.6/storage/innobase/dict/dict0stats.cc:2968
            #18 0x0000561a7e39d11b in dict_stats_save (table_orig=table_orig@entry=0x7f3f9c040208, only_for_index=only_for_index@entry=0x0) at /mariadb/10.6/storage/innobase/dict/dict0stats.cc:3246
            #19 0x0000561a7e39f685 in dict_stats_update (table=table@entry=0x7f3f9c040208, stats_upd_option=stats_upd_option@entry=DICT_STATS_EMPTY_TABLE) at /mariadb/10.6/storage/innobase/dict/dict0stats.cc:3894
            #20 0x0000561a7e08f937 in create_table_info_t::create_table_update_dict (this=this@entry=0x7f3fc40f2d60) at /mariadb/10.6/storage/innobase/handler/ha_innodb.cc:13074
            #21 0x0000561a7e09f191 in ha_innobase::create (this=<optimized out>, name=<optimized out>, form=<optimized out>, create_info=<optimized out>, file_per_table=<optimized out>, trx=0x7f3fd0be4390, trx@entry=0x0)
                at /mariadb/10.6/storage/innobase/handler/ha_innodb.cc:13222
            #22 0x0000561a7e0949cd in ha_innobase::create (this=<optimized out>, name=<optimized out>, form=<optimized out>, create_info=<optimized out>) at /mariadb/10.6/storage/innobase/handler/ha_innodb.cc:13246
            #23 0x0000561a7dcc064a in handler::ha_create (this=0x7f3f9c0819f0, name=0x7f3fc40f4760 "./test/t2", form=form@entry=0x7f3fc40f3310, info_arg=info_arg@entry=0x7f3fc40f4c50) at /mariadb/10.6/sql/handler.cc:5422
            

            I got an rr replay trace where the server executed my fix, that is, dict_stats_save_defrag_stats() would return DB_READ_ONLY.

            In MDEV-25919, a similar change (return DB_READ_ONLY if trx->read_only is set) was made to dict_stats_save(), but not to dict_stats_save_defrag_stats().

            marko Marko Mäkelä added a comment - I was unable to create an mtr test case for this, but I am able to repeat this when running the client manually. Also innodb_limit_optimistic_insert_debug=2 is important here, because it will cause something to be added to the defrag_pool : 10.6 16b87f9890145ff344bfd8cd751e6356a5a8139b #2 dict_stats_defrag_pool_add (index=0x7f3f98004958) at /mariadb/10.6/storage/innobase/dict/dict0defrag_bg.cc:132 #3 0x0000561a7e31d511 in btr_defragment_save_defrag_stats_if_needed ( index=0x7f3f98004958) at /mariadb/10.6/storage/innobase/btr/btr0defragment.cc:231 #4 0x0000561a7e2c8e06 in btr_page_split_and_insert (flags=flags@entry=0, cursor=cursor@entry=0x7f3fc40f1660, offsets=offsets@entry=0x7f3fc40f1650, heap=heap@entry=0x7f3fc40f1648, tuple=tuple@entry=0x7f3f9c020e98, n_ext=0, mtr=0x7f3fc40f19b0) at /mariadb/10.6/storage/innobase/btr/btr0btr.cc:2791 #5 0x0000561a7e2e7ede in btr_cur_pessimistic_insert (flags=flags@entry=0, cursor=cursor@entry=0x7f3fc40f1660, heap=heap@entry=0x7f3fc40f1648, entry=entry@entry=0x7f3f9c020e98, rec=rec@entry=0x7f3fc40f1658, big_rec=0x7f3fc40f1640, n_ext=<optimized out>, thr=0x7f3f9c089608, mtr=0x7f3fc40f19b0) at /mariadb/10.6/storage/innobase/btr/btr0cur.cc:3762 #6 0x0000561a7e1d84ce in row_ins_clust_index_entry_low (flags=flags@entry=0, mode=<optimized out>, mode@entry=33, index=index@entry=0x7f3f98004958, n_uniq=n_uniq@entry=4, entry=entry@entry=0x7f3f9c020e98, n_ext=n_ext@entry=0, thr=<optimized out>) at /mariadb/10.6/storage/innobase/row/row0ins.cc:2779 #7 0x0000561a7e1d8ade in row_ins_clust_index_entry (index=index@entry=0x7f3f98004958, entry=entry@entry=0x7f3f9c020e98, thr=thr@entry=0x7f3f9c089608, n_ext=n_ext@entry=0) at /mariadb/10.6/storage/innobase/row/row0ins.cc:3248 #8 0x0000561a7e1dacb5 in row_ins_index_entry (index=0x7f3f98004958, entry=0x7f3f9c020e98, thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/row/row0ins.cc:3357 #9 0x0000561a7e1dad69 in row_ins_index_entry_step (node=node@entry=0x7f3f9c089350, thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/row/row0ins.cc:3525 #10 0x0000561a7e1daf44 in row_ins (node=node@entry=0x7f3f9c089350, thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/row/row0ins.cc:3671 #11 0x0000561a7e1dbc14 in row_ins_step (thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/row/row0ins.cc:3817 #12 0x0000561a7e1948f0 in que_thr_step (thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/que/que0que.cc:632 #13 0x0000561a7e194f48 in que_run_threads_low (thr=thr@entry=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/que/que0que.cc:709 #14 0x0000561a7e19500b in que_run_threads (thr=0x7f3f9c089608) at /mariadb/10.6/storage/innobase/que/que0que.cc:729 #15 0x0000561a7e195727 in que_eval_sql (info=info@entry=0x7f3f9c01efc8, sql=sql@entry=0x561a7e80bd30 "PROCEDURE INDEX_STATS_SAVE () IS\nBEGIN\nDELETE FROM \"mysql/innodb_index_stats\"\nWHERE\ndatabase_name = :database_name AND\ntable_name = :table_name AND\nindex_name = :index_name AND\nstat_name = :stat_name;"..., trx=trx@entry=0x7f3fd0be5540) at /mariadb/10.6/storage/innobase/que/que0que.cc:768 #16 0x0000561a7e397fd6 in dict_stats_exec_sql (pinfo=pinfo@entry=0x7f3f9c01efc8, sql=sql@entry=0x561a7e80bd30 "PROCEDURE INDEX_STATS_SAVE () IS\nBEGIN\nDELETE FROM \"mysql/innodb_index_stats\"\nWHERE\ndatabase_name = :database_name AND\ntable_name = :table_name AND\nindex_name = :index_name AND\nstat_name = :stat_name;"..., trx=trx@entry=0x7f3fd0be5540) at /mariadb/10.6/storage/innobase/dict/dict0stats.cc:532 #17 0x0000561a7e3985c9 in dict_stats_save_index_stat (index=index@entry=0x7f3f9c0858a8, last_update=last_update@entry=1642410239, stat_name=<optimized out>, stat_name@entry=0x561a7e80afc8 "n_leaf_pages", stat_value=1, sample_size=sample_size@entry=0x0, stat_description=stat_description@entry=0x561a7e80c630 "Number of leaf pages in the index", trx=0x7f3fd0be5540) at /mariadb/10.6/storage/innobase/dict/dict0stats.cc:2968 #18 0x0000561a7e39d11b in dict_stats_save (table_orig=table_orig@entry=0x7f3f9c040208, only_for_index=only_for_index@entry=0x0) at /mariadb/10.6/storage/innobase/dict/dict0stats.cc:3246 #19 0x0000561a7e39f685 in dict_stats_update (table=table@entry=0x7f3f9c040208, stats_upd_option=stats_upd_option@entry=DICT_STATS_EMPTY_TABLE) at /mariadb/10.6/storage/innobase/dict/dict0stats.cc:3894 #20 0x0000561a7e08f937 in create_table_info_t::create_table_update_dict (this=this@entry=0x7f3fc40f2d60) at /mariadb/10.6/storage/innobase/handler/ha_innodb.cc:13074 #21 0x0000561a7e09f191 in ha_innobase::create (this=<optimized out>, name=<optimized out>, form=<optimized out>, create_info=<optimized out>, file_per_table=<optimized out>, trx=0x7f3fd0be4390, trx@entry=0x0) at /mariadb/10.6/storage/innobase/handler/ha_innodb.cc:13222 #22 0x0000561a7e0949cd in ha_innobase::create (this=<optimized out>, name=<optimized out>, form=<optimized out>, create_info=<optimized out>) at /mariadb/10.6/storage/innobase/handler/ha_innodb.cc:13246 #23 0x0000561a7dcc064a in handler::ha_create (this=0x7f3f9c0819f0, name=0x7f3fc40f4760 "./test/t2", form=form@entry=0x7f3fc40f3310, info_arg=info_arg@entry=0x7f3fc40f4c50) at /mariadb/10.6/sql/handler.cc:5422 I got an rr replay trace where the server executed my fix, that is, dict_stats_save_defrag_stats() would return DB_READ_ONLY . In MDEV-25919 , a similar change (return DB_READ_ONLY if trx->read_only is set) was made to dict_stats_save() , but not to dict_stats_save_defrag_stats() .
            Roel Roel Van de Paar added a comment - - edited

            "The default setting of the server" is InnoDB when the CLI is used (not so for MTR). IOW, ENGINE=InnoDB is not required for the CREATE TABLE t2 when the CLI is used. The DROP TABLE is also not required. Timing could be an issue, but it always reproduced non-sporadically for me. The original testcase crashes with 100% default settings on a tarball build, using the CLI and --no-defaults. I note that you changed the testcase to use two times t2 whereas the original uses t then t2.

            Roel Roel Van de Paar added a comment - - edited "The default setting of the server" is InnoDB when the CLI is used (not so for MTR). IOW, ENGINE=InnoDB is not required for the CREATE TABLE t2 when the CLI is used. The DROP TABLE is also not required. Timing could be an issue, but it always reproduced non-sporadically for me. The original testcase crashes with 100% default settings on a tarball build, using the CLI and --no-defaults . I note that you changed the testcase to use two times t2 whereas the original uses t then t2 .

            I rechecked the rr replay trace that I made, and indeed, I see that init_common_variables() did set default_storage_engine to be InnoDB by default.

            Based on this, the trick to reproduce the bug in my environment seems to have been to wait long enough before CREATE TABLE t2, or to drop the table and try creating it again.

            marko Marko Mäkelä added a comment - I rechecked the rr replay trace that I made, and indeed, I see that init_common_variables() did set default_storage_engine to be InnoDB by default. Based on this, the trick to reproduce the bug in my environment seems to have been to wait long enough before CREATE TABLE t2 , or to drop the table and try creating it again.

            People

              marko Marko Mäkelä
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.