Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I mentioned that it'd be quite simple to add MongoDB transactions in #9898 - so I decided to try it, even if it's not ideal when it comes to consistency.
I think I handled all parts of MongoDB driver where multiple writes occur (since single operations are atomic anyway).
Transactions only work on replica sets on a version newer than MongoDB 4.0, unfortunately. On singular instances nothing improves in terms of consistency. As such the current tests never take the transaction path - and to change that would require adding another entry to test matrix for newer replica set MongoDB.
If it's fine to do so, I'll be glad to update this PR to have testing done properly for replica sets, but currently I just made a separate branch with all mongo tests modified to use replica sets: https://github.com/oplik0/NodeBB/actions/runs/1351224224
Edit: also now tested different mongo versions with replica set enabled: