Skip to content

Race conditions in transactions with SyncIndexWithObjectChangeListener #902

Description

@sneakyvv

The issue is that during a long or nested transaction, the sendUpdateIndexMessage() is called during a postPersist event, while the data may not yet be available in the database. The subsequent processing of the sent message (Doctrine/Queue/SyncIndexWithObjectChangeProcessor.php line 87) does not find the object and will send a delete command to Elastic instead of an insert.

This happens for example during a Doctrine fixtures load, which is actually several flushes inside nested transactions, but I have also seen it happen during a simple request (with queued processing). The problem is that the message is sent before the $conn->commit() is done in the (outer-)transaction's flush call. So none of the Doctrine lifecycle events is gonna guarantee there will be no race conditions.

The solution imo is to allow the message to be delivered with a delay.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions