Skip to content

Commit 6266493

Browse files
Jimmy Yangdr-m
authored andcommitted
Bug #25729649 LOCK0LOCK.CC:NNN:ADD_POSITION != __NULL
Reviewed-by: Sunny Bains <sunny.bains@oracle.com>
1 parent 4c731a2 commit 6266493

File tree

3 files changed

+96
-2
lines changed

3 files changed

+96
-2
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL);
2+
CREATE SPATIAL INDEX idx1 on tab(c2);
3+
INSERT INTO tab(c1,c2) VALUES(1,ST_GeomFromText('POINT(10 10)'));
4+
5+
# On connection 1
6+
set transaction isolation level serializable ;
7+
START TRANSACTION;
8+
SELECT ST_AsText(c2) FROM tab WHERE MBRWithin(c2, ST_GeomFromText('POLYGON((5 5, 15 5, 15 15, 5 15, 5 5))'));
9+
ST_AsText(c2)
10+
POINT(10 10)
11+
12+
# On connection 2
13+
start transaction;
14+
INSERT INTO tab(c1,c2) VALUES(7, ST_GeomFromText('POINT(11 11)'));;
15+
16+
# On connection 3
17+
include/start_transaction_high_prio.inc
18+
START TRANSACTION /* HIGH PRIORITY */;
19+
INSERT INTO tab(c1,c2) VALUES(8, ST_GeomFromText('POINT(10 10)'));
20+
COMMIT;
21+
22+
# On connection 1
23+
COMMIT;
24+
ERROR HY000: Got error 149 during COMMIT
25+
include/assert.inc ['There is a 8 in tab']
26+
SELECT c1 FROM tab;
27+
c1
28+
1
29+
8
30+
DROP TABLE tab;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Scenario:
2+
# T1=({R(B)})
3+
# T2=({W(B)})
4+
# T3=({W(B), C}, HIGH_PRIORITY).
5+
#
6+
# Outcome: T1 must abort, T2 must commit.
7+
8+
--source include/count_sessions.inc
9+
10+
CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL);
11+
CREATE SPATIAL INDEX idx1 on tab(c2);
12+
INSERT INTO tab(c1,c2) VALUES(1,ST_GeomFromText('POINT(10 10)'));
13+
14+
--connect(con1,localhost,root,,test)
15+
--connect(con2,localhost,root,,test)
16+
--connect(con3,localhost,root,,test)
17+
18+
--echo
19+
--echo # On connection 1
20+
--connection con1
21+
set transaction isolation level serializable ;
22+
START TRANSACTION;
23+
SELECT ST_AsText(c2) FROM tab WHERE MBRWithin(c2, ST_GeomFromText('POLYGON((5 5, 15 5, 15 15, 5 15, 5 5))'));
24+
25+
26+
--echo
27+
--echo # On connection 2
28+
--connection con2
29+
start transaction;
30+
--send INSERT INTO tab(c1,c2) VALUES(7, ST_GeomFromText('POINT(11 11)'));
31+
32+
--echo
33+
--echo # On connection 3
34+
--connection con3
35+
--source include/start_transaction_high_prio.inc
36+
INSERT INTO tab(c1,c2) VALUES(8, ST_GeomFromText('POINT(10 10)'));
37+
COMMIT;
38+
--disconnect con3
39+
40+
--echo
41+
--echo # On connection 1
42+
--connection con1
43+
--error ER_ERROR_DURING_COMMIT
44+
COMMIT;
45+
--disconnect con1
46+
47+
--connection default
48+
--let $assert_text= 'There is a 8 in tab'
49+
--let $assert_cond= [SELECT COUNT(*) AS count FROM tab WHERE tab.c1 = 8, count, 1] = 1
50+
--source include/assert.inc
51+
52+
--connection con2
53+
--reap;
54+
--disconnect con2
55+
56+
--connection default
57+
SELECT c1 FROM tab;
58+
59+
DROP TABLE tab;
60+
61+
--source include/wait_until_count_sessions.inc

storage/innobase/lock/lock0lock.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2014, 2017, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
@@ -2728,7 +2728,10 @@ RecLock::lock_add_priority(
27282728
lock_t* grant_position = NULL;
27292729
lock_t* add_position = NULL;
27302730

2731-
HASH_SEARCH(hash, lock_sys->rec_hash, m_rec_id.fold(), lock_t*,
2731+
/* Different lock (such as predicate lock) are on different hash */
2732+
hash_table_t* lock_hash = lock_hash_get(m_mode);
2733+
2734+
HASH_SEARCH(hash, lock_hash, m_rec_id.fold(), lock_t*,
27322735
lock_head, ut_ad(lock_head->is_record_lock()), true);
27332736

27342737
ut_ad(lock_head);

0 commit comments

Comments
 (0)