forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add retry option when receiving kBusy on first row after snapshot
Summary: When there is contention on rows that causes kBusy errors if this occurs on the first row since we created a snapshot we can release the snapshot (and iterator) and retry to avoid returning too many deadlock errors. Test Plan: MTR Reviewers: spetrunia, yoshinorim, hermanlee4 Reviewed By: hermanlee4 Subscribers: spetrunia, webscalesql-eng Differential Revision: https://reviews.facebook.net/D54231
- Loading branch information
Showing
9 changed files
with
375 additions
and
221 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
mysql-test/suite/rocksdb/include/rocksdb_concurrent_delete.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Usage: | ||
# | ||
# let $order = ASC; # or DESC | ||
# let $comment = "rev:cf2"; # or "" | ||
# --source suite/rocksdb/include/rocksdb_concurrent_delete.inc | ||
|
||
let $first_row = -1; # Error this should never happen | ||
if ($order == 'ASC') | ||
{ | ||
let $first_row = 1; | ||
} | ||
if ($order == 'DESC') | ||
{ | ||
let $first_row = 3; | ||
} | ||
|
||
connect (con, localhost, root,,); | ||
connection default; | ||
|
||
--disable_warnings | ||
SET debug_sync='RESET'; | ||
DROP TABLE IF EXISTS t1; | ||
--enable_warnings | ||
|
||
eval CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT $comment, a INT); | ||
INSERT INTO t1 VALUES(1,1), (2,2), (3,3); | ||
|
||
# This will cause the SELECT to block after finding the first row, but | ||
# before locking and reading it. | ||
connection con; | ||
SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go'; | ||
send_eval SELECT * FROM t1 order by t1.pk $order FOR UPDATE; | ||
|
||
# While that connection is waiting, delete the first row (the one con | ||
# is about to lock and read | ||
connection default; | ||
SET debug_sync='now WAIT_FOR parked'; | ||
eval DELETE FROM t1 WHERE pk = $first_row; | ||
|
||
# Signal the waiting select to continue | ||
SET debug_sync='now SIGNAL go'; | ||
|
||
# Now get the results from the select. The first entry (1,1) (or (3,3) when | ||
# using reverse ordering) should be missing. Prior to the fix the SELECT | ||
# would have returned: "1815: Internal error: NotFound:" | ||
connection con; | ||
reap; | ||
|
||
# Cleanup | ||
connection default; | ||
disconnect con; | ||
set debug_sync='RESET'; | ||
drop table t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 53 additions & 9 deletions
62
mysql-test/suite/rocksdb/r/rocksdb_concurrent_delete.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,56 @@ | ||
SET debug_sync='RESET'; | ||
DROP TABLE IF EXISTS t1; | ||
CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "", a INT); | ||
INSERT INTO t1 VALUES(1,1), (2,2), (3,3); | ||
SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go'; | ||
SELECT * FROM t1 order by t1.pk ASC FOR UPDATE; | ||
SET debug_sync='now WAIT_FOR parked'; | ||
DELETE FROM t1 WHERE pk = 1; | ||
SET debug_sync='now SIGNAL go'; | ||
pk a | ||
2 2 | ||
3 3 | ||
set debug_sync='RESET'; | ||
drop table if exists t1; | ||
create table t1 (pk int primary key, a int); | ||
insert into t1 values(1,1), (2,2), (3,3); | ||
set debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go'; | ||
select * from t1 for update; | ||
set debug_sync='now WAIT_FOR parked'; | ||
delete from t1 where pk = 1; | ||
set debug_sync='now SIGNAL go'; | ||
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction | ||
drop table t1; | ||
SET debug_sync='RESET'; | ||
DROP TABLE IF EXISTS t1; | ||
CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "", a INT); | ||
INSERT INTO t1 VALUES(1,1), (2,2), (3,3); | ||
SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go'; | ||
SELECT * FROM t1 order by t1.pk DESC FOR UPDATE; | ||
SET debug_sync='now WAIT_FOR parked'; | ||
DELETE FROM t1 WHERE pk = 3; | ||
SET debug_sync='now SIGNAL go'; | ||
pk a | ||
2 2 | ||
1 1 | ||
set debug_sync='RESET'; | ||
drop table t1; | ||
SET debug_sync='RESET'; | ||
DROP TABLE IF EXISTS t1; | ||
CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "rev:cf2", a INT); | ||
INSERT INTO t1 VALUES(1,1), (2,2), (3,3); | ||
SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go'; | ||
SELECT * FROM t1 order by t1.pk ASC FOR UPDATE; | ||
SET debug_sync='now WAIT_FOR parked'; | ||
DELETE FROM t1 WHERE pk = 1; | ||
SET debug_sync='now SIGNAL go'; | ||
pk a | ||
2 2 | ||
3 3 | ||
set debug_sync='RESET'; | ||
drop table t1; | ||
SET debug_sync='RESET'; | ||
DROP TABLE IF EXISTS t1; | ||
CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "rev:cf2", a INT); | ||
INSERT INTO t1 VALUES(1,1), (2,2), (3,3); | ||
SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go'; | ||
SELECT * FROM t1 order by t1.pk DESC FOR UPDATE; | ||
SET debug_sync='now WAIT_FOR parked'; | ||
DELETE FROM t1 WHERE pk = 3; | ||
SET debug_sync='now SIGNAL go'; | ||
pk a | ||
2 2 | ||
1 1 | ||
set debug_sync='RESET'; | ||
drop table t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.