-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MasterSlaveConnection::ping() throws PDOException #3313
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
MasterSlaveConnection::ping() throws PDOException #3313
Conversation
@@ -1673,7 +1674,7 @@ public function ping() | |||
$this->query($this->getDatabasePlatform()->getDummySelectSQL()); | |||
|
|||
return true; | |||
} catch (DBALException $e) { | |||
} catch (PDOException | DBALException $e) { |
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.
When does a PDOException
occur? I believe we upcast those, so this is fixing a symptom
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.
we may stay with DBALException
only for case when we will catch Throwable
and convert them to the DBALException in the query
methods.
https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Connection.php#L1011-L1015
*/ | ||
public function ping() | ||
{ | ||
$this->connect('master'); |
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.
Seems incorrect to me: it should simply ping whichever connection is already selected, as otherwise we may attempt to select the slave and then not get a valid response
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.
will revert
$statement = $this->_conn->query(...$args); | ||
try { | ||
$statement = $this->_conn->query(...$args); | ||
} catch (Throwable $e) { |
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.
Same as above: we upcast these, so if we need to further wrap it there's something else going on
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 follow the same idea from the regular Connection class https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Connection.php#L1011-L1015
is the latest build random? oO |
@sidz no, it just errored. I restarted the needed jobs. |
@morozov doesn't help :( |
@sidz should be related to https://www.traviscistatus.com/incidents/k35bqcmm5274. |
@sidz please try rebasing on the latest master. |
@morozov done |
@sidz the Travis CI build is green but AppVeyor is all red. I've restarted it to see if it's something accidental. |
@Ocramius ping for re-review |
Irrelevant as of #4128. |
Summary
Fix existing issue with uncaught exception in the
MasterSlaveConnection::query
.Also looks like
ping
method in the MasterSlaveConnection class will send pings to the slave connection:https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php#L124-L133
I've marked it as BC Break as
ping
method will change it behavior in theMasterSlaveConnection
and will ping master instead of slavep.s. this PR covers 2 issues: #3118 and #2769