-
Notifications
You must be signed in to change notification settings - Fork 440
Race conditions in transactions with SyncIndexWithObjectChangeListener #902
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
Comments
I encountered the same problem. I agree with @sneakyvv 's explanation. In PostPersist/PostUpdate, the DB transaction is not necessarily completed. Unless I'm mistaken, there is indeed the usable Doctrine doc:
In
IMO, the solution with |
Even the flush event cannot help during nested transactions. Every So, I guess this is a Doctrine issue (too?). |
There are two problems (or contexts):
For the first problem, I think that enqueue-elastica should at least follow the implementation of FosElasticaBundle (see: For the second, you're right. Doctrine events cannot help during nested transactions. It does not emit a |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The issue is that during a long or nested transaction, the
sendUpdateIndexMessage()
is called during apostPersist
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.
The text was updated successfully, but these errors were encountered: