Skip to content

Commit 1cad1db

Browse files
committed
MDEV-35235 innodb_snapshot_isolation=ON fails to signal transaction rollback
convert_error_code_to_mysql(): Treat DB_DEADLOCK and DB_RECORD_CHANGED in the same way, that is, signal to the SQL layer that the transaction had been rolled back.
1 parent b3be3c2 commit 1cad1db

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

mysql-test/suite/innodb/r/lock_isolation.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ BEGIN;
134134
INSERT INTO t SET a=2;
135135
connection consistent;
136136
START TRANSACTION WITH CONSISTENT SNAPSHOT;
137+
SAVEPOINT sp1;
137138
SELECT * FROM t FORCE INDEX (b) FOR UPDATE;
138139
ERROR HY000: Record has changed since last read in table 't'
140+
SAVEPOINT sp1;
139141
connection con_weird;
140142
START TRANSACTION WITH CONSISTENT SNAPSHOT;
141143
SELECT * FROM t FORCE INDEX (b) FOR UPDATE;
@@ -155,3 +157,4 @@ a b
155157
disconnect consistent;
156158
connection default;
157159
DROP TABLE t;
160+
# End of 10.6 tests

mysql-test/suite/innodb/t/lock_isolation.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ BEGIN; INSERT INTO t SET a=2;
152152

153153
--connection consistent
154154
START TRANSACTION WITH CONSISTENT SNAPSHOT;
155+
SAVEPOINT sp1;
155156
--disable_ps2_protocol
156157
--error ER_CHECKREAD
157158
SELECT * FROM t FORCE INDEX (b) FOR UPDATE;
158159
--enable_ps2_protocol
160+
SAVEPOINT sp1;
159161

160162
--connection con_weird
161163
START TRANSACTION WITH CONSISTENT SNAPSHOT;
@@ -181,3 +183,5 @@ SELECT * FROM t FORCE INDEX (b) FOR UPDATE;
181183

182184
--connection default
183185
DROP TABLE t;
186+
187+
--echo # End of 10.6 tests

storage/innobase/handler/ha_innodb.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,7 @@ convert_error_code_to_mysql(
22342234
return(HA_ERR_NO_ACTIVE_RECORD);
22352235

22362236
case DB_DEADLOCK:
2237+
case DB_RECORD_CHANGED:
22372238
/* Since we rolled back the whole transaction, we must
22382239
tell it also to MySQL so that MySQL knows to empty the
22392240
cached binlog for this transaction */
@@ -2242,10 +2243,8 @@ convert_error_code_to_mysql(
22422243
thd_mark_transaction_to_rollback(thd, 1);
22432244
}
22442245

2245-
return(HA_ERR_LOCK_DEADLOCK);
2246-
2247-
case DB_RECORD_CHANGED:
2248-
return HA_ERR_RECORD_CHANGED;
2246+
return error == DB_DEADLOCK
2247+
? HA_ERR_LOCK_DEADLOCK : HA_ERR_RECORD_CHANGED;
22492248

22502249
case DB_LOCK_WAIT_TIMEOUT:
22512250
/* Starting from 5.0.13, we let MySQL just roll back the

0 commit comments

Comments
 (0)