Skip to content

Commit a8eae88

Browse files
minggrinikep
authored andcommitted
Ignore setting m_lock_rows if lock_type == TL_IGNORE (facebook#871) (facebook#871)
Summary: Original report: https://jira.mariadb.org/browse/MDEV-15816 To reproduce this bug just following below steps, client 1: USE test; CREATE TABLE t1 (i INT) ENGINE=MyISAM; HANDLER t1 OPEN h; CREATE TABLE t2 (i INT) ENGINE=RocksDB; LOCK TABLES t2 WRITE; client 2: FLUSH TABLES WITH READ LOCK; client 1: INSERT INTO t2 VALUES (1); So client 1 acquired the lock and set m_lock_rows = RDB_LOCK_WRITE. Then client 2 calls store_lock(TL_IGNORE) and m_lock_rows was wrongly set to RDB_LOCK_NONE, as below ``` #0 myrocks::ha_rocksdb::store_lock (this=0x7fffbc03c7c8, thd=0x7fffc0000ba0, to=0x7fffc0011220, lock_type=TL_IGNORE) #1 get_lock_data (thd=0x7fffc0000ba0, table_ptr=0x7fffe84b7d20, count=1, flags=2) #2 mysql_lock_abort_for_thread (thd=0x7fffc0000ba0, table=0x7fffbc03bbc0) #3 THD::notify_shared_lock (this=0x7fffc0000ba0, ctx_in_use=0x7fffbc000bd8, needs_thr_lock_abort=true) #4 MDL_lock::notify_conflicting_locks (this=0x555557a82380, ctx=0x7fffc0000cc8) #5 MDL_context::acquire_lock (this=0x7fffc0000cc8, mdl_request=0x7fffe84b8350, lock_wait_timeout=2) #6 Global_read_lock::lock_global_read_lock (this=0x7fffc0003fe0, thd=0x7fffc0000ba0) ``` Finally, client 1 "INSERT INTO..." hits the Assertion 'm_lock_rows == RDB_LOCK_WRITE' failed in myrocks::ha_rocksdb::write_row() Fix this bug by not setting m_locks_rows if lock_type == TL_IGNORE. Closes facebook#838 Pull Request resolved: facebook#871 Differential Revision: D9417382 Pulled By: lth
1 parent ad288cf commit a8eae88

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

Diff for: mysql-test/suite/rocksdb/r/lock.result

+15
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,18 @@ SELECT a,b FROM t1;
106106
a b
107107
UNLOCK TABLES;
108108
DROP TABLE t1, t2;
109+
CREATE TABLE t1 (i INT) ENGINE=MyISAM;
110+
HANDLER t1 OPEN h;
111+
CREATE TABLE t2 (i INT) ENGINE=RocksDB;
112+
LOCK TABLES t2 WRITE;
113+
connect con1,localhost,root,,test;
114+
connection con1;
115+
FLUSH TABLES WITH READ LOCK;
116+
connection default;
117+
INSERT INTO t2 VALUES (1);
118+
UNLOCK TABLES;
119+
HANDLER h CLOSE;
120+
connection con1;
121+
disconnect con1;
122+
connection default;
123+
DROP TABLE t1, t2;

Diff for: mysql-test/suite/rocksdb/t/lock.test

+22
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,28 @@ SELECT a,b FROM t1;
196196
UNLOCK TABLES;
197197
DROP TABLE t1, t2;
198198

199+
CREATE TABLE t1 (i INT) ENGINE=MyISAM;
200+
HANDLER t1 OPEN h;
201+
CREATE TABLE t2 (i INT) ENGINE=RocksDB;
202+
LOCK TABLES t2 WRITE;
203+
204+
--connect (con1,localhost,root,,test)
205+
--connection con1
206+
--send
207+
FLUSH TABLES WITH READ LOCK;
208+
209+
--connection default
210+
INSERT INTO t2 VALUES (1);
211+
UNLOCK TABLES;
212+
HANDLER h CLOSE;
213+
214+
--connection con1
215+
--reap
216+
--disconnect con1
217+
218+
--connection default
219+
DROP TABLE t1, t2;
220+
199221
# Check that all connections opened by test cases in this file are really
200222
# gone so execution of other tests won't be affected by their presence.
201223
--source include/wait_until_count_sessions.inc

Diff for: storage/rocksdb/ha_rocksdb.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -10402,7 +10402,7 @@ THR_LOCK_DATA **ha_rocksdb::store_lock(THD *const thd, THR_LOCK_DATA **to,
1040210402
m_lock_rows = RDB_LOCK_WRITE;
1040310403
} else if (lock_type == TL_READ_WITH_SHARED_LOCKS) {
1040410404
m_lock_rows = RDB_LOCK_READ;
10405-
} else {
10405+
} else if (lock_type != TL_IGNORE) {
1040610406
m_lock_rows = RDB_LOCK_NONE;
1040710407
if (THDVAR(thd, lock_scanned_rows)) {
1040810408
/*

0 commit comments

Comments
 (0)