summaryrefslogtreecommitdiff
path: root/includes/db/LBFactory.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-06-10 13:00:47 +0200
committerPierre Schmitz <pierre@archlinux.de>2009-06-10 13:00:47 +0200
commit72e90545454c0e014318fa3c81658e035aac58c1 (patch)
tree9212e3f46868989c4d57ae9a5c8a1a80e4dc0702 /includes/db/LBFactory.php
parent565a0ccc371ec1a2a0e9b39487cbac18e6f60e25 (diff)
applying patch to version 1.15.0
Diffstat (limited to 'includes/db/LBFactory.php')
-rw-r--r--includes/db/LBFactory.php26
1 files changed, 18 insertions, 8 deletions
diff --git a/includes/db/LBFactory.php b/includes/db/LBFactory.php
index 256875d7..3876d71f 100644
--- a/includes/db/LBFactory.php
+++ b/includes/db/LBFactory.php
@@ -236,15 +236,25 @@ class ChronologyProtector {
* @param LoadBalancer $lb
*/
function shutdownLB( $lb ) {
- if ( session_id() != '' && $lb->getServerCount() > 1 ) {
- $masterName = $lb->getServerName( 0 );
- if ( !isset( $this->shutdownPos[$masterName] ) ) {
- $pos = $lb->getMasterPos();
- $info = $lb->parentInfo();
- wfDebug( __METHOD__.": LB " . $info['id'] . " has master pos $pos\n" );
- $this->shutdownPos[$masterName] = $pos;
- }
+ // Don't start a session, don't bother with non-replicated setups
+ if ( strval( session_id() ) == '' || $lb->getServerCount() <= 1 ) {
+ return;
+ }
+ $masterName = $lb->getServerName( 0 );
+ if ( isset( $this->shutdownPos[$masterName] ) ) {
+ // Already done
+ return;
+ }
+ // Only save the position if writes have been done on the connection
+ $db = $lb->getAnyOpenConnection( 0 );
+ $info = $lb->parentInfo();
+ if ( !$db || !$db->doneWrites() ) {
+ wfDebug( __METHOD__.": LB {$info['id']}, no writes done\n" );
+ return;
}
+ $pos = $db->getMasterPos();
+ wfDebug( __METHOD__.": LB {$info['id']} has master pos $pos\n" );
+ $this->shutdownPos[$masterName] = $pos;
}
/**