-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[6.x] Prevent making actual pdo connections while reconnecting #30998
Conversation
Thanks for the PR. What I wonder about this implementation though is that now |
@bernardwiesner I think that's the intended way for it to work. Why make a connection before actually needing one? |
It just seems that the comments are rather misleading now, since
which actually does disconnect the connection and
which would not actually reconnect to the DB. To me what makes more sense is to have an implementation where if a previous write connection existed and you call |
@bernardwiesner, when you disconnect we don't store if the read/write connections are in place. That's why there's no way we know what this connection used to do. To me a fresh connection is safer and better approach. |
You think something like this would work? I am assuming that when the PDOs are set to null it means they were disconnected.
|
@bernardwiesner again, why make the connection before actually needing one? Your app could terminate without making any select/insert queries, why make a connection without using it? Can you explain a use case? |
Yeah I also cant think of many use cases, I just thought the comments and namings were a little off now. The only use case I can think of is an asynchronous one, where you may want to save some time on the reconnect and call it while processing some other data. |
Calling
$connection->getPdo()
or$connection->getReadPdo()
starts an actual connection with the database:Problems appear when the connection we are using is a read-only or write-only connection, in that case we don't want to make the other PDO connection while it won't be used as seen in this issue(#30957).
I went for
readRawPdo
andreadWritePdo
for method names as we have the same in Query\Builder.php where we have a gettergetBidnings
and another methodgetRawBindings
. That way we won't have to break the interface.