- // Throw any unexpected errors after having disconnected
- if ( $exception instanceof Exception ) {
- throw $exception;
+ // Log or throw any unexpected errors after having disconnected
+ if ( $error !== null ) {
+ // T217819, T231443: if this is probably just LoadBalancer trying to recover from
+ // errors and shutdown, then log any problems and move on since the request has to
+ // end one way or another. Throwing errors is not very useful at some point.
+ if ( $this->ownerId !== null && $owner === $this->ownerId ) {
+ $this->queryLogger->error( $error );
+ } else {
+ throw new DBUnexpectedError( $this, $error );
+ }