firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Firestore emulator problem when 2 transactions in parallel are creating same document

Open panky98 opened this issue 1 year ago • 2 comments

[REQUIRED] Environment info

firebase-tools: 12.9.1

Platform: Windows 10

[REQUIRED] Test case

When executing same transaction completely in parallel (2 executions going in parallel), if both transactions are creating a same document then neither transaction is going to succeed, both transactions fail.

Error which both transactions receive: (StatusCode="Aborted", Detail="Transaction lock timeout.")

[REQUIRED] Steps to reproduce

Execute 2 transactions in parallel which are creating the same document in a same collection.

Transaction configuration: Only 1 attempt

[REQUIRED] Expected behavior

At least one transaction to succeed.

[REQUIRED] Actual behavior

Neither transaction succeed.

panky98 avatar Feb 09 '24 11:02 panky98

Hey @panky98, thanks for reporting this. I'll pass this along to the Firestore emulator owners to take a look. However, this behavior is within expectations for the emulator suite - it is not meant for production use and we cannot guarantee correct behavior under load or parallel use.

joehan avatar Feb 13 '24 18:02 joehan

Hello @joehan, you're welcome! I understand, it is not in use on production, of course, we were just using it for some test case which is simualting production situation(so we can be sure that our code guarantees synchronization) in which 2 transactions are executed almost conpletely in parallel (few ms between those). :-)

I hope that problem can be solved.

panky98 avatar Feb 14 '24 05:02 panky98