Updated GetSnapshot method#484
Updated GetSnapshot method#484akg179 wants to merge 1 commit intoNEventStore:developNEventStore/NEventStore:developfrom
Conversation
Currently, if two or more snapshots are added for a stream with same streamRevision using AddSnapshot method, both of them will be stored in the `_snapshots` collection. While retrieving snapshot for that streamRevision, the one which was added earlier in time will be returned from `GetSnapshot`. I follow the MongoDB persistence engine and observe that `AddSnapshot` does an `update` instead of persisting all snapshots with same `streamId` and `streamRevision`. https://github.com/NEventStore/NEventStore.Persistence.MongoDB/blob/master/src/NEventStore.Persistence.MongoDB/MongoPersistenceEngine.cs#L515 Therefore, the InMemory persistence behaves differently when compared to MongoDB persistence. With this change, the GetSnapshot has been modified to give the most recent added snapshot when there are more than one snapshots for same streamId and streamRevision.
|
Hi, adding multiple snapshots for the same tuple of bucketId, streamId, streamRevision should not be allowed. I'll write a test to confirm the bug and fix the behavior. |
|
I double checked the behavior, actually it's up to the driver implementation decide what to do when adding more than one snapshot with the same tuple. |
|
I have decided to not break the original behavior of the InMemoryPersistence and follow the Sql implementation for this provider. I also added a test that checks the correct behavior of the provider: Thanks for reporting the Issue, I'm closing this PR. |
Also update the netcoreapp2.1 to netcoreapp3.1 for test projects.
Currently, if two or more snapshots are added for a stream with same streamRevision using AddSnapshot method, both of them will be stored in the
_snapshotscollection. While retrieving snapshot for that streamRevision, the one which was added earlier in time will be returned fromGetSnapshot.I follow the MongoDB persistence engine and observe that
AddSnapshotdoes an update instead of persisting all snapshots with samestreamIdandstreamRevision.Therefore, the InMemory persistence behaves differently when compared to MongoDB persistence.
With this change, the
GetSnapshothas been modified to give the most recent added snapshot when there are more than one snapshots for same streamId and streamRevision.