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

ASAN errors in ha_maria::repair upon concurrent REPAIR PARTITION and DML

    XMLWordPrintable

Details

    Description

      Note: The test case is very non-deterministic. It already contains loops (to avoid re-creating tables to make execution faster), so it's meant to fail on the first attempt, and it usually does, for me it fails within several seconds. However, I suppose it can vary a lot on different machines and builds, so try to adjust the loop parameters and/or run with repeat=N if it doesn't fail right away.

      Don't put it into the regression suite!

      The compound block is not important for the test scenario, it's just there to produce concurrency within MTR.

      --source include/have_partition.inc
       
      CREATE TABLE t1 (a INT, KEY(a)) ENGINE=Aria PARTITION BY HASH(a) PARTITIONS 10;
      CREATE TABLE t2 (b INT, KEY(b)) ENGINE=Aria PARTITION BY HASH(b) PARTITIONS 10;
       
      --connect (con1,localhost,root,,)
       
      --let run=1000
      while ($run)
      {
        --echo #
        --echo # $run loops left
        --echo #
        --connection con1
        --delimiter $
        --send
          BEGIN NOT ATOMIC
          DECLARE i INT DEFAULT 0;
          WHILE i < 500 DO
            UPDATE t2 PARTITION (p1) SET b = 8;
            SET i = i + 1;
          END WHILE;
          END $
        --delimiter ;
       
        --connection default
        --let $n= 20
        while ($n)
        {
          ALTER TABLE t1 REPAIR PARTITION p0,p1,p2,p3,p4,p5,p6,p7,p8,p9;
          --dec $n
        }
       
        --connection con1
        --reap
        --dec $run
      }
       
      # Cleanup
      DROP TABLE t1, t2;
      

      10.5 caeff135

      ==3898374==ERROR: AddressSanitizer: heap-use-after-free on address 0x60e000099b28 at pc 0x558c62671c0b bp 0x7f16a50914f0 sp 0x7f16a50914e8
      READ of size 8 at 0x60e000099b28 thread T5
          #0 0x558c62671c0a in ha_maria::repair(THD*, st_ha_check_opt*) /data/src/10.5/storage/maria/ha_maria.cc:1492
          #1 0x558c620b5f3d in handler::ha_repair(THD*, st_ha_check_opt*) /data/src/10.5/sql/handler.cc:4708
          #2 0x558c628ad0ec in ha_partition::handle_opt_part(THD*, st_ha_check_opt*, unsigned int, unsigned int) /data/src/10.5/sql/ha_partition.cc:1389
          #3 0x558c628ae15f in ha_partition::handle_opt_partitions(THD*, st_ha_check_opt*, unsigned int) /data/src/10.5/sql/ha_partition.cc:1555
          #4 0x558c628ac9ec in ha_partition::repair(THD*, st_ha_check_opt*) /data/src/10.5/sql/ha_partition.cc:1307
          #5 0x558c620b5f3d in handler::ha_repair(THD*, st_ha_check_opt*) /data/src/10.5/sql/handler.cc:4708
          #6 0x558c61cf9262 in mysql_admin_table /data/src/10.5/sql/sql_admin.cc:835
          #7 0x558c61cff091 in Sql_cmd_repair_table::execute(THD*) /data/src/10.5/sql/sql_admin.cc:1500
          #8 0x558c61cc82ff in Sql_cmd_alter_table_repair_partition::execute(THD*) /data/src/10.5/sql/sql_partition_admin.cc:789
          #9 0x558c6189332a in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:6073
          #10 0x558c618a07e6 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8106
          #11 0x558c61876377 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
          #12 0x558c61872d14 in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1375
          #13 0x558c61cbffea in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1416
          #14 0x558c61cbf9b2 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1318
          #15 0x558c6290f70b in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
          #16 0x7f16ac8a7fd3 in start_thread nptl/pthread_create.c:442
          #17 0x7f16ac9285bb in clone3 ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
       
      0x60e000099b28 is located 40 bytes inside of 160-byte region [0x60e000099b00,0x60e000099ba0)
      freed by thread T5 here:
          #0 0x7f16ad4b76a8 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:52
          #1 0x558c6356175b in my_free /data/src/10.5/mysys/my_malloc.c:213
          #2 0x558c6263af0a in _ma_trnman_end_trans_hook /data/src/10.5/storage/maria/ma_state.c:551
          #3 0x558c6268c209 in trnman_end_trn /data/src/10.5/storage/maria/trnman.c:475
          #4 0x558c627187dc in ma_commit /data/src/10.5/storage/maria/ma_commit.c:39
          #5 0x558c6267ea26 in ha_maria::implicit_commit(THD*, bool) /data/src/10.5/storage/maria/ha_maria.cc:3067
          #6 0x558c62672097 in ha_maria::repair(THD*, st_ha_check_opt*) /data/src/10.5/storage/maria/ha_maria.cc:1528
          #7 0x558c620b5f3d in handler::ha_repair(THD*, st_ha_check_opt*) /data/src/10.5/sql/handler.cc:4708
          #8 0x558c628ad0ec in ha_partition::handle_opt_part(THD*, st_ha_check_opt*, unsigned int, unsigned int) /data/src/10.5/sql/ha_partition.cc:1389
          #9 0x558c628ae15f in ha_partition::handle_opt_partitions(THD*, st_ha_check_opt*, unsigned int) /data/src/10.5/sql/ha_partition.cc:1555
          #10 0x558c628ac9ec in ha_partition::repair(THD*, st_ha_check_opt*) /data/src/10.5/sql/ha_partition.cc:1307
          #11 0x558c620b5f3d in handler::ha_repair(THD*, st_ha_check_opt*) /data/src/10.5/sql/handler.cc:4708
          #12 0x558c61cf9262 in mysql_admin_table /data/src/10.5/sql/sql_admin.cc:835
          #13 0x558c61cff091 in Sql_cmd_repair_table::execute(THD*) /data/src/10.5/sql/sql_admin.cc:1500
          #14 0x558c61cc82ff in Sql_cmd_alter_table_repair_partition::execute(THD*) /data/src/10.5/sql/sql_partition_admin.cc:789
          #15 0x558c6189332a in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:6073
          #16 0x558c618a07e6 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8106
          #17 0x558c61876377 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
          #18 0x558c61872d14 in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1375
          #19 0x558c61cbffea in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1416
          #20 0x558c61cbf9b2 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1318
          #21 0x558c6290f70b in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
          #22 0x7f16ac8a7fd3 in start_thread nptl/pthread_create.c:442
       
      previously allocated by thread T5 here:
          #0 0x7f16ad4b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
          #1 0x558c6356092b in my_malloc /data/src/10.5/mysys/my_malloc.c:91
          #2 0x558c62637c8c in _ma_setup_live_state /data/src/10.5/storage/maria/ma_state.c:82
          #3 0x558c6267ed9b in ha_maria::implicit_commit(THD*, bool) /data/src/10.5/storage/maria/ha_maria.cc:3106
          #4 0x558c62672097 in ha_maria::repair(THD*, st_ha_check_opt*) /data/src/10.5/storage/maria/ha_maria.cc:1528
          #5 0x558c620b5f3d in handler::ha_repair(THD*, st_ha_check_opt*) /data/src/10.5/sql/handler.cc:4708
          #6 0x558c628ad0ec in ha_partition::handle_opt_part(THD*, st_ha_check_opt*, unsigned int, unsigned int) /data/src/10.5/sql/ha_partition.cc:1389
          #7 0x558c628ae15f in ha_partition::handle_opt_partitions(THD*, st_ha_check_opt*, unsigned int) /data/src/10.5/sql/ha_partition.cc:1555
          #8 0x558c628ac9ec in ha_partition::repair(THD*, st_ha_check_opt*) /data/src/10.5/sql/ha_partition.cc:1307
          #9 0x558c620b5f3d in handler::ha_repair(THD*, st_ha_check_opt*) /data/src/10.5/sql/handler.cc:4708
          #10 0x558c61cf9262 in mysql_admin_table /data/src/10.5/sql/sql_admin.cc:835
          #11 0x558c61cff091 in Sql_cmd_repair_table::execute(THD*) /data/src/10.5/sql/sql_admin.cc:1500
          #12 0x558c61cc82ff in Sql_cmd_alter_table_repair_partition::execute(THD*) /data/src/10.5/sql/sql_partition_admin.cc:789
          #13 0x558c6189332a in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:6073
          #14 0x558c618a07e6 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8106
          #15 0x558c61876377 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
          #16 0x558c61872d14 in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1375
          #17 0x558c61cbffea in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1416
          #18 0x558c61cbf9b2 in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1318
          #19 0x558c6290f70b in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
          #20 0x7f16ac8a7fd3 in start_thread nptl/pthread_create.c:442
       
      Thread T5 created by T0 here:
          #0 0x7f16ad449726 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:207
          #1 0x558c6290b43e in my_thread_create /data/src/10.5/storage/perfschema/my_thread.h:52
          #2 0x558c6290fafa in pfs_spawn_thread_v1 /data/src/10.5/storage/perfschema/pfs.cc:2252
          #3 0x558c61569f1b in inline_mysql_thread_create /data/src/10.5/include/mysql/psi/mysql_thread.h:1323
          #4 0x558c6157fc8d in create_thread_to_handle_connection(CONNECT*) /data/src/10.5/sql/mysqld.cc:6060
          #5 0x558c6158029e in create_new_thread(CONNECT*) /data/src/10.5/sql/mysqld.cc:6119
          #6 0x558c61580571 in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/src/10.5/sql/mysqld.cc:6184
          #7 0x558c61581162 in handle_connections_sockets() /data/src/10.5/sql/mysqld.cc:6311
          #8 0x558c6157f50a in mysqld_main(int, char**) /data/src/10.5/sql/mysqld.cc:5706
          #9 0x558c61568928 in main /data/src/10.5/sql/main.cc:25
          #10 0x7f16ac846189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
       
      SUMMARY: AddressSanitizer: heap-use-after-free /data/src/10.5/storage/maria/ha_maria.cc:1492 in ha_maria::repair(THD*, st_ha_check_opt*)
      Shadow bytes around the buggy address:
        0x0c1c8000b310: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c1c8000b320: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
        0x0c1c8000b330: fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa
        0x0c1c8000b340: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c1c8000b350: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa
      =>0x0c1c8000b360: fd fd fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd
        0x0c1c8000b370: fd fd fd fd fa fa fa fa fa fa fa fa fd fd fd fd
        0x0c1c8000b380: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0c1c8000b390: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
        0x0c1c8000b3a0: fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa
        0x0c1c8000b3b0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
      Shadow byte legend (one shadow byte represents 8 application bytes):
        Addressable:           00
        Partially addressable: 01 02 03 04 05 06 07 
        Heap left redzone:       fa
        Freed heap region:       fd
        Stack left redzone:      f1
        Stack mid redzone:       f2
        Stack right redzone:     f3
        Stack after return:      f5
        Stack use after scope:   f8
        Global redzone:          f9
        Global init order:       f6
        Poisoned by user:        f7
        Container overflow:      fc
        Array cookie:            ac
        Intra object redzone:    bb
        ASan internal:           fe
        Left alloca redzone:     ca
        Right alloca redzone:    cb
      ==3898374==ABORTING
      230606  3:32:19 [ERROR] mysqld got signal 6 ;
      This could be because you hit a bug. It is also possible that this binary
      or one of the libraries it was linked against is corrupt, improperly built,
      or misconfigured. This error can also be caused by malfunctioning hardware.
       
      To report this bug, see https://mariadb.com/kb/en/reporting-bugs
       
      We will try our best to scrape up some info that will hopefully help
      diagnose the problem, but since we have already crashed, 
      something is definitely wrong and this may fail.
       
      Server version: 10.5.21-MariaDB-debug-log source revision: caeff1357939daa708f7e68d51ab5ded2a929b97
      key_buffer_size=1048576
      read_buffer_size=131072
      max_used_connections=2
      max_threads=153
      thread_count=2
      It is possible that mysqld could use up to 
      key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 63762 K  bytes of memory
      Hope that's ok; if not, decrease some variables in the equation.
       
      Thread pointer: 0x62b000069218
      Attempting backtrace. You can use the following information to find out
      where mysqld died. If you see no messages after this, something went
      terribly wrong...
      stack_bottom = 0x7f16a5094c50 thread_stack 0x100000
      sanitizer_common/sanitizer_common_interceptors.inc:4277(__interceptor_backtrace.part.0)[0x7f16ad451f31]
      mysys/stacktrace.c:212(my_print_stacktrace)[0x558c635707ab]
      sql/signal_handler.cc:241(handle_fatal_signal)[0x558c6208bf47]
      libc_sigaction.c:0(__restore_rt)[0x7f16ac85af90]
      nptl/pthread_kill.c:44(__pthread_kill_implementation)[0x7f16ac8a9ccc]
      posix/raise.c:27(__GI_raise)[0x7f16ac85aef2]
      stdlib/abort.c:81(__GI_abort)[0x7f16ac845472]
      sanitizer_common/sanitizer_posix_libcdep.cpp:137(__sanitizer::Abort())[0x7f16ad4d650f]
      sanitizer_common/sanitizer_termination.cpp:59(__sanitizer::Die())[0x7f16ad4e2ba1]
      asan/asan_report.cpp:190(__asan::ScopedInErrorReport::~ScopedInErrorReport())[0x7f16ad4c1f5e]
      asan/asan_report.cpp:479(__asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool))[0x7f16ad4c14c6]
      asan/asan_rtl.cpp:123(__asan_report_load8)[0x7f16ad4c25ac]
      maria/ha_maria.cc:1492(ha_maria::repair(THD*, st_ha_check_opt*))[0x558c62671c0b]
      sql/handler.cc:4708(handler::ha_repair(THD*, st_ha_check_opt*))[0x558c620b5f3e]
      sql/ha_partition.cc:1389(ha_partition::handle_opt_part(THD*, st_ha_check_opt*, unsigned int, unsigned int))[0x558c628ad0ed]
      sql/ha_partition.cc:1555(ha_partition::handle_opt_partitions(THD*, st_ha_check_opt*, unsigned int))[0x558c628ae160]
      sql/ha_partition.cc:1307(ha_partition::repair(THD*, st_ha_check_opt*))[0x558c628ac9ed]
      sql/handler.cc:4708(handler::ha_repair(THD*, st_ha_check_opt*))[0x558c620b5f3e]
      sql/sql_admin.cc:835(mysql_admin_table(THD*, TABLE_LIST*, st_ha_check_opt*, char const*, thr_lock_type, bool, bool, unsigned int, int (*)(THD*, TABLE_LIST*, st_ha_check_opt*), int (handler::*)(THD*, st_ha_check_opt*), int (*)(THD*, TABLE_LIST*, st_ha_check_opt*), bool))[0x558c61cf9263]
      sql/sql_admin.cc:1500(Sql_cmd_repair_table::execute(THD*))[0x558c61cff092]
      sql/sql_partition_admin.cc:789(Sql_cmd_alter_table_repair_partition::execute(THD*))[0x558c61cc8300]
      sql/sql_parse.cc:6073(mysql_execute_command(THD*))[0x558c6189332b]
      sql/sql_parse.cc:8106(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x558c618a07e7]
      sql/sql_parse.cc:1894(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x558c61876378]
      sql/sql_parse.cc:1375(do_command(THD*))[0x558c61872d15]
      sql/sql_connect.cc:1416(do_handle_one_connection(CONNECT*, bool))[0x558c61cbffeb]
      sql/sql_connect.cc:1320(handle_one_connection)[0x558c61cbf9b3]
      perfschema/pfs.cc:2203(pfs_spawn_thread)[0x558c6290f70c]
      nptl/pthread_create.c:442(start_thread)[0x7f16ac8a7fd4]
      x86_64/clone3.S:83(clone3)[0x7f16ac9285bc]
       
      Trying to get some variables.
      Some pointers may be invalid and cause the dump to abort.
      Query (0x62b000038238): ALTER TABLE t1 REPAIR PARTITION p0,p1,p2,p3,p4,p5,p6,p7,p8,p9
       
      Connection ID (thread ID): 4
      Status: NOT_KILLED
       
      Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
       
      The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
      information that should help you find out what is causing the crash.
      Writing a core file...
      Working directory at /dev/shm/var_auto_bMLO/mysqld.1/data
      Resource Limits:
      Limit                     Soft Limit           Hard Limit           Units     
      Max cpu time              unlimited            unlimited            seconds   
      Max file size             unlimited            unlimited            bytes     
      Max data size             unlimited            unlimited            bytes     
      Max stack size            8388608              unlimited            bytes     
      Max core file size        unlimited            unlimited            bytes     
      Max resident set          unlimited            unlimited            bytes     
      Max processes             385793               385793               processes 
      Max open files            65536                65536                files     
      Max locked memory         12649951232          12649951232          bytes     
      Max address space         unlimited            unlimited            bytes     
      Max file locks            unlimited            unlimited            locks     
      Max pending signals       385793               385793               signals   
      Max msgqueue size         819200               819200               bytes     
      Max nice priority         0                    0                    
      Max realtime priority     0                    0                    
      Max realtime timeout      unlimited            unlimited            us        
      Core pattern: core
       
      Kernel version: Linux version 6.1.0-3-amd64 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC Debian 6.1.8-1 (2023-01-29)
      

      Could not reproduce on 10.4.
      Could not reproduce with MyISAM.

      Attachments

        Activity

          People

            monty Michael Widenius
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.