Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Clone in Desktop Download ZIP

Loading…

Release row locks on statement errors #57

Closed
yoshinorim opened this Issue · 2 comments

2 participants

@yoshinorim
Owner

Client 1:
mysql> create table t1 (id int primary key) engine=rocksdb;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values (1), (2), (3);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values (4), (5), (6);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> insert into t1 values (7), (8), (2), (9);
ERROR 1062 (23000): Duplicate entry '2' for key 'PRIMARY'
mysql> select * from t1;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
+----+
6 rows in set (0.00 sec)

Then start client 2:
mysql> begin;
Query OK, 0 rows affected (0.00 sec)
1) mysql> select * from t1 where id=4 for update;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
2) mysql> select * from t1 where id=7 for update;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
3) mysql> select * from t1 where id=9 for update;
Empty set (0.00 sec)

1) was expected. 3) was also expected. But 2) was not desired behavior since client 1 failed the statement, and row id=7 didn't exist. In InnoDB, locking reads on id=7 succeeds.

@spetrunia spetrunia self-assigned this
@spetrunia spetrunia referenced this issue from a commit
@spetrunia spetrunia Issue #57: Release row locks on statement errors
Summary:
Do exactly that: remember what locks we've held at the start of the
statement, and release all other locks if the statement is rolled back.

Test Plan: Ran mtr

Reviewers: maykov, jtolmer, yoshinorim, hermanlee4

Reviewed By: hermanlee4

Differential Revision: https://reviews.facebook.net/D38313
7f7c355
@spetrunia
Collaborator

Pushed

@spetrunia spetrunia closed this
@spetrunia spetrunia referenced this issue from a commit
@spetrunia spetrunia Issue #57: Release row locks on statement errors
Summary:
Do exactly that: remember what locks we've held at the start of the
statement, and release all other locks if the statement is rolled back.

Test Plan: Ran mtr

Reviewers: maykov, jtolmer, yoshinorim, hermanlee4

Reviewed By: hermanlee4

Differential Revision: https://reviews.facebook.net/D38313
4ade4bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.