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

Assertion failure in Stat_table::update_stat with stat table corrupt by USE_FRM

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Trivial
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.0(EOL)
    • 10.11, 11.4, 11.8
    • Server
    • None

    Description

      This is very much a case of "garbage in, garbage out" and a meaningless use case. As explained in MDEV-29103, USE_FRM destroys encrypted tables more or less "by design", and it shouldn't be used except for very special cases, much less on a system table.
      So, it's not surprising that statistics collection which attempts to write into the table fails after that.
      But it fails sometimes in random tests, so I need to have it filed for the tests to ignore it legitimately.

      The described assertion failure happens on 10.11+. 10.6 fails already on REPAIR with MDEV-36753 which was only fixed in 10.11+.

      --source suite/encryption/include/have_file_key_management_plugin.inc
      --source include/have_innodb.inc
       
      SET @aria_encrypt= @@aria_encrypt_tables;
      SET GLOBAL aria_encrypt_tables= ON;
       
      CREATE TABLE t (a INT PRIMARY KEY) ENGINE=InnoDB;
      ANALYZE TABLE t;
      REPAIR TABLE mysql.index_stats QUICK USE_FRM;
      ANALYZE TABLE t;
       
      DROP TABLE t;
      SET GLOBAL aria_encrypt_tables= @aria_encrypt;
      

      10.11 2147951560c013fc084c4c06dcf8e09ec403dd9f

      2025-07-28 20:40:17 4 [ERROR] mariadbd: failed to decrypt './mysql/index_stats'  rc: -1  dstlen: 0  size: 8172
      2025-07-28 20:40:17 4 [ERROR] mariadbd: failed to decrypt './mysql/index_stats'  rc: -1  dstlen: 0  size: 8172
      2025-07-28 20:40:17 4 [ERROR] mariadbd: Got error '192 "Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryptio"' for './mysql/index_stats.MAI'
      mariadbd: /data/bld/10.11-asan-ubsan/sql/sql_statistics.cc:719: bool Stat_table::update_stat(): Assertion `0' failed.
      250728 20:40:17 [ERROR] /share8t/bld/10.11-asan-ubsan/sql/mariadbd got signal 6 ;
       
      #10 0x00007f978f453eb2 in __GI___assert_fail (assertion=0x55d6a8ad2660 "0", file=0x55d6a8ad2900 "/data/bld/10.11-asan-ubsan/sql/sql_statistics.cc", line=719, function=0x55d6a8ad3be0 "bool Stat_table::update_stat()") at ./assert/assert.c:101
      #11 0x000055d6a559d599 in Stat_table::update_stat (this=this@entry=0x7f977eec9ff0) at /data/bld/10.11-asan-ubsan/sql/sql_statistics.cc:719
      #12 0x000055d6a558e1b5 in update_statistics_for_table (thd=thd@entry=0x62c0001f0218, table=table@entry=0x6190000bdb98) at /data/bld/10.11-asan-ubsan/sql/sql_statistics.cc:2976
      #13 0x000055d6a59b6db6 in mysql_admin_table (thd=thd@entry=0x62c0001f0218, tables=tables@entry=0x62d0000a0520, check_opt=check_opt@entry=0x62c0001f5a08, operator_name=operator_name@entry=0x55d6a9884760 <msg_analyze>, lock_type=lock_type@entry=TL_READ_NO_INSERT, org_open_for_modify=org_open_for_modify@entry=true, repair_table_use_frm=<optimized out>, extra_open_options=<optimized out>, prepare_func=<optimized out>, operator_func=<optimized out>, view_operator_func=<optimized out>, is_cmd_replicated=<optimized out>) at /data/bld/10.11-asan-ubsan/sql/sql_admin.cc:1075
      #14 0x000055d6a59bf2a1 in Sql_cmd_analyze_table::execute (this=<optimized out>, thd=0x62c0001f0218) at /data/bld/10.11-asan-ubsan/sql/sql_admin.cc:1570
      #15 0x000055d6a513c5fc in mysql_execute_command (thd=thd@entry=0x62c0001f0218, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /data/bld/10.11-asan-ubsan/sql/sql_parse.cc:6163
      #16 0x000055d6a5140e4d in mysql_parse (thd=thd@entry=0x62c0001f0218, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7f977eecfab0) at /data/bld/10.11-asan-ubsan/sql/sql_parse.cc:8178
      #17 0x000055d6a514a121 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x62c0001f0218, packet=packet@entry=0x62900028a219 "", packet_length=packet_length@entry=15, blocking=blocking@entry=true) at /data/bld/10.11-asan-ubsan/sql/sql_parse.cc:1906
      #18 0x000055d6a5156d5d in do_command (thd=thd@entry=0x62c0001f0218, blocking=blocking@entry=true) at /data/bld/10.11-asan-ubsan/sql/sql_parse.cc:1419
      #19 0x000055d6a5949a06 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x6080000214b8, put_in_cache=put_in_cache@entry=true) at /data/bld/10.11-asan-ubsan/sql/sql_connect.cc:1386
      #20 0x000055d6a594ab63 in handle_one_connection (arg=0x6080000214b8) at /data/bld/10.11-asan-ubsan/sql/sql_connect.cc:1298
      #21 0x000055d6a72afd6f in pfs_spawn_thread (arg=0x617000008218) at /data/bld/10.11-asan-ubsan/storage/perfschema/pfs.cc:2201
      #22 0x00007f978f4a81c4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #23 0x00007f978f52885c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      Non-debug build produces a bunch of errors both on REPAIR and ANALYZE:

      10.11 2147951560c013fc084c4c06dcf8e09ec403dd9f

      CREATE TABLE t (a INT PRIMARY KEY) ENGINE=InnoDB;
      ANALYZE TABLE t;
      Table	Op	Msg_type	Msg_text
      test.t	analyze	status	Engine-independent statistics collected
      test.t	analyze	status	OK
      REPAIR TABLE mysql.index_stats QUICK USE_FRM;
      Table	Op	Msg_type	Msg_text
      mysql.index_stats	repair	Error	failed to decrypt './mysql/index_stats'  rc: -1  dstlen: 0  size: 8172
      mysql.index_stats	repair	status	OK
      ANALYZE TABLE t;
      Table	Op	Msg_type	Msg_text
      test.t	analyze	Error	failed to decrypt './mysql/index_stats'  rc: -1  dstlen: 0  size: 8172
      test.t	analyze	Error	Got error '192 "Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryptio"' for './mysql/index_stats.MAI'
      test.t	analyze	status	Operation failed
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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