client-rust icon indicating copy to clipboard operation
client-rust copied to clipboard

What is the cause of the error "PessimisticLock error: MultipleKeyErrors([KeyError(KeyError { locked: None, retryable: "Error(Txn(Error(Mvcc(Error(WriteConflict"..."?

Open HughPenn opened this issue 8 months ago • 2 comments

What is the cause of the error "PessimisticLock error: MultipleKeyErrors([KeyError(KeyError { locked: None, retryable: "Error(Txn(Error(Mvcc(Error(WriteConflict"..."? After this error occurs, does it mean the entire transaction was not executed, and the database state remains the same as before the transaction? Is there any solution to this?

Image

HughPenn avatar Apr 11 '25 02:04 HughPenn

What is the cause of the error

There was another transaction with start timestamp of conflict_ts and commit timestamp of conflict_commit_ts modified data after current transaction started.

After this error occurs, does it mean the entire transaction was not executed

Yes.

and the database state remains the same as before the transaction?

No, another transaction change the database.

Is there any solution to this?

Up to your business. E.g, if your business do a = a + 1, you need to retry from start a new transaction, read the a, then modify and commit again.

pingyu avatar Apr 11 '25 02:04 pingyu

I'm using pessimistic transactions. Aren't pessimistic transactions supposed to acquire locks and prevent write conflicts? @pingyu

HughPenn avatar Apr 11 '25 02:04 HughPenn