rdbms: improve log warnings in runMasterPostTrxCallbacks()
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 1 May 2018 17:57:18 +0000 (10:57 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 1 May 2018 20:24:39 +0000 (13:24 -0700)
Bug: T191282
Change-Id: Iba663c58224af920f90d7b401aab2eb21f921941

includes/libs/rdbms/database/Database.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php

index f44b7cb..8da1ca9 100644 (file)
@@ -722,12 +722,14 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        }
 
        /**
-        * Get the list of method names that have pending write queries or that
-        * have transaction callbacks that have yet to run
+        * List the methods that have write queries or callbacks for the current transaction
         *
-        * @return array
+        * This method should not be used outside of Database/LoadBalancer
+        *
+        * @return string[]
+        * @since 1.32
         */
-       protected function pendingWriteAndCallbackCallers() {
+       public function pendingWriteAndCallbackCallers() {
                $fnames = $this->pendingWriteCallers();
                foreach ( [
                        $this->trxIdleCallbacks,
index e70d49e..ddc4277 100644 (file)
@@ -1424,6 +1424,14 @@ class LoadBalancer implements ILoadBalancer {
                                if ( $conn->writesPending() ) {
                                        // A callback from another handle wrote to this one and DBO_TRX is set
                                        $this->queryLogger->warning( __METHOD__ . ": found writes pending." );
+                                       $fnames = implode( ', ', $conn->pendingWriteAndCallbackCallers() );
+                                       $this->queryLogger->warning(
+                                               __METHOD__ . ": found writes pending ($fnames).",
+                                               [
+                                                       'db_server' => $conn->getServer(),
+                                                       'db_name' => $conn->getDBname()
+                                               ]
+                                       );
                                } elseif ( $conn->trxLevel() ) {
                                        // A callback from another handle read from this one and DBO_TRX is set,
                                        // which can easily happen if there is only one DB (no replicas)