So the cloud firestore's admin SDK documentation states that a transaction holds a pessimistic lock on all documents being read inside it. Which means that during this locked period (moment from when the document was fetched to when the transaction is committed), any updates to the locked documents outside of the transaction itself will get rejected instead of the transaction being retried.
Now what happens when let's say at time t1 a transaction T1 reads (and thus locks) a document d1, while at a later time t2 another transaction T2 tries to read the same document d1 while the first transaction T1 is still running and is not yet committed?
- Will the second transaction T2 will just fail upright?
- The documentation suggests that during the locked period updates to the document will get rejected but not reads. So will that be a case that T2 does not fails upright, but when it tries to perform a write operation on the document d1 it fails as this update operation is outside the transaction T1?
- If my 2nd assumption is correct, then is it possible to run both transactions T1 and T2 simultaneously on the same document d1 successfully, providing that either T2 does not even modify document d1 (it is only a read transaction for d1) or when it performs write operations on d2, the transaction T1 has already been committed?