Skip to content

Commit 30bc04f

Browse files
author
Bin Su
committed
BUG#26553164 - INNODB PARTITION TABLE HAS UNEXPECTED ROW LOCK
This is similar issue to bug#26731025, the only difference is that this one is for ordered index scan, while the other one is for unordered index scan. The cause is same too, that is for the equal range scan, it used to call improper read_range* function and set an incorrect lock to the record, which leads to the final lock waiting. The fix is that for equal range scan, call the proper index_next_same_in_part() to set a proper record to previous locking waiting. RB: 19528 Reviewed-by: Debarun Banerjee (debarun.banerjee@oracle.com)
1 parent f8220e8 commit 30bc04f

File tree

3 files changed

+86
-11
lines changed

3 files changed

+86
-11
lines changed

mysql-test/r/partition_innodb.result

+33
Original file line numberDiff line numberDiff line change
@@ -1334,3 +1334,36 @@ TABLE_NAME = 't1' ORDER BY PARTITION_ORDINAL_POSITION;
13341334
TABLE_NAME COUNT(UPDATE_TIME)
13351335
t1 1
13361336
DROP TABLE t1;
1337+
1338+
BUG#26553164 - INNODB PARTITION TABLE HAS UNEXPECTED ROW LOCK
1339+
1340+
CREATE TABLE `t1` (
1341+
`id` int(11) NOT NULL,
1342+
`dt` datetime NOT NULL,
1343+
`data` varchar(10) DEFAULT NULL,
1344+
PRIMARY KEY (`id`,`dt`),
1345+
KEY `idx_dt` (`dt`)
1346+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1347+
/*!50100 PARTITION BY RANGE (to_days(dt))
1348+
(PARTITION p20170218 VALUES LESS THAN (736744) ENGINE = InnoDB,
1349+
PARTITION p20170219 VALUES LESS THAN (736745) ENGINE = InnoDB,
1350+
PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */;
1351+
INSERT INTO t1 VALUES (1, '2018-04-25 10:18:00', '1');
1352+
INSERT INTO t1 VALUES (2, '2018-04-25 10:18:01', '2');
1353+
INSERT INTO t1 VALUES (3, '2018-04-25 10:18:02', '3');
1354+
SELECT * FROM t1;
1355+
id dt data
1356+
1 2018-04-25 10:18:00 1
1357+
2 2018-04-25 10:18:01 2
1358+
3 2018-04-25 10:18:02 3
1359+
begin;
1360+
UPDATE t1 SET data = '11' WHERE id = 1;
1361+
begin;
1362+
UPDATE t1 SET data = '22' WHERE id = 2;
1363+
commit;
1364+
SELECT * FROM t1;
1365+
id dt data
1366+
1 2018-04-25 10:18:00 11
1367+
2 2018-04-25 10:18:01 22
1368+
3 2018-04-25 10:18:02 3
1369+
DROP TABLE t1;

mysql-test/t/partition_innodb.test

+42
Original file line numberDiff line numberDiff line change
@@ -1319,3 +1319,45 @@ FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA = 'test' AND
13191319
TABLE_NAME = 't1' ORDER BY PARTITION_ORDINAL_POSITION;
13201320

13211321
DROP TABLE t1;
1322+
1323+
1324+
--echo
1325+
--echo BUG#26553164 - INNODB PARTITION TABLE HAS UNEXPECTED ROW LOCK
1326+
--echo
1327+
1328+
--connect (conn1,localhost,root,,)
1329+
1330+
--connection default
1331+
1332+
CREATE TABLE `t1` (
1333+
`id` int(11) NOT NULL,
1334+
`dt` datetime NOT NULL,
1335+
`data` varchar(10) DEFAULT NULL,
1336+
PRIMARY KEY (`id`,`dt`),
1337+
KEY `idx_dt` (`dt`)
1338+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1339+
/*!50100 PARTITION BY RANGE (to_days(dt))
1340+
(PARTITION p20170218 VALUES LESS THAN (736744) ENGINE = InnoDB,
1341+
PARTITION p20170219 VALUES LESS THAN (736745) ENGINE = InnoDB,
1342+
PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */;
1343+
1344+
INSERT INTO t1 VALUES (1, '2018-04-25 10:18:00', '1');
1345+
INSERT INTO t1 VALUES (2, '2018-04-25 10:18:01', '2');
1346+
INSERT INTO t1 VALUES (3, '2018-04-25 10:18:02', '3');
1347+
1348+
SELECT * FROM t1;
1349+
1350+
begin;
1351+
UPDATE t1 SET data = '11' WHERE id = 1;
1352+
1353+
--connection conn1
1354+
begin;
1355+
UPDATE t1 SET data = '22' WHERE id = 2;
1356+
commit;
1357+
1358+
--disconnect conn1
1359+
1360+
--connection default
1361+
SELECT * FROM t1;
1362+
1363+
DROP TABLE t1;

sql/partitioning/partition_handler.cc

+11-11
Original file line numberDiff line numberDiff line change
@@ -3530,20 +3530,20 @@ int Partition_helper::handle_ordered_next(uchar *buf, bool is_next_same)
35303530
else
35313531
read_buf= rec_buf;
35323532

3533-
3534-
if (m_index_scan_type == PARTITION_READ_RANGE)
3535-
{
3536-
error= read_range_next_in_part(part_id,
3537-
read_buf == m_table->record[0]
3538-
? NULL : read_buf);
3539-
}
3540-
else if (!is_next_same)
3541-
error= index_next_in_part(part_id, read_buf);
3542-
else
3543-
error= index_next_same_in_part(part_id,
3533+
if (is_next_same) {
3534+
error = index_next_same_in_part(part_id,
35443535
read_buf,
35453536
m_start_key.key,
35463537
m_start_key.length);
3538+
} else if (m_index_scan_type == PARTITION_READ_RANGE) {
3539+
error = read_range_next_in_part(part_id,
3540+
read_buf == m_table->record[0]
3541+
? NULL : read_buf);
3542+
}
3543+
else {
3544+
error = index_next_in_part(part_id, read_buf);
3545+
}
3546+
35473547
if (error)
35483548
{
35493549
if (error == HA_ERR_END_OF_FILE)

0 commit comments

Comments
 (0)