Race condition in AutoIncrementTracker can cause two transactions to get assigned the same auto-incrementing ID. #7702
Labels
bug
Something isn't working
concurrency
Issues relating to concurrent access to Dolt
good repro
Easily reproducible bugs
AUTO INCREMENT
is supposed to be unaffected by transactions: not-yet-committed transactions can still advance the counter, and rolling back a transaction does not reset the counter. This allows two concurrent transactions to both insert into the same table with anAUTO INCREMENT
column without causing a transaction conflict.Unfortunately, it appears that in rare cases we can generate the same ID for two concurrent transactions, causing a conflict for whichever transaction commits second.
I was only able to get this to reproduce when the insertion was happening as the result of a trigger.
Steps to reproduce:
There is a high likelihood that one of the transactions will fail. By comparing both transactions versions of the
timestamps
table, we can see that a small fraction of the primary keys appear in both tables. (Out of the 2048 inserts that this script makes, there are usually anywhere in the range of 1-7 duplicates.)The text was updated successfully, but these errors were encountered: