Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
11.8.3
-
None
-
None
Description
With innodb_snapshot_isolation=ON, inserting a new record that references a not-yet-visible record via a foreign key constraint causes an error:
ERROR 1020 (HY000): Record has changed since last read in table '(inserted table)'
This error mentions the wrong table: The changed table is the one referenced by the foreign key constaint, not the one the current INSERT operates on. This is misleading and causes confusion when debugging.
The error can be recreated with these statements:
-- Tables
|
create table RecordChange1 (id int primary key); |
create table RecordChange2 (id2 int primary key, fk int references RecordChange1 (id)); |
|
-- Connection 1
|
start transaction; |
select * from RecordChange1; |
-- continue later...
|
|
-- Concurrent Connection 2
|
start transaction; |
insert into RecordChange1 (id) values (1); |
commit; |
|
-- Continue in Connection 1
|
insert into RecordChange2 (id2, fk) values (2, 1); |
-- ERROR 1020 (HY000): Record has changed since last read in table 'RecordChange2' |
Note that the error message mentions RecordChange2, but the changed record is actually in RecordChange1.
Attachments
Issue Links
- relates to
-
MDEV-35124 Set innodb_snapshot_isolation=ON by default
-
- Closed
-