-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[8.x] Fix Doctrine type mappings creating too many connections #40303
[8.x] Fix Doctrine type mappings creating too many connections #40303
Conversation
@bakerkretzmar I confirm this fixes it! Thank you! Couldn't test with parallel though. |
@bakerkretzmar I've just tried your proposed solution. |
@skollro does it work if you do it in the |
@bakerkretzmar unfortunately, no. It seems like |
@skollro thanks. It does get called but not where I thought it did, working on fixing this now. |
$this->getDoctrineSchemaManager() | ||
->getDatabasePlatform() | ||
->registerDoctrineTypeMapping($type, $name); | ||
$this->doctrineTypeMappings[$name] = $type; |
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've kept this whole registerDoctrineType
method for backwards compatibility but it can be removed in Laravel 9 because the same method on the DatabaseManager class replaces it. I'll PR that today too.
I'm pretty sure this fixes the issue now in all the cases mentioned here and in various comments: registering custom types either via There is some code duplication here to maintain complete backwards compatibility, I'll submit another PR asap to clean this up a bit for Laravel 9. Basically, the type registration has to happen through the |
Thanks @bakerkretzmar & @TomHAnderson ! |
Thanks! Can confirm |
Yeah I'm going to remove |
TLDR: this PR closes #40297 by only registering custom Doctrine type mappings on a Doctrine connection after that connection is created (as opposed to creating one to register them).
Context
My and @TomHAnderson's original PR, #40119, created an issue with tests where way too many database connections would be created. We were manually creating a database connection to register the custom type mappings, which caused database connections to be created every time the app boots, and dozens of unnecessary connections to be created when tests are run in parallel.
I'm still not entirely sure why all those connections stick around, I tried manually closing/destroying them through Doctrine and that didn't seem to work.