[MDEV-20498] Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type == 1' failed upon REBUILD PARTITION Created: 2019-09-04  Updated: 2024-01-06

Status: Confirmed
Project: MariaDB Server
Component/s: Partitioning
Affects Version/s: 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0, 11.1, 11.2, 11.3, 11.4
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2, 11.3, 11.4

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Alexey Botchkov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-22164 WITHOUT VALIDATION for EXCHANGE PARTI... Closed

 Description   

--source include/have_innodb.inc
--source include/have_partition.inc
 
CREATE TABLE t1 (a INT) ENGINE=InnoDB PARTITION BY LIST (a) (PARTITION p0 VALUES IN (8), PARTITION p1 VALUES IN (4,7,0), PARTITION p2 VALUES IN (9,2,5), PARTITION p3 VALUES IN (3,1,6));
INSERT INTO t1 VALUES (8),(5),(4),(0);
ALTER TABLE t1 DROP a, ADD a INT NOT NULL DEFAULT 0;
ALTER TABLE t1 REBUILD PARTITION p0;
 
# Cleanup
DROP TABLE t1;

10.4 18af13b8 debug

mysqld: /data/src/10.4/sql/handler.cc:6658: int handler::ha_write_row(const uchar*): Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type == 1' failed.
190904 22:27:19 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f52c06fcf12 in __GI___assert_fail (assertion=0x55f6434545c0 "table_share->tmp_table != NO_TMP_TABLE || m_lock_type == 1", file=0x55f643452c32 "/data/src/10.4/sql/handler.cc", line=6658, function=0x55f643457440 <handler::ha_write_row(unsigned char const*)::__PRETTY_FUNCTION__> "int handler::ha_write_row(const uchar*)") at assert.c:101
#8  0x000055f642911004 in handler::ha_write_row (this=0x7f526814f908, buf=0x7f5268079998 "\377") at /data/src/10.4/sql/handler.cc:6657
#9  0x000055f6431742da in ha_partition::copy_partitions (this=0x7f526800b638, copied=0x7f52b9ac95c8, deleted=0x7f52b9ac95d0) at /data/src/10.4/sql/ha_partition.cc:2117
#10 0x000055f643173fc7 in ha_partition::change_partitions (this=0x7f526800b638, create_info=0x7f52b9acbd10, path=0x7f52b9ac9320 "./test/t1", copied=0x7f52b9ac95c8, deleted=0x7f52b9ac95d0, pack_frm_data=0x0, pack_frm_len=0) at /data/src/10.4/sql/ha_partition.cc:2029
#11 0x000055f64290b7f4 in handler::ha_change_partitions (this=0x7f526800b638, create_info=0x7f52b9acbd10, path=0x7f52b9ac9320 "./test/t1", copied=0x7f52b9ac95c8, deleted=0x7f52b9ac95d0, pack_frm_data=0x0, pack_frm_len=0) at /data/src/10.4/sql/handler.cc:4785
#12 0x000055f642ae3531 in mysql_change_partitions (lpt=0x7f52b9ac95c0) at /data/src/10.4/sql/sql_partition.cc:6007
#13 0x000055f642ae6ca7 in fast_alter_partition_table (thd=0x7f5268000b00, table=0x7f526814e2e0, alter_info=0x7f52b9acbc50, create_info=0x7f52b9acbd10, table_list=0x7f5268013210, db=0x7f52b9acb140, table_name=0x7f52b9acb150) at /data/src/10.4/sql/sql_partition.cc:7372
#14 0x000055f64268f817 in mysql_alter_table (thd=0x7f5268000b00, new_db=0x7f52680052b8, new_name=0x7f52680056c0, create_info=0x7f52b9acbd10, table_list=0x7f5268013210, alter_info=0x7f52b9acbc50, order_num=0, order=0x0, ignore=false) at /data/src/10.4/sql/sql_table.cc:9837
#15 0x000055f642728485 in Sql_cmd_alter_table::execute (this=0x7f52680138e0, thd=0x7f5268000b00) at /data/src/10.4/sql/sql_alter.cc:508
#16 0x000055f6425a61a3 in mysql_execute_command (thd=0x7f5268000b00) at /data/src/10.4/sql/sql_parse.cc:6099
#17 0x000055f6425ab8ec in mysql_parse (thd=0x7f5268000b00, rawbuf=0x7f5268013118 "ALTER TABLE t1 REBUILD PARTITION p0", length=35, parser_state=0x7f52b9acd170, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7909
#18 0x000055f6425968ec in dispatch_command (command=COM_QUERY, thd=0x7f5268000b00, packet=0x7f526819dc31 "ALTER TABLE t1 REBUILD PARTITION p0", packet_length=35, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1843
#19 0x000055f642594f36 in do_command (thd=0x7f5268000b00) at /data/src/10.4/sql/sql_parse.cc:1360
#20 0x000055f64271ec47 in do_handle_one_connection (connect=0x55f64623ca90) at /data/src/10.4/sql/sql_connect.cc:1412
#21 0x000055f64271e996 in handle_one_connection (arg=0x55f64623ca90) at /data/src/10.4/sql/sql_connect.cc:1316
#22 0x000055f643154da3 in pfs_spawn_thread (arg=0x55f6461bb410) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#23 0x00007f52c22714a4 in start_thread (arg=0x7f52b9ace700) at pthread_create.c:456
#24 0x00007f52c07b9d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

No obvious effect on a non-debug build.



 Comments   
Comment by Elena Stepanova [ 2023-12-27 ]

With addition of WITHOUT VALIDATION in MDEV-22164 this bug makes 11.4 testing even more problematic, as it directly applies to tables altered without validation:

--source include/have_innodb.inc
--source include/have_partition.inc
 
create table t (a int) engine=InnoDB;
insert into t values (1),(100);
 
create table t1 (a int) engine=InnoDB partition by list(a) (p0 values in (1,2));
insert into t1 values (1),(2);
 
alter table t1 convert table t to partition p1 values in (3,4) without validation;
alter table t1 rebuild partition p1;
 
# Cleanup
drop table t1;

Also, contrary to the claim in the description, there can be effect on a non-debug build:

--source include/have_partition.inc
 
create table t (a int) partition by range (a) (
  partition p0 values less than (10),
  partition p1 values less than (100)
);
 
create table t1 (a int);
insert into t1 values (1),(101);
 
alter table t exchange partition p1 with table t1 without validation;
alter table t rebuild partition p1;

11.4 5462b61b0c3ae59d3996018d7da34220460baf46

mysqltest: At line 12: query 'alter table t rebuild partition p1' failed: ER_OPEN_AS_READONLY (1036): Table './test/t.MYI' is read only

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