[MDEV-29034] Assertion (o->ind == vers_start) upon inplace ALTER with virtual columns Created: 2022-07-05  Updated: 2023-12-07

Status: Stalled
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Storage Engine - InnoDB, Versioned Tables
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0, 11.1
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0

Type: Bug Priority: Major
Reporter: Matthias Leich Assignee: Aleksey Midenkov
Resolution: Unresolved Votes: 1
Labels: duplicate, not-10.3, regression-10.4

Attachments: File TBR-1565.test    
Issue Links:
Duplicate
duplicates MDEV-20545 Assertion (col.vers_sys_end()) upon i... Closed
Problem/Incident
is caused by MDEV-17697 Broken versioning info after instant ... Closed
Relates
relates to MDEV-18322 Assertion `!"wrong page type"' or Ass... Closed

 Description   

./mtr  --mem TBR-1565
...
CREATE TABLE B (
pk INTEGER AUTO_INCREMENT,
col_int_key INTEGER,
col_varchar_key VARCHAR(1),
o BIT, n BIT,
h FLOAT AS ( n + 2 ) VIRTUAL,
v BIT,
PRIMARY KEY (pk),
KEY (col_varchar_key, col_int_key)
)  ENGINE = InnoDB;
SET `system_versioning_alter_history`= KEEP ;
ALTER TABLE `B` ADD SYSTEM VERSIONING ;
ALTER        TABLE `B` ADD COLUMN IF NOT EXISTS ( w BIT, v SERIAL ) ;
Warnings:
Note    1060    Duplicate column name 'v'
ALTER        TABLE `B` ADD COLUMN IF NOT EXISTS ( p BIT ) ;
ERROR HY000: Lost connection to server during query
DROP TABLE `B`;
ERROR HY000: Server has gone away
...
mariadbd: /data/Server/10.8G/storage/innobase/handler/handler0alter.cc:529: bool dict_table_t::instant_column(const dict_table_t&, const ulint*): Assertion `o->ind == vers_start' failed.
...
(rr) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007f96cc83e859 in __GI_abort () at abort.c:79
#2  0x00007f96cc83e729 in __assert_fail_base (fmt=0x7f96cc9d4588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55940fe144c0 "o->ind == vers_start", 
    file=0x55940fe12900 "/data/Server/10.8G/storage/innobase/handler/handler0alter.cc", line=529, function=<optimized out>) at assert.c:92
#3  0x00007f96cc84ff36 in __GI___assert_fail (assertion=0x55940fe144c0 "o->ind == vers_start", file=0x55940fe12900 "/data/Server/10.8G/storage/innobase/handler/handler0alter.cc", line=529, 
    function=0x55940fe14000 "bool dict_table_t::instant_column(const dict_table_t&, const ulint*)") at assert.c:101
#4  0x000055940ea1d36f in dict_table_t::instant_column (this=0x618000067908, table=..., col_map=0x61d0002dd6c0) at /data/Server/10.8G/storage/innobase/handler/handler0alter.cc:529
#5  0x000055940ea25067 in ha_innobase_inplace_ctx::instant_column (this=0x6290000fd610) at /data/Server/10.8G/storage/innobase/handler/handler0alter.cc:1177
#6  0x000055940e9d9925 in innobase_instant_try (ha_alter_info=0x7f96c07b2b00, ctx=0x6290000fd610, altered_table=0x7f96c07b3200, table=0x6190000d8e98, trx=0x7f96c8a83e40)
    at /data/Server/10.8G/storage/innobase/handler/handler0alter.cc:5739
#7  0x000055940ea2f0fb in commit_try_norebuild (ha_alter_info=0x7f96c07b2b00, ctx=0x6290000fd610, altered_table=0x7f96c07b3200, old_table=0x6190000d8e98, trx=0x7f96c8a83e40, table_name=0x61b00003b05d "B")
    at /data/Server/10.8G/storage/innobase/handler/handler0alter.cc:10474
#8  0x000055940ea074f7 in ha_innobase::commit_inplace_alter_table (this=0x61d0002d64b8, altered_table=0x7f96c07b3200, ha_alter_info=0x7f96c07b2b00, commit=true)
    at /data/Server/10.8G/storage/innobase/handler/handler0alter.cc:11222
#9  0x000055940e0b50aa in handler::ha_commit_inplace_alter_table (this=0x61d0002d64b8, altered_table=0x7f96c07b3200, ha_alter_info=0x7f96c07b2b00, commit=true) at /data/Server/10.8G/sql/handler.cc:5219
#10 0x000055940db128d8 in mysql_inplace_alter_table (thd=0x62b00016c218, table_list=0x6290000fa390, table=0x6190000d8e98, altered_table=0x7f96c07b3200, ha_alter_info=0x7f96c07b2b00, target_mdl_request=0x7f96c07b2c00, 
    ddl_log_state=0x7f96c07b2920, trigger_param=0x7f96c07b3640, alter_ctx=0x7f96c07b40a0, partial_alter=@0x7f96c07b2690: false, start_alter_id=@0x7f96c07b26c0: 0, if_exists=false) at /data/Server/10.8G/sql/sql_table.cc:7733
#11 0x000055940db27832 in mysql_alter_table (thd=0x62b00016c218, new_db=0x62b000170cc0, new_name=0x62b0001710d8, create_info=0x7f96c07b5550, table_list=0x6290000fa390, alter_info=0x7f96c07b5420, order_num=0, order=0x0, 
    ignore=false, if_exists=false) at /data/Server/10.8G/sql/sql_table.cc:10701
#12 0x000055940dcb782c in Sql_cmd_alter_table::execute (this=0x6290000fabb0, thd=0x62b00016c218) at /data/Server/10.8G/sql/sql_alter.cc:547
#13 0x000055940d87df76 in mysql_execute_command (thd=0x62b00016c218, is_called_from_prepared_stmt=false) at /data/Server/10.8G/sql/sql_parse.cc:5988
#14 0x000055940d88a397 in mysql_parse (thd=0x62b00016c218, rawbuf=0x6290000fa238 "ALTER        TABLE `B` ADD COLUMN IF NOT EXISTS ( p BIT )", length=57, parser_state=0x7f96c07b6a20) at /data/Server/10.8G/sql/sql_parse.cc:8027
#15 0x000055940d8627e9 in dispatch_command (command=COM_QUERY, thd=0x62b00016c218, packet=0x62900026c219 "ALTER        TABLE `B` ADD COLUMN IF NOT EXISTS ( p BIT ) ", packet_length=58, blocking=true)
    at /data/Server/10.8G/sql/sql_parse.cc:1894
#16 0x000055940d85fc30 in do_command (thd=0x62b00016c218, blocking=true) at /data/Server/10.8G/sql/sql_parse.cc:1407
#17 0x000055940dc9d5e5 in do_handle_one_connection (connect=0x608000002a38, put_in_cache=true) at /data/Server/10.8G/sql/sql_connect.cc:1418
#18 0x000055940dc9ce71 in handle_one_connection (arg=0x6080000029b8) at /data/Server/10.8G/sql/sql_connect.cc:1312
#19 0x00007f96ccd68609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#20 0x00007f96cc93b293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(rr)
 
In case I use the storage engine 'Aria' than the test passes.
 
commit 155019b96b9c98228ddbe87ef0c82c24cda3f474 (HEAD, origin/10.8)



 Comments   
Comment by Marko Mäkelä [ 2022-07-25 ]

Curiously, TBR-1565.test will not crash 10.3, but it does crash 10.4 and 10.5 for me:

10.3 8aa37c264f1c67beb9dc5cd4127379f0e596e3f5

innodb.TBR-1565 'innodb'                 [ pass ]     28

10.4 8911823f65a6557ce66ea5f8aecd55b115a85606

ALTER TABLE `B` ADD COLUMN IF NOT EXISTS ( w BIT, v SERIAL ) ;
Warnings:
Note	1060	Duplicate column name 'v'
ALTER TABLE `B` ADD COLUMN IF NOT EXISTS ( p BIT ) ;
ERROR HY000: Lost connection to MySQL server during query
DROP TABLE `B`;
ERROR HY000: MySQL server has gone away
innodb.TBR-1565 'innodb'                 [ fail ]
mysqld: /mariadb/10.4/storage/innobase/handler/handler0alter.cc:566: bool dict_table_t::instant_column(const dict_table_t&, const ulint*): Assertion `o->ind == vers_start' failed.

The assertion was added by midenok in MDEV-17697.

Comment by Roel Van de Paar [ 2023-04-08 ]

This bug is possibly related to MDEV-18322. Reduced testcase and versions update:

SET system_versioning_alter_history=KEEP;
CREATE TABLE t (c INT AS (d),d INT) WITH SYSTEM VERSIONING ENGINE=InnoDB;
ALTER TABLE t ADD COLUMN (e INT,f SERIAL);
ALTER TABLE t ADD COLUMN (g INT);

Leads to:

11.1.0 2b61ff8f2221745f0a96855a0feb0825c426f993 (Debug)

mariadbd: /test/11.1_dbg/storage/innobase/handler/handler0alter.cc:529: bool dict_table_t::instant_column(const dict_table_t&, const ulint*): Assertion `o->ind == vers_start' failed.

11.1.0 2b61ff8f2221745f0a96855a0feb0825c426f993 (Debug)

