In the sample code below, what will happen if retrieved data in the transaction changes caused by a outside/separated write operation before the transaction end or committed? does transaction automatically aborted?
await session.withTransaction(async () => {
const coll1 = client.db('mydb1').collection('foo');
await coll1.find( { qty: { $gt: 4 } }, { session } );
// some code before update
// if the retrieved data from the above, changed due to a separate write(separate session/transaction) will this transaction abort?
await coll1.update(
{ id: 3 },
{ $set: { qty: 2 } },
{ session }
)
}, transactionOptions);
I read the documentation about transaction, to my understanding it mostly offer data atomicity and durability, but I can’t find any what will happen to a transaction if any read data changed caused by outside/separate write operation