Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/74323


Change subject: Improved DBConnRef handling when write transactions are still 
open
......................................................................

Improved DBConnRef handling when write transactions are still open

Change-Id: I681be609ff34bb95d45c0ad298f570cf763e12e6
---
M includes/db/LoadBalancer.php
1 file changed, 13 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/23/74323/1

diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php
index 5c4443d..e7690be 100644
--- a/includes/db/LoadBalancer.php
+++ b/includes/db/LoadBalancer.php
@@ -1111,6 +1111,18 @@
        }
 
        function __destruct() {
-               $this->lb->reuseConnection( $this->conn );
+               // We can call reuse the connection for another wiki via 
selectDB() on this as
+               // long as it is not in a transaction (which can easily happen 
with DBO_TRX) as
+               // cross-DB transactions are not supported. In that case it can 
only be reused
+               // for same-DB queries until it commits.
+               if ( $this->conn->writesOrCallbacksPending() ) {
+                       $lb = $this->lb;
+                       $conn = $this->conn;
+                       $conn->onTransactionIdle( function() use ( $lb, $conn ) 
{
+                               $lb->reuseConnection( $conn ); // might get 
called some extra times, meh
+                       } );
+               } else {
+                       $this->lb->reuseConnection( $this->conn );
+               }
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/74323
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I681be609ff34bb95d45c0ad298f570cf763e12e6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to