[MDEV-31172] Server crash or ASAN errors in online_alter_check_autoinc Created: 2023-05-03  Updated: 2024-01-01  Resolved: 2024-01-01

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: N/A
Fix Version/s: 11.2.1

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Nikita Malyavin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
PartOf
is part of MDEV-31058 ER_KEY_NOT_FOUND upon concurrent CHAN... Closed
Problem/Incident
is caused by MDEV-16329 Engine-independent online ALTER TABLE Closed
is caused by MDEV-31058 ER_KEY_NOT_FOUND upon concurrent CHAN... Closed
Relates
relates to MDEV-28808 Test MDEV-16329 (ALTER ONLINE TABLE) ... Stalled

 Description   

CREATE TABLE t (a INT, b INT, c CHAR(8), KEY(a,b,c));
ALTER TABLE t MODIFY c INT AUTO_INCREMENT KEY, ALGORITHM=COPY;
 
# Cleanup
DROP TABLE t;

bb-11.0-oalter 971a1f26ca5

==375595==ERROR: AddressSanitizer: use-after-poison on address 0x61900009ad50 at pc 0x55b83f3d6ada bp 0x7faf792b3e40 sp 0x7faf792b3e38
READ of size 8 at 0x61900009ad50 thread T5
    #0 0x55b83f3d6ad9 in online_alter_check_autoinc(THD const*, Alter_info const*, TABLE const*, bool*) /data/src/bb-11.0-oalter-asan/sql/sql_table.cc:9879
    #1 0x55b83f3d8c12 in mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, Table_specification_st*, TABLE_LIST*, Recreate_info*, Alter_info*, unsigned int, st_order*, bool, bool) /data/src/bb-11.0-oalter-asan/sql/sql_table.cc:10172
    #2 0x55b83f5a5a68 in Sql_cmd_alter_table::execute(THD*) /data/src/bb-11.0-oalter-asan/sql/sql_alter.cc:563
    #3 0x55b83f0e7509 in mysql_execute_command(THD*, bool) /data/src/bb-11.0-oalter-asan/sql/sql_parse.cc:6001
    #4 0x55b83f0f4428 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/bb-11.0-oalter-asan/sql/sql_parse.cc:7997
    #5 0x55b83f0ca620 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/src/bb-11.0-oalter-asan/sql/sql_parse.cc:1894
    #6 0x55b83f0c7352 in do_command(THD*, bool) /data/src/bb-11.0-oalter-asan/sql/sql_parse.cc:1407
    #7 0x55b83f58849b in do_handle_one_connection(CONNECT*, bool) /data/src/bb-11.0-oalter-asan/sql/sql_connect.cc:1416
    #8 0x55b83f587e5c in handle_one_connection /data/src/bb-11.0-oalter-asan/sql/sql_connect.cc:1318
    #9 0x55b840165907 in pfs_spawn_thread /data/src/bb-11.0-oalter-asan/storage/perfschema/pfs.cc:2201
    #10 0x7faf80aa7fd3 in start_thread nptl/pthread_create.c:442
    #11 0x7faf80b285bb in clone3 ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
 
0x61900009ad50 is located 464 bytes inside of 1040-byte region [0x61900009ab80,0x61900009af90)
allocated by thread T5 here:
    #0 0x7faf816b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x55b840d45c41 in my_malloc /data/src/bb-11.0-oalter-asan/mysys/my_malloc.c:91
    #2 0x55b840d2125f in root_alloc /data/src/bb-11.0-oalter-asan/mysys/my_alloc.c:71
    #3 0x55b840d229b5 in alloc_root /data/src/bb-11.0-oalter-asan/mysys/my_alloc.c:337
    #4 0x55b840d244c8 in memdup_root /data/src/bb-11.0-oalter-asan/mysys/my_alloc.c:609
    #5 0x55b83f48bde6 in TABLE_SHARE::init_from_binary_frm_image(THD*, bool, unsigned char const*, unsigned long, unsigned char const*, unsigned long) /data/src/bb-11.0-oalter-asan/sql/table.cc:1855
    #6 0x55b83f4843f3 in open_table_def(THD*, TABLE_SHARE*, unsigned int) /data/src/bb-11.0-oalter-asan/sql/table.cc:728
    #7 0x55b83f7fa578 in tdc_acquire_share(THD*, TABLE_LIST*, unsigned int, TABLE**) /data/src/bb-11.0-oalter-asan/sql/table_cache.cc:836
    #8 0x55b83ef255bc in open_table(THD*, TABLE_LIST*, Open_table_context*) /data/src/bb-11.0-oalter-asan/sql/sql_base.cc:2028
    #9 0x55b83ef31673 in open_and_process_table /data/src/bb-11.0-oalter-asan/sql/sql_base.cc:4108
    #10 0x55b83ef341b1 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /data/src/bb-11.0-oalter-asan/sql/sql_base.cc:4595
    #11 0x55b83f38e319 in open_tables /data/src/bb-11.0-oalter-asan/sql/sql_base.h:266
    #12 0x55b83f3d86a5 in mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, Table_specification_st*, TABLE_LIST*, Recreate_info*, Alter_info*, unsigned int, st_order*, bool, bool) /data/src/bb-11.0-oalter-asan/sql/sql_table.cc:10129
    #13 0x55b83f5a5a68 in Sql_cmd_alter_table::execute(THD*) /data/src/bb-11.0-oalter-asan/sql/sql_alter.cc:563
    #14 0x55b83f0e7509 in mysql_execute_command(THD*, bool) /data/src/bb-11.0-oalter-asan/sql/sql_parse.cc:6001
    #15 0x55b83f0f4428 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /data/src/bb-11.0-oalter-asan/sql/sql_parse.cc:7997
    #16 0x55b83f0ca620 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /data/src/bb-11.0-oalter-asan/sql/sql_parse.cc:1894
    #17 0x55b83f0c7352 in do_command(THD*, bool) /data/src/bb-11.0-oalter-asan/sql/sql_parse.cc:1407
    #18 0x55b83f58849b in do_handle_one_connection(CONNECT*, bool) /data/src/bb-11.0-oalter-asan/sql/sql_connect.cc:1416
    #19 0x55b83f587e5c in handle_one_connection /data/src/bb-11.0-oalter-asan/sql/sql_connect.cc:1318
    #20 0x55b840165907 in pfs_spawn_thread /data/src/bb-11.0-oalter-asan/storage/perfschema/pfs.cc:2201
    #21 0x7faf80aa7fd3 in start_thread nptl/pthread_create.c:442
 
Thread T5 created by T0 here:
    #0 0x7faf81649726 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:207
    #1 0x55b840161642 in my_thread_create /data/src/bb-11.0-oalter-asan/storage/perfschema/my_thread.h:52
    #2 0x55b840165cf6 in pfs_spawn_thread_v1 /data/src/bb-11.0-oalter-asan/storage/perfschema/pfs.cc:2252
    #3 0x55b83ed1278a in inline_mysql_thread_create /data/src/bb-11.0-oalter-asan/include/mysql/psi/mysql_thread.h:1139
    #4 0x55b83ed2a6ca in create_thread_to_handle_connection(CONNECT*) /data/src/bb-11.0-oalter-asan/sql/mysqld.cc:6126
    #5 0x55b83ed2acef in create_new_thread(CONNECT*) /data/src/bb-11.0-oalter-asan/sql/mysqld.cc:6188
    #6 0x55b83ed2afda in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/src/bb-11.0-oalter-asan/sql/mysqld.cc:6250
    #7 0x55b83ed2b95e in handle_connections_sockets() /data/src/bb-11.0-oalter-asan/sql/mysqld.cc:6374
    #8 0x55b83ed29f47 in mysqld_main(int, char**) /data/src/bb-11.0-oalter-asan/sql/mysqld.cc:6021
    #9 0x55b83ed118f8 in main /data/src/bb-11.0-oalter-asan/sql/main.cc:34
    #10 0x7faf80a46189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
 
SUMMARY: AddressSanitizer: use-after-poison /data/src/bb-11.0-oalter-asan/sql/sql_table.cc:9879 in online_alter_check_autoinc(THD const*, Alter_info const*, TABLE const*, bool*)
Shadow bytes around the buggy address:
  0x0c328000b550: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c328000b560: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c328000b570: 00 00 00 00 00 00 f7 00 00 f7 01 f7 00 00 00 00
  0x0c328000b580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c328000b590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04
=>0x0c328000b5a0: f7 00 00 00 f7 00 00 01 f7 01[f7]00 00 00 00 f7
  0x0c328000b5b0: f7 f7 00 00 00 00 00 00 00 f7 00 00 00 00 00 00
  0x0c328000b5c0: f7 00 f7 f7 f7 f7 00 00 00 00 00 00 00 00 00 00
  0x0c328000b5d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c328000b5e0: f7 00 01 f7 04 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x0c328000b5f0: f7 f7 fa fa fa fa fa fa fa fa fa fa fa fa fa fa
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
==375595==ABORTING
230503  3:21:46 [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: 11.0.2-MariaDB-debug-log source revision: 971a1f26ca51279d09c0677240c63f409d61d8f0
key_buffer_size=1048576
read_buffer_size=131072
max_used_connections=1
max_threads=153
thread_count=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 63923 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x62b00007e218
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 = 0x7faf792b9c10 thread_stack 0x100000
sanitizer_common/sanitizer_common_interceptors.inc:4277(__interceptor_backtrace.part.0)[0x7faf81651f31]
mysys/stacktrace.c:215(my_print_stacktrace)[0x55b840d56d5e]
sql/signal_handler.cc:238(handle_fatal_signal)[0x55b83f9b3206]
libc_sigaction.c:0(__restore_rt)[0x7faf80a5af90]
nptl/pthread_kill.c:44(__pthread_kill_implementation)[0x7faf80aa9ccc]
posix/raise.c:27(__GI_raise)[0x7faf80a5aef2]
stdlib/abort.c:81(__GI_abort)[0x7faf80a45472]
sanitizer_common/sanitizer_posix_libcdep.cpp:137(__sanitizer::Abort())[0x7faf816d650f]
sanitizer_common/sanitizer_termination.cpp:59(__sanitizer::Die())[0x7faf816e2ba1]
asan/asan_report.cpp:190(__asan::ScopedInErrorReport::~ScopedInErrorReport())[0x7faf816c1f5e]
asan/asan_report.cpp:479(__asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool))[0x7faf816c14c6]
asan/asan_rtl.cpp:123(__asan_report_load8)[0x7faf816c25ac]
sql/sql_table.cc:9879(online_alter_check_autoinc(THD const*, Alter_info const*, TABLE const*, bool*))[0x55b83f3d6ada]
sql/sql_table.cc:10172(mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, Table_specification_st*, TABLE_LIST*, Recreate_info*, Alter_info*, unsigned int, st_order*, bool, bool))[0x55b83f3d8c13]
sql/sql_alter.cc:563(Sql_cmd_alter_table::execute(THD*))[0x55b83f5a5a69]
sql/sql_parse.cc:6001(mysql_execute_command(THD*, bool))[0x55b83f0e750a]
sql/sql_parse.cc:7997(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x55b83f0f4429]
sql/sql_parse.cc:1896(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x55b83f0ca621]
sql/sql_parse.cc:1407(do_command(THD*, bool))[0x55b83f0c7353]
sql/sql_connect.cc:1416(do_handle_one_connection(CONNECT*, bool))[0x55b83f58849c]
sql/sql_connect.cc:1320(handle_one_connection)[0x55b83f587e5d]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x55b840165908]
nptl/pthread_create.c:442(start_thread)[0x7faf80aa7fd4]
x86_64/clone3.S:83(clone3)[0x7faf80b285bc]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x6290000e6238): ALTER TABLE t MODIFY c INT AUTO_INCREMENT KEY, ALGORITHM=COPY
 
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_q1e0/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            1024                 1024                 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)


Generated at Thu Feb 08 10:21:49 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.