-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[doctrine-messenger] DB table locks on messenger_messages with many failures #52273
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
Labels
Comments
It appears it would affect 6.x as well. |
bn-jdcook
added a commit
to bn-jdcook/symfony
that referenced
this issue
Oct 24, 2023
…ssages with many failures
bn-jdcook
added a commit
to bn-jdcook/symfony
that referenced
this issue
Oct 25, 2023
…ssages with many failures
fabpot
added a commit
that referenced
this issue
Oct 25, 2023
…n-jdcook) This PR was merged into the 5.4 branch. Discussion ---------- DB table locks on messenger_messages with many failures | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #52273 | License | MIT This reorders the query to target the `queue_name` first and not include any `failed` messages in the first part of the `WHERE` clause to help performance. Commits ------- 3245280 fix #52273 [doctrine-messenger] DB table locks on messenger_messages with many failures
fabpot
added a commit
that referenced
this issue
Oct 26, 2023
* 5.4: [5.4] Remove unused test fixtures [Dotent] Add PHPDoc for `$overrideExistingVars` [SecurityBundle] Fix missing login-link element in xsd schema [Validator] Add missing Chinese translations #51934 [Serializer] Fix using `DateIntervalNormalizer` with union types [Validator] fix: add missing translations for for Thai (th) fix #52273 [doctrine-messenger] DB table locks on messenger_messages with many failures [Serializer] Handle defaultContext for DateTimeNormalizer [CI] Add step to verify symfony/deprecation-contracts requirements
fabpot
added a commit
that referenced
this issue
Oct 26, 2023
* 6.3: [6.3] Remove unused test fixture [5.4] Remove unused test fixtures [Dotent] Add PHPDoc for `$overrideExistingVars` [SecurityBundle] Fix missing login-link element in xsd schema [Validator] Add missing Chinese translations #51934 [Serializer] Fix using `DateIntervalNormalizer` with union types [Validator] fix: add missing translations for for Thai (th) fix #52273 [doctrine-messenger] DB table locks on messenger_messages with many failures [Serializer] Handle defaultContext for DateTimeNormalizer declare constructor argument as optional for backwards compatibility [CI] Add step to verify symfony/deprecation-contracts requirements
fabpot
added a commit
that referenced
this issue
Oct 26, 2023
* 6.4: [6.3] Remove unused test fixture [5.4] Remove unused test fixtures [Dotent] Add PHPDoc for `$overrideExistingVars` [SecurityBundle] Fix missing login-link element in xsd schema [Validator] Add missing Chinese translations #51934 replace a not-existing virtual request stack with the real one [Messenger] add handler description as array key to `HandlerFailedException::getWrappedExceptions()` [Serializer] Fix using `DateIntervalNormalizer` with union types [Validator] fix: add missing translations for for Thai (th) fix #52273 [doctrine-messenger] DB table locks on messenger_messages with many failures [Serializer] Handle defaultContext for DateTimeNormalizer declare constructor argument as optional for backwards compatibility [CI] Add step to verify symfony/deprecation-contracts requirements
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected
5.4.25
Description
We are using doctrine-messenger in our project and have noticed a DB lock on the messenger_messages if we have many failed messages due to this query:
SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < '2023-10-24 07:36:16') AND (m.available_at <= '2023-10-24 08:36:16') AND (m.queue_name = 'default') ORDER BY available_at ASC LIMIT 1
andm.delivered_at
is set tonull
when a message is moved to thefailed
queue.How to reproduce
Messenger Config:
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
failure_transport: failed
reset_on_message: true
Failed data:

Query:
SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < '2023-10-24 07:36:16') AND (m.available_at <= '2023-10-24 08:36:16') AND (m.queue_name = 'default') ORDER BY available_at ASC LIMIT 1
Notice the query will first include all with
m.delivered_at is null
which will include all in thefailed
queue. Even if it does not always cause a DB lock on that table, it makes the query unnecessarily slow.Possible Solution
Move the
queue_name
to higher in the where clause.Additional Context
No response
The text was updated successfully, but these errors were encountered: