Skip to content

Exception when deleting messages: SqlTransaction has completed; it is no longer usable #527

@Aaronontheweb

Description

@Aaronontheweb

Version Information
Version of Akka.NET? 1.5.38
Which Akka.NET Modules? Akka.Persistence.Sql

Describe the bug

When running the following code - normal post-snapshot cleanup code:

Command<SaveSnapshotSuccess>(x =>
    {
        DeleteMessages(x.Metadata.SequenceNr - 1);
    }
);

The following exception can sometimes happen:

Failed to DeleteMessages ToSequenceNr [10200] for PersistenceId [change-queue] due to: Exception thrown when rolling back database transaction

The inner exception is:  This SqlTransaction has completed; it is no longer usable.

Expected behavior

Delete operation should complete without error.

Actual behavior

It's racy, but sometimes the delete operation can fail with this exception - looks like a transaction / scope management issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions