Akka.Persistence.MongoDB icon indicating copy to clipboard operation
Akka.Persistence.MongoDB copied to clipboard

Fix journal and snapshot write atomicity

Open Arkatufus opened this issue 7 months ago • 0 comments

Two issues are addressed:

  1. Right now, all write operations were done under transactions, if write transaction feature flag is turned on. But according to the MongoDb documentation, single document write or updates are already atomic and does not need to be enclosed inside a transaction.
  2. Right now, when we do a bulk atomic write WriteMessagesAsync(), we're atomically writing each collection payload under separate transactions, which is wrong, the correct way is to cover all of the writes under a single transaction so that they can be written atomically.

Changes

  • Add non-transactioned single document write optimization to snapshot store and journal
  • Refactor WriteMessagesAsync() to use a single transaction for its entire bulk write operation.

Arkatufus avatar Mar 27 '25 15:03 Arkatufus