You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[This happens only if you remove snapshot cache from repository, but since snapshot cache is probably something that should be removed, this is an issue to take care of.].
Method OpenStream of AbstractRepository stores opened stream in a dictionary whose key is obtained by StreamId and BucketId and this generates error with snapshot.
Consider this sequence of operation on an aggregate that is at version 10
repository.GetById(ID); //no snapshot on disk, Repository opens the stream from 0 to 10
aggregate events are applied, aggregate is at version 10.
a method of aggregate is called, another event is generated.
Save is called and aggregate new event is persisted.
At this moment, since the aggregate is in memory, we could get a snapshot to store in cache. Snapshot is at version 11.
Now with the same instance of the repository issue the GetById(ID) command again and this happens
Repository load the snapshot (
Method OpenStream finds the stream in _streams dictionary cache, so no stream is loaded.
ApplyEventsToAggregate is called, but it uses incorrectly the same stream instance from before, opened at version 0, so all the events are applied to aggregate, causing errors.
A proposed fix is avoiding caching stream inside _stream dictionary with a string key, but using the instance of the aggregate as a key. A stream cached is valid only if the very same instance of aggregate is reused.
The text was updated successfully, but these errors were encountered:
[This happens only if you remove snapshot cache from repository, but since snapshot cache is probably something that should be removed, this is an issue to take care of.].
Method OpenStream of AbstractRepository stores opened stream in a dictionary whose key is obtained by StreamId and BucketId and this generates error with snapshot.
Consider this sequence of operation on an aggregate that is at version 10
At this moment, since the aggregate is in memory, we could get a snapshot to store in cache. Snapshot is at version 11.
Now with the same instance of the repository issue the GetById(ID) command again and this happens
A proposed fix is avoiding caching stream inside _stream dictionary with a string key, but using the instance of the aggregate as a key. A stream cached is valid only if the very same instance of aggregate is reused.
The text was updated successfully, but these errors were encountered: