Unclear error on aborted Firestore transaction

326 views
Skip to first unread message

Shai Ben-Tovim

unread,
Feb 1, 2022, 1:02:37 PM2/1/22
to Firebase Google Group
Hi,

Using Firestore through the server side NodeJS "firebase-admin" SDK.

I have certain documents that get written only through the server side SDK and only using transactions.
My understanding is that in this case each transaction will lock the document until complete and each "waiting" transaction will run in serial sequence.

I can see from time-to-time (not often) this error message being returned by the transaction back to my code:
Error: 10 ABORTED: Aborted due to cross-transaction contention. This occurs when multiple transactions attempt to access the same data, requiring Firestore to abort at least one in order to enforce serializability. 
at Object.callErrorFromStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call.js:31:26) 
at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client.js:327:49) 
at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:305:181) 
at process.nextTick (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:124:78) 

Its unclear to me why the transaction is aborting :
1. This isn't an "internal" transaction abort before retry - this is an error thrown back to my calling function and therefore my understanding that the write transaction has completely failed.
2. My expectation is that it the transaction would wait until it can access the doc and complete.
3. If this was a write throughput issue (it shouldn't be) I'd expect: "Too much contention on these datastore entities"

What are the cases where this specific error is thrown and how can I remedy it?

Thanks.

Reply all
Reply to author
Forward
0 new messages