[MDEV-17091] Assertion `old_part_id == m_last_part' failed in ha_partition::update_row or `part_id == m_last_part' in ha_partition::delete_row upon UPDATE/DELETE after dropping versioning Created: 2018-08-29  Updated: 2020-05-28  Resolved: 2020-04-02

Status: Closed
Project: MariaDB Server
Component/s: Partitioning, Versioned Tables
Affects Version/s: 10.3, 10.4
Fix Version/s: 10.3.23, 10.4.13, 10.5.3

Type: Bug Priority: Major
Reporter: Alice Sherepa Assignee: Robert Bindar
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-18794 Assertion `!m_innodb' failed in ha_pa... Closed
Relates
relates to MDEV-15395 Wrong result or Assertion `old_part_i... Closed
relates to MDEV-21641 CHECK reports a misplaced row on part... Closed

 Description   

10.4 6ccd7d2df853baa7646fdc79663d1

#6  0x00007fc9f1e4abd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x55d3735acea4 "old_part_id == m_last_part", file=file@entry=0x55d3735abec0 "/git/10.4/sql/ha_partition.cc", line=line@entry=4377, function=function@entry=0x55d3735b0280 <ha_partition::update_row(unsigned char const*, unsigned char const*)::__PRETTY_FUNCTION__> "virtual int ha_partition::update_row(const uchar*, const uchar*)") at assert.c:92
#7  0x00007fc9f1e4ac82 in __GI___assert_fail (assertion=0x55d3735acea4 "old_part_id == m_last_part", file=0x55d3735abec0 "/git/10.4/sql/ha_partition.cc", line=4377, function=0x55d3735b0280 <ha_partition::update_row(unsigned char const*, unsigned char const*)::__PRETTY_FUNCTION__> "virtual int ha_partition::update_row(const uchar*, const uchar*)") at assert.c:101
#8  0x000055d373156eef in ha_partition::update_row (this=0x7fc9802129f8, old_data=0x7fc9801108a8 "\374\001 \230\177&\200\311\177", new_data=0x7fc980110878 "\374\001 v\316 \200\311\177") at /git/10.4/sql/ha_partition.cc:4377
#9  0x000055d3729ed640 in handler::ha_update_row (this=0x7fc9802129f8, old_data=0x7fc9801108a8 "\374\001 \230\177&\200\311\177", new_data=0x7fc980110878 "\374\001 v\316 \200\311\177") at /git/10.4/sql/handler.cc:6229
#10 0x000055d372b2c8d8 in Update_rows_log_event::do_exec_row (this=0x7fc980234ce0, rgi=0x7fc980000a90) at /git/10.4/sql/log_event.cc:14342
#11 0x000055d372b258b2 in Rows_log_event::do_apply_event (this=0x7fc980234ce0, rgi=0x7fc980000a90) at /git/10.4/sql/log_event.cc:11507
#12 0x000055d372603d7b in Log_event::apply_event (this=0x7fc980234ce0, rgi=0x7fc980000a90) at /git/10.4/sql/log_event.h:1481
#13 0x000055d3725f7d3f in apply_event_and_update_pos_apply (ev=0x7fc980234ce0, thd=0x7fc980001560, rgi=0x7fc980000a90, reason=0) at /git/10.4/sql/slave.cc:3917
#14 0x000055d3725f8210 in apply_event_and_update_pos (ev=0x7fc980234ce0, thd=0x7fc980001560, rgi=0x7fc980000a90) at /git/10.4/sql/slave.cc:4065
#15 0x000055d3725f897c in exec_relay_log_event (thd=0x7fc980001560, rli=0x55d376da6e48, serial_rgi=0x7fc980000a90) at /git/10.4/sql/slave.cc:4352
#16 0x000055d3725fc06a in handle_slave_sql (arg=0x55d376da5180) at /git/10.4/sql/slave.cc:5515
#17 0x00007fc9f2a8f6ba in start_thread (arg=0x7fc9d12a4700) at pthread_create.c:333
#18 0x00007fc9f1f2441d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

See comments for test cases.



 Comments   
Comment by Elena Stepanova [ 2018-12-02 ]

Test case for `part_id == m_last_part' in ha_partition::delete_row

--source include/have_partition.inc
--source include/have_innodb.inc
 
CREATE TABLE t1 (pk INT PRIMARY KEY, f INT) ENGINE=InnoDB WITH SYSTEM VERSIONING PARTITION BY KEY() PARTITIONS 2;
INSERT INTO t1 VALUES (1,10),(2,20);
ALTER TABLE t1 DROP SYSTEM VERSIONING;
DELETE FROM t1;
 
# Cleanup
DROP TABLE t1;

10.3 95f3c142a

mysqld: /data/src/10.3/sql/ha_partition.cc:4528: virtual int ha_partition::delete_row(const uchar*): Assertion `part_id == m_last_part' failed.
181202 13:45:19 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f4a9a879ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x00005582f3d2b7e0 in ha_partition::delete_row (this=0x7f4a400a5d58, buf=0x7f4a400a7978 "\375\002") at /data/src/10.3/sql/ha_partition.cc:4528
#9  0x00005582f35d6024 in handler::ha_delete_row (this=0x7f4a400a5d58, buf=0x7f4a400a7978 "\375\002") at /data/src/10.3/sql/handler.cc:6325
#10 0x00005582f376db5b in TABLE::delete_row (this=0x7f4a400a5110) at /data/src/10.3/sql/sql_delete.cc:253
#11 0x00005582f376ad91 in mysql_delete (thd=0x7f4a40000b00, table_list=0x7f4a40014da0, conds=0x0, order_list=0x7f4a40005398, limit=18446744073709551614, options=0, result=0x0) at /data/src/10.3/sql/sql_delete.cc:753
#12 0x00005582f32d26cd in mysql_execute_command (thd=0x7f4a40000b00) at /data/src/10.3/sql/sql_parse.cc:4924
#13 0x00005582f32dc7cb in mysql_parse (thd=0x7f4a40000b00, rawbuf=0x7f4a40014cd8 "DELETE FROM t1", length=14, parser_state=0x7f4a9441f5f0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:8091
#14 0x00005582f32c997f in dispatch_command (command=COM_QUERY, thd=0x7f4a40000b00, packet=0x7f4a40161121 "DELETE FROM t1", packet_length=14, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1850
#15 0x00005582f32c83a3 in do_command (thd=0x7f4a40000b00) at /data/src/10.3/sql/sql_parse.cc:1395
#16 0x00005582f34300a0 in do_handle_one_connection (connect=0x5582f684f4d0) at /data/src/10.3/sql/sql_connect.cc:1402
#17 0x00005582f342fe24 in handle_one_connection (arg=0x5582f684f4d0) at /data/src/10.3/sql/sql_connect.cc:1308
#18 0x00005582f38ca41d in pfs_spawn_thread (arg=0x5582f6890dc0) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#19 0x00007f4a9c335494 in start_thread (arg=0x7f4a94420700) at pthread_create.c:333
#20 0x00007f4a9a93693f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Test case for `old_part_id == m_last_part' in ha_partition::update_row

--source include/have_partition.inc
--source include/have_innodb.inc
 
CREATE TABLE t1 (pk INT PRIMARY KEY, f INT) ENGINE=InnoDB WITH SYSTEM VERSIONING PARTITION BY KEY() PARTITIONS 2;
INSERT INTO t1 VALUES (1,10),(2,20);
ALTER TABLE t1 DROP SYSTEM VERSIONING;
UPDATE t1 SET f=pk;
 
# Cleanup
DROP TABLE t1;

10.3 95f3c142a

mysqld: /data/src/10.3/sql/ha_partition.cc:4383: virtual int ha_partition::update_row(const uchar*, const uchar*): Assertion `old_part_id == m_last_part' failed.
181202 13:46:42 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fd1840e3ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000560ae9e1f1d9 in ha_partition::update_row (this=0x7fd1280a5d58, old_data=0x7fd1280a7988 "\375\002", new_data=0x7fd1280a7978 "\375\002") at /data/src/10.3/sql/ha_partition.cc:4383
#9  0x0000560ae96c9c3d in handler::ha_update_row (this=0x7fd1280a5d58, old_data=0x7fd1280a7988 "\375\002", new_data=0x7fd1280a7978 "\375\002") at /data/src/10.3/sql/handler.cc:6269
#10 0x0000560ae94bd8ba in mysql_update (thd=0x7fd128000b00, table_list=0x7fd128014db0, fields=..., values=..., conds=0x0, order_num=0, order=0x0, limit=18446744073709551614, handle_duplicates=DUP_ERROR, ignore=false, found_return=0x7fd17d4286f0, updated_return=0x7fd17d4287b0) at /data/src/10.3/sql/sql_update.cc:947
#11 0x0000560ae93c53af in mysql_execute_command (thd=0x7fd128000b00) at /data/src/10.3/sql/sql_parse.cc:4580
#12 0x0000560ae93d07cb in mysql_parse (thd=0x7fd128000b00, rawbuf=0x7fd128014cd8 "UPDATE t1 SET f=pk", length=18, parser_state=0x7fd17d4295f0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:8091
#13 0x0000560ae93bd97f in dispatch_command (command=COM_QUERY, thd=0x7fd128000b00, packet=0x7fd128161121 "UPDATE t1 SET f=pk", packet_length=18, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1850
#14 0x0000560ae93bc3a3 in do_command (thd=0x7fd128000b00) at /data/src/10.3/sql/sql_parse.cc:1395
#15 0x0000560ae95240a0 in do_handle_one_connection (connect=0x560aec343250) at /data/src/10.3/sql/sql_connect.cc:1402
#16 0x0000560ae9523e24 in handle_one_connection (arg=0x560aec343250) at /data/src/10.3/sql/sql_connect.cc:1308
#17 0x0000560ae99be41d in pfs_spawn_thread (arg=0x560aec384b40) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#18 0x00007fd185b9f494 in start_thread (arg=0x7fd17d42a700) at pthread_create.c:333
#19 0x00007fd1841a093f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Comment by Nikita Malyavin [ 2018-12-25 ]

Second time I see how system versioning reveals interesting server's corner cases.
The thing is to catch both rows in same partition:

CREATE OR REPLACE TABLE t1 (pk INT, f INT, primary key(pk, f)) 
    ENGINE=InnoDB PARTITION BY KEY() PARTITIONS 2;
INSERT INTO t1 VALUES (1,10),(2,11);
SELECT * FROM t1 PARTITION (P0);
+----+----+
| pk | f  |
+----+----+
|  1 | 10 |
|  2 | 11 |
+----+----+
ALTER TABLE t1 DROP PRIMARY KEY, DROP F, ADD PRIMARY KEY(PK);
SELECT * FROM t1 PARTITION(P0);
+----+
| pk |
+----+
|  1 |
|  2 |  -- <--- should not be here!!
+----+
2 rows in set (0.001 sec)
 
DELETE FROM t1; # fails

ALTER algorithm is chosen to be INPLACE, which seems to be incorrect since we have to repartition the table.

Comment by Robert Bindar [ 2020-04-02 ]

PR 1336 merged

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