Skip to content

eventsByTag may sometimes skip some events when more than 1 database thread is used #96

@WellingR

Description

@WellingR

This issue occurred on version 2.4.17.1

In an actor system where several actors concurrently persist events with the same tag. The following issue may occur whenever multiple database threads are used:

Suppose that two database threads are concurrently writing an event. Thread 1 writes event A and thread 2 writes event B. Events A and B are written by different persistent actors, but they both have the same tag.

The database (I use Postgres) generates the sequence number for the ordering column. However it does not guarantee that the sequence number are visible in the order of the number.

What can happen is that event A get sequence number 1 and event B gets sequence number 2. However event B is visible in the database before event A.
eventsByTag is implemented by repeatedly querying the database. Therefore it may happen that an eventsByTag query (at offset 0) results in event B while event A has never been seen before.

At this point the implementation of eventsByTag assumes that all events with a sequence number equal to or lower than 2 (the sequence number of event B) either do not match the tag, or have been returned by the query before. This was not the case because event A was not yet visible in the database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions