Skip to content

[Messenger] run "ping database connection" Doctrine middleware with the new alarm based event #60109

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

Open
dkarlovi opened this issue Apr 1, 2025 · 1 comment

Comments

@dkarlovi
Copy link
Contributor

dkarlovi commented Apr 1, 2025

Symfony version(s) affected

7.3.x

Description

Let's assume you're not using Doctrine as your Messenger transport, but you are using Doctrine ORM.

The latest alarm based features added by @HypeMC in #53533 and #53508 provided a way to refresh the transports, and this got expanded to Doctrine too in #59601.

But, the Doctrine middleware is does not honor this and Doctrine will only get refreshed by the alarm if you're using Doctrine as your Messenger transport too.

Example:

  1. use Beanstalk (or any other transport except Doctrine) as your Messenger transport
  2. use Doctrine ORM as usual, enable the middleware
  3. message comes in, Doctrine middleware runs to refresh the connection
  4. processing the message takes say 10min
  5. the alarm keeps triggering and the Beanstalk connection is getting refreshed, but not Doctrine's
  6. before the message is processed, the end result needs to be written into the DB, but the database connection is closed by the server due to 10min idle (it was refreshed on message arrival)

How to reproduce

See above.

Possible Solution

If you've enabled the Doctrine middleware, it should get triggered by the alarm too.

Additional Context

Technically, the original intent of #47920 was not solved.

@dkarlovi
Copy link
Contributor Author

dkarlovi commented Apr 3, 2025

Some snippets from Slack

@dkarlovi

should the middleware implement an event subscriber maybe?

@HypeMC

Yes, that would work. However, that might trigger the middleware outside of the context of messenger if I'm not mistaking.

@dkarlovi dkarlovi changed the title [Messenger] run "refresh database connection" Doctrine middleware with the new alarm based event [Messenger] run "ping database connection" Doctrine middleware with the new alarm based event Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants