-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
8000
4.4-7.1
Using a master-master mysql replica, a couple of transports with different queue_name-s and separate consumers by transports, it can easily happen that the cleanup statements will result in replication error due to preventable race-conditions.
If we run distinct consumers against the replicated dbs, it should not happen, if the cleanup queries would filter for the queue name. Currently every consumer deletes old records even from unrelated queues.
I know that we could workaround this problem with separate tables, but I think it might be a nice and correct addition for the current implementation.
The current implementation does not filter for the 'queu_name', but it should:
- $this->driverConnection->delete($this->configuration['table_name'], ['delivered_at' => '9999-12-31 23:59:59']);
+ $this->driverConnection->delete($this->configuration['table_name'], ['delivered_at' => '9999-12-31 23:59:59', 'queue_name' => $this->configuration['queue_name']]);
# messenger.yaml
# ...
transports:
job_a:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%?queue_name=job_a'
job_b:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%?queue_name=job_b'
Do the cleanup only for the configured queue_name.
In Symfony\Component\Messenger\Bridge\Doctrine\Transport::get
- $this->driverConnection->delete($this->configuration['table_name'], ['delivered_at' => '9999-12-31 23:59:59']);
+ $this->driverConnection->delete($this->configuration['table_name'], ['delivered_at' => '9999-12-31 23:59:59', 'queue_name' => $this->configuration['queue_name']]);
We experienced this issue with symfony 4.4, but I can see from the code that it still works the same way.