Deadlock at COMMIT
Your application reports ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction, and the statement that failed is COMMIT.
Why it happens#
Scuttle replicates synchronously and resolves write conflicts optimistically. When two transactions change the same rows at the same time, the one that commits second fails certification and is rolled back with a deadlock error. Nothing is wrong with the cluster, and no data was lost.
Fix#
Retry the whole transaction. The pattern and the list of retryable errors are in Retrying transactions. Most ORMs and frameworks have a retry hook for 40001 serialization failures — enable it.
If it happens often#
Frequent conflicts mean many transactions compete for the same rows: a counter row, a queue table polled by many workers, or long transactions. Shorten the transactions, shard the hot row, or serialise that piece of work in the application.