[MDEV-18875] Assertion `thd->transaction.stmt.ha_list == __null || trans == &thd->transaction.stmt' failed or bogus ER_DUP_ENTRY upon ALTER TABLE with versioning Created: 2019-03-10  Updated: 2020-02-04  Resolved: 2019-12-29

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Versioned Tables
Affects Version/s: 10.3, 10.4
Fix Version/s: 10.3.22, 10.4.12

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

Issue Links:
Relates
relates to MDEV-21650 Non-empty statement transaction on gl... Closed

 Description   

--source include/have_innodb.inc
 
CREATE OR REPLACE TABLE t1 (s DATE, e DATE, PERIOD FOR app(s,e)) ENGINE=InnoDB;
SET AUTOCOMMIT = 0;
ALTER TABLE t1 
  ADD PERIOD IF NOT EXISTS FOR app(a,b),
  ADD COLUMN row_start BIGINT UNSIGNED AS ROW START,
  ADD COLUMN row_end BIGINT UNSIGNED AS ROW END,
  ADD PERIOD FOR SYSTEM_TIME(row_start,row_end),
  WITH SYSTEM VERSIONING;
 
# Cleanup
DROP TABLE t1;

10.4 5a796f1f debug

mysqld: /data/src/10.4/sql/handler.cc:1803: int ha_rollback_trans(THD*, bool): Assertion `thd->transaction.stmt.ha_list == __null || trans == &thd->transaction.stmt' failed.
190310 18:09:31 [ERROR] mysqld got signal 6 ;
 
#7  0x00007faba0704ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x000055b2b4707dbf in ha_rollback_trans (thd=0x7fab48000b00, all=true) at /data/src/10.4/sql/handler.cc:1802
#9  0x000055b2b4707771 in ha_commit_trans (thd=0x7fab48000b00, all=true) at /data/src/10.4/sql/handler.cc:1657
#10 0x000055b2b454ab85 in trans_commit_implicit (thd=0x7fab48000b00) at /data/src/10.4/sql/transaction.cc:378
#11 0x000055b2b4711132 in ha_enable_transaction (thd=0x7fab48000b00, on=true) at /data/src/10.4/sql/handler.cc:4968
#12 0x000055b2b44aba58 in mysql_trans_commit_alter_copy_data (thd=0x7fab48000b00) at /data/src/10.4/sql/sql_table.cc:10377
#13 0x000055b2b44ad098 in copy_data_between_tables (thd=0x7fab48000b00, from=0x7fab4800c980, to=0x7fab48153180, create=..., ignore=false, order_num=0, order=0x0, copied=0x7fab99a2a800, deleted=0x7fab99a2a808, keys_onoff=Alter_info::LEAVE_AS_IS, alter_ctx=0x7fab99a2b0e0) at /data/src/10.4/sql/sql_table.cc:10736
#14 0x000055b2b44aab9f in mysql_alter_table (thd=0x7fab48000b00, new_db=0x7fab480052a0, new_name=0x7fab480056a0, create_info=0x7fab99a2bcd0, table_list=0x7fab48015730, alter_info=0x7fab99a2bc10, order_num=0, order=0x0, ignore=false) at /data/src/10.4/sql/sql_table.cc:10076
#15 0x000055b2b453bb5a in Sql_cmd_alter_table::execute (this=0x7fab480164f0, thd=0x7fab48000b00) at /data/src/10.4/sql/sql_alter.cc:499
#16 0x000055b2b43c99ca in mysql_execute_command (thd=0x7fab48000b00) at /data/src/10.4/sql/sql_parse.cc:6393
#17 0x000055b2b43ceb63 in mysql_parse (thd=0x7fab48000b00, rawbuf=0x7fab480154c8 "ALTER TABLE t1 \nADD PERIOD IF NOT EXISTS FOR app(a,b),\nADD COLUMN row_start BIGINT UNSIGNED AS ROW START,\nADD COLUMN row_end BIGINT UNSIGNED AS ROW END,\nADD PERIOD FOR SYSTEM_TIME(row_start,row_end),\n"..., length=222, parser_state=0x7fab99a2d180, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8204
#18 0x000055b2b43ba1a5 in dispatch_command (command=COM_QUERY, thd=0x7fab48000b00, packet=0x7fab4813a1a1 "", packet_length=222, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1829
#19 0x000055b2b43b898b in do_command (thd=0x7fab48000b00) at /data/src/10.4/sql/sql_parse.cc:1358
#20 0x000055b2b4532703 in do_handle_one_connection (connect=0x55b2b6fac160) at /data/src/10.4/sql/sql_connect.cc:1399
#21 0x000055b2b4532474 in handle_one_connection (arg=0x55b2b6fac160) at /data/src/10.4/sql/sql_connect.cc:1302
#22 0x000055b2b4a28031 in pfs_spawn_thread (arg=0x55b2b6ff1fd0) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#23 0x00007faba23db494 in start_thread (arg=0x7fab99a2e700) at pthread_create.c:333
#24 0x00007faba07c193f in clone () from /lib/x86_64-linux-gnu/libc.so.6

10.4 5a796f1f non-debug

mysqltest: At line 5: query 'ALTER TABLE t1 
ADD PERIOD IF NOT EXISTS FOR app(a,b),
ADD COLUMN row_start BIGINT UNSIGNED AS ROW START,
ADD COLUMN row_end BIGINT UNSIGNED AS ROW END,
ADD PERIOD FOR SYSTEM_TIME(row_start,row_end),
WITH SYSTEM VERSIONING' failed: 1062: Duplicate entry '38' for key 'PRIMARY'



 Comments   
Comment by Nikita Malyavin [ 2019-03-19 ]

Reproduced without Application-time periods by adding ALGORITHM=COPY

--source include/have_innodb.inc
 
CREATE OR REPLACE TABLE t1 (s DATE, e DATE) ENGINE=InnoDB;
SET AUTOCOMMIT = 0;
ALTER TABLE t1
  ALGORITHM=COPY,
  ADD COLUMN row_start BIGINT UNSIGNED AS ROW START,
  ADD COLUMN row_end BIGINT UNSIGNED AS ROW END,
  ADD PERIOD FOR SYSTEM_TIME(row_start,row_end),
  WITH SYSTEM VERSIONING;
 
# Cleanup
DROP TABLE t1;

Comment by Sergei Golubchik [ 2019-10-25 ]

server change is fine, dunno about InnoDB changes

Comment by Marko Mäkelä [ 2019-12-18 ]

I rebased to latest 10.3 and force-pushed to bb-10.3-trxid_fixes, and added a small cleanup commit on top. Please check the results (it did pass my local --big-test run) and squash it into a single commit before pushing to 10.3.

Generated at Thu Feb 08 08:47:24 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.