Core was generated by `/test/MD070423-mariadb-11.1.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --cor'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22927949948480)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x14da544fe640 (LWP 1368333))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22927949948480) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=22927949948480) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=22927949948480, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x000014da72063476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x000014da720497f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x000014da7204971b in __assert_fail_base (fmt=0x14da721fe150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x564b5d6885a2 "o->ind == vers_start", file=0x564b5d680e90 "/test/11.1_dbg/storage/innobase/handler/handler0alter.cc", line=529, function=<optimized out>) at ./assert/assert.c:92
#6  0x000014da7205ae96 in __GI___assert_fail (assertion=0x564b5d6885a2 "o->ind == vers_start", file=0x564b5d680e90 "/test/11.1_dbg/storage/innobase/handler/handler0alter.cc", line=529, function=0x564b5d6886a8 "bool dict_table_t::instant_column(const dict_table_t&, const ulint*)") at ./assert/assert.c:101
#7  0x0000564b5cf5710e in dict_table_t::instant_column (this=0x14da08035c00, table=<optimized out>, col_map=<optimized out>) at /test/11.1_dbg/storage/innobase/handler/handler0alter.cc:529
#8  0x0000564b5cf586e4 in ha_innobase_inplace_ctx::instant_column (this=0x14da080154e8) at /test/11.1_dbg/storage/innobase/handler/handler0alter.cc:1217
#9  innobase_instant_try (ha_alter_info=ha_alter_info@entry=0x14da544f9d90, ctx=ctx@entry=0x14da080154e8, altered_table=altered_table@entry=0x14da544f9e50, table=table@entry=0x14da080268d8, trx=trx@entry=0x14da6931c680) at /test/11.1_dbg/storage/innobase/handler/handler0alter.cc:5895
#10 0x0000564b5cf5cf12 in commit_try_norebuild (ha_alter_info=ha_alter_info@entry=0x14da544f9d90, ctx=ctx@entry=0x14da080154e8, altered_table=altered_table@entry=0x14da544f9e50, old_table=0x14da080268d8, trx=trx@entry=0x14da6931c680, table_name=<optimized out>) at /test/11.1_dbg/storage/innobase/handler/handler0alter.cc:10621
#11 0x0000564b5cf484a3 in ha_innobase::commit_inplace_alter_table (this=<optimized out>, altered_table=<optimized out>, ha_alter_info=<optimized out>, commit=<optimized out>) at /test/11.1_dbg/storage/innobase/handler/handler0alter.cc:11384
#12 0x0000564b5cc36617 in handler::ha_commit_inplace_alter_table (this=0x14da08028fa0, altered_table=altered_table@entry=0x14da544f9e50, ha_alter_info=ha_alter_info@entry=0x14da544f9d90, commit=commit@entry=true) at /test/11.1_dbg/sql/handler.cc:5428
#13 0x0000564b5ca2e9fa in mysql_inplace_alter_table (thd=thd@entry=0x14da08000d58, table_list=0x14da08013268, table=table@entry=0x14da080268d8, altered_table=altered_table@entry=0x14da544f9e50, ha_alter_info=ha_alter_info@entry=0x14da544f9d90, target_mdl_request=target_mdl_request@entry=0x14da544fa630, ddl_log_state=0x14da544f9d20, trigger_param=0x14da544fa210, alter_ctx=0x14da544fb510, partial_alter=@0x14da544f9c8f: false, start_alter_id=@0x14da544f9c98: 0, if_exists=false) at /test/11.1_dbg/sql/sql_table.cc:7810
#14 0x0000564b5ca40b6d in mysql_alter_table (thd=thd@entry=0x14da08000d58, new_db=new_db@entry=0x14da08005878, new_name=new_name@entry=0x14da08005cc8, create_info=create_info@entry=0x14da544fc320, table_list=<optimized out>, table_list@entry=0x14da08013268, recreate_info=recreate_info@entry=0x14da544fc210, alter_info=<optimized out>, order_num=<optimized out>, order=<optimized out>, ignore=<optimized out>, if_exists=<optimized out>) at /test/11.1_dbg/sql/sql_table.cc:10846
#15 0x0000564b5cac0d2c in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x14da08000d58) at /test/11.1_dbg/sql/sql_alter.cc:558
#16 0x0000564b5c962604 in mysql_execute_command (thd=thd@entry=0x14da08000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.1_dbg/sql/sql_parse.cc:5760
#17 0x0000564b5c963f05 in mysql_parse (thd=thd@entry=0x14da08000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14da544fd230) at /test/11.1_dbg/sql/sql_parse.cc:7760
#18 0x0000564b5c966099 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14da08000d58, packet=packet@entry=0x14da0800ae49 "ALTER TABLE t ADD COLUMN (g INT)", packet_length=packet_length@entry=32, blocking=blocking@entry=true) at /test/11.1_dbg/sql/sql_class.h:242
#19 0x0000564b5c967ef5 in do_command (thd=0x14da08000d58, blocking=blocking@entry=true) at /test/11.1_dbg/sql/sql_parse.cc:1405
#20 0x0000564b5cab9cfc in do_handle_one_connection (connect=<optimized out>, connect@entry=0x564b5f7050e8, put_in_cache=put_in_cache@entry=true) at /test/11.1_dbg/sql/sql_connect.cc:1416
#21 0x0000564b5cab9f5b in handle_one_connection (arg=0x564b5f7050e8) at /test/11.1_dbg/sql/sql_connect.cc:1318
#22 0x000014da720b5b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#23 0x000014da72147a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Bug confirmed present in:
MariaDB: 10.4.29 (dbg), 10.5.20 (dbg), 10.6.13 (dbg), 10.7.8 (dbg), 10.8.8 (dbg), 10.9.6 (dbg), 10.10.4 (dbg), 10.11.3 (dbg), 11.0.2 (dbg), 11.1.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.4.29 (opt), 10.5.20 (opt), 10.6.13 (opt), 10.7.8 (opt), 10.8.8 (opt), 10.9.6 (opt), 10.10.4 (opt), 10.11.3 (opt), 11.0.2 (opt), 11.1.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.40 (dbg), 5.7.40 (opt), 8.0.31 (dbg), 8.0.31 (opt)

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