Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the transaction has succeeded before indexing or removing objects #385

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lemonlab
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Related Issue none
Need Doc update no

Describe your change

Index and remove objects during the postFlush event to ensure the transaction has succeeded.

What problem is this fixing?

The postUpdate and postPersist events are triggered after the database operations on entity data but before the transaction has been committed.
https://www.doctrine-project.org/projects/doctrine-orm/en/3.3/reference/events.html#postupdate-postremove-postpersist

If the transaction fails, the object could be indexed in Algolia without the corresponding database change, causing desynchronization between the database and Algolia. By indexing or removing objects in the postFlush event, we ensure that the transaction has succeeded first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant