User A queries a document. User B also query the same document. User A writes to document and commit. Now User B is left with a document JSON that has already been changed by user A. What happens if user B tries to write and save. Does User A transaction will be lost in that case ?
Hi @waseem_shahzad welcome to the community!
I believe you’re talking about multi-document transaction, but correct me if I’m wrong.
So as I understand it, the scenario is as follows:
- A starts a transaction, B also starts a transaction
- A writes to a document and commit
- B tries to write to the same document and commit
If this is correct, then B would see a write conflict error (see In-progress Transactions and Write Conflicts) which I think describes this exact scenario.
- If A & B tries to write to different documents, both will succeed and there won’t be errors .
- If A & B tries to write to different documents, but B relies on something that A previously write (and thus may make the wrong decision), this is a stale read scenario. Please see In-progress Transactions and Stale Reads for more information on how to mitigate this.
Further to your question:
Does User A transaction will be lost in that case
Once a transaction is committed and the client received an acknowledgment, the writes won’t be lost.