Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[DoctrineBridge] Idle connection listener for long running runtime#53214
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[DoctrineBridge] Idle connection listener for long running runtime#53214
Uh oh!
There was an error while loading.Please reload this page.
Conversation
07aa62f
toba1eefd
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
A few suggestions 🙂
src/Symfony/Bridge/Doctrine/Listener/DoctrineConnectionListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bridge/Doctrine/Listener/DoctrineConnectionListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bridge/Doctrine/Listener/DoctrineConnectionListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bridge/Doctrine/Listener/DoctrineConnectionListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bridge/Doctrine/Listener/DoctrineConnectionListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
nicolas-grekas commentedDec 26, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hi, thanks for working on this topic. |
Just reading the code, it adds a lot new stuff which looks like a new feature instead of a bugfix to me |
ba1eefd
to3ec9cd7
Comparedunglas commentedDec 27, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I agree that a decorator would be better. Also, would it be possible to catch errors and reconnect only in this case instead of triggering a ping? This would remove the performance hit in most cases. @OskarStark the code probably needs to be simplified, but the underlying bug is annoying because it makes Symfony apps unstable when using FrankenPHP, RoadRunner (without the bundle), Swoole etc. The fix should be made at least in the current stable version. |
3ec9cd7
to24fb643
Compare@nicolas-grekas@dunglas ok I'll update it and try to decorate the Connection object |
24fb643
to40d646a
Compare
Thanks for the explanation Kevin 👍 |
ostrolucky left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't like the approach, because as@nicolas-grekas mentioned, this will keep pinging the DB every request, even if normally request wouldn't need connection. Can't we make this DBAL middleware instead? Middleware would check if any query fails with "DB went away..." error, if so, reset everything and retry.
Also, bear in mind counterpart for messenger is athttps://github.com/symfony/symfony/blob/412ea7afcb533b8a7a95e248d741b70fea505350/src/Symfony/Bridge/Doctrine/Messenger/DoctrinePingConnectionMiddleware.php, so this would be a good opportunity to extract common parts into bridge
src/Symfony/Bridge/Doctrine/Listener/DoctrineConnectionSubscriber.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bridge/Doctrine/Listener/DoctrineConnectionSubscriber.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bridge/Doctrine/Listener/DoctrineConnectionSubscriber.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bridge/Doctrine/Listener/DoctrineConnectionSubscriber.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bridge/Doctrine/Listener/DoctrineConnectionSubscriber.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Ok, I'll update then |
40d646a
toeb35f9d
Comparealli83 commentedJan 3, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@ostrolucky |
27e36c1
tod8773ac
CompareI was referring to middlewares that implement |
Any news on this/what's preventing it from being merged? |
d8773ac
to7791eb2
Comparesrc/Symfony/Bridge/Doctrine/Middleware/IdleConnection/Listener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
b16e918
to3d2816c
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I force-pushed to fix my last comments :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
🎉
3d2816c
tof7cc44e
CompareThank you@alli83. |
462ab95
intosymfony:7.1Uh oh!
There was an error while loading.Please reload this page.
<element key="time-sensitive"> | ||
<array> | ||
<element key="0"><string>Symfony\Bridge\Doctrine\Middleware\Debug</string></element> | ||
<element key="1"><string>Symfony\Bridge\Doctrine\Middleware\Debug</string></element> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@nicolas-grekas Isn'tSymfony\Bridge\Doctrine\Middleware\IdleConnection
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Oops, PR welcome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed in65ccca0
$containerMock = $this->createMock(ContainerInterface::class); | ||
$connectionExpiries = new \ArrayObject(['connectionone' => time() - 30, 'connectiontwo' => time() + 40]); | ||
$connectionOneMock = $this->getMockBuilder(ConnectionInterface::class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You can just do$this->createMock(ConnectionInterface::class)
to spare two lines of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Please don't comment on old, already merged PRs. If you feel strongly about this, send a PR instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sure, was just a general suggestion, though.
jsamouh commentedJan 16, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
possible to backport that into 6.X ? cc@fabpot |
No, we don't backport features. |
jsamouh commentedJan 16, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
well, does not seem to be a feature to me as it fix the error connection for long running runtime whis is our case right now in production with frankenPHP worker mode, cc@dunglas |
We understand you are having an issue you would love to solve, but this listener is a new Symfony feature improving your experience with other software (Doctrine + frankenPHP). There was no issue with Symfony, so it's not a bugfix, and it really shows in the diff, which consists in new classes. It also shows in the changelog: "Add support for auto-closing idle connections" Please stop pinging busy people that have bigger fish to fry and start work on upgrading to Symfony 7.1. If that's too much work, you can always copy paste the classes in this PR in your project, and wire them up. |
jsamouh commentedJan 16, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I dont agree but if you say so |
Uh oh!
There was an error while loading.Please reload this page.
This pull request introduces a solution based on the RoadRunner bundle's Doctrine ORM/ODM middlewarehttps://github.com/Baldinof/roadrunner-bundle/blob/3.x/src/Integration/Doctrine/DoctrineORMMiddleware.php#L22.
It checks the status of Doctrine connection, then if the connection is initialized and connected, it performs a 'ping' to check its viability. If the ping fails, it closes the connection.
linked todoctrine/DoctrineBundle#1739