Skip to content

Akka.Persistence.Query.TCK Bug: TestActor acknowledges delete whether it actually happened or not #3935

@Aaronontheweb

Description

@Aaronontheweb

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:

[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 TestActor in the Akka.Persistence.Query.TCK

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions