Repository navigation
fix: mongodb multiple error rollback transaction - #4245
DanRibbens wants to merge 1 commit into
Conversation
This sounds very strange to me. Only one operation should be responsible for rolling back or committing the transaction, right? How is After cloning the reproduction repository from #4133 I saw that it was using Payload 2.1.1, which does not include #4164. In that reproduction I am seeing seeing an issue in commitTransaction, called from the When updating the reproduction repo to Payload 2.2.1, the reported issue goes away. After all this: What exactly is this now fixing, if not #4133? :D |
I'm firing off two
This is all great. I am glad that your changes addressed #4133. The other thing this PR does is prevent |
I'm sorry to keep going about this, but I would rather we get this correct. If I understand everything correctly, the test case you linked will never roll back a transaction and if this test passes (with transactions enabled) then we have a bug (or I have a fundamental misunderstanding).
|
Yup, this is exactly what the test is doing: This is how synchronous operations should be handled and now there is a test case for it. Without the changes to rollbackTransaction this test was hanging indefinitely.
I did have @diesieben07 are you against merging this PR, do you see it causing other issues? EDIT: I didn't see your reply above:
This test case does rollback and the test passes. It is encapsulating multiple changes in one transaction. I think you maybe missed that. |
|
Okay... I found both my misunderstanding and the bug. All operations unconditionally call Consider the scenario from your test case, where multiple operations run concurrently within the same transaction. Neither of them is "in charge" of the transaction, it was started before (like in your test case). Now one of the operations encounters an error and calls Edit: Sorry for just removing my earlier reply. I had hoped I was quick enough so it wouldn't be seen. I was entirely mistaken in that reply, so I deleted it. |
Description
fixes #4133
When one transaction is used where multiple operations error, the result is that rollbackTransaction is called more than once. If this is happening async the second call to rollbackTransaction would hang on
await sessions[id].abortTransaction().This change makes it non-blocking and the function will not error when called multiple times.
PR also hs a type change to in Payload so the database interface allows the return type for rollbackTransaction to not be async.
Type of change
Checklist: