-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Version: v1.4.0-beta2
Found this while investigating akkadotnet/Akka.Persistence.MongoDB#77 (comment)
Issue is this:
Error in this case appears to be a stale read coming from the MongoDB journal:
akka.net/src/core/Akka.Persistence.TCK/Query/CurrentEventsByPersistenceIdSpec.cs
Lines 113 to 127 in 4f984bc
[Fact] public virtual void ReadJournal_CurrentEventsByPersistenceId_should_return_remaining_values_after_partial_journal_cleanup() { var queries = ReadJournal.AsInstanceOf<ICurrentEventsByPersistenceIdQuery>(); var pref = Setup("h"); pref.Tell(new TestActor.DeleteCommand(2)); AwaitAssert(() => ExpectMsg("2-deleted")); var src = queries.CurrentEventsByPersistenceId("h", 0L, long.MaxValue); src.Select(x => x.Event).RunWith(this.SinkProbe<object>(), Materializer) .Request(1) .ExpectNext("h-3") .ExpectComplete(); } Setup writes 3 events to the journal - arrange phase of the test deletes the first two - assertion expects only the third one back. Instead we got the first event straight away.
Sounds to me like Mongo being Mongo, but I'll take a look real fast.
And determined cause:
Ah, the problem is actually with the
TestActorin the Akka.Persistence.Query.TCKakka.net/src/core/Akka.Persistence.TCK/Query/TestActor.cs
Lines 44 to 47 in 4f984bc
case DeleteCommand delete: DeleteMessages(delete.ToSequenceNr); Sender.Tell($"{delete.ToSequenceNr}-deleted"); break; We send a reply back that the message has been deleted without actually knowing if the journal has done that or not.
Proposed fix: Probably need to wait until we get a DeleteMessagesSuccess or a DeleteMessagesFailure message back, since DeleteMessages(long seqNo) is an asynchronous operation.