Aaron Schulz has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/348193 )
Change subject: Fix some LoadBalancer::waitFor*() inconsistencies
......................................................................
Fix some LoadBalancer::waitFor*() inconsistencies
* Make sure waitFor() always handles laggedReplicaMode updates,
even if the actual waiting was deferred until a connection was
needed.
* Restore the old mWaitForPos in waitForOne()/waitForAll() since
this do not care about the generic reader index or the sort of
ChronologyProtector logic related to it.
Change-Id: I0767e9831b8fd7fd115a472354977e3c1e12114a
---
M includes/libs/rdbms/loadbalancer/ILoadBalancer.php
M includes/libs/rdbms/loadbalancer/LoadBalancer.php
2 files changed, 12 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/93/348193/1
diff --git a/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
b/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
index 8b5a98d..ee00274 100644
--- a/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
+++ b/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
@@ -135,6 +135,10 @@
* If a DB_REPLICA connection has been opened already, then wait
immediately.
* Otherwise sets a variable telling it to wait if such a connection is
opened.
*
+ * This only applies to connections to the generic (non-grouped)
replica DB.
+ * If a timeout happens when waiting, then
getLaggedReplicaMode()/laggedReplicaUsed()
+ * will return true.
+ *
* @param DBMasterPos|bool $pos Master position or false
*/
public function waitFor( $pos );
diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php
b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
index ffa4f78..0e30d8d 100644
--- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php
+++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
@@ -411,7 +411,9 @@
# Replica DB connection successful.
# Wait for the session master pos for a short time.
if ( $this->mWaitForPos && $i > 0 ) {
- $this->doWait( $i );
+ # When LoadBalancer::waitFor() set mWaitForPos,
the wait will happen here.
+ # Be sure to update laggedReplicaMode
accordingly for consistency.
+ $laggedReplicaMode = !$this->doWait( $i );
}
if ( $this->mReadIndex <= 0 && $this->mLoads[$i] > 0 &&
$group === false ) {
$this->mReadIndex = $i;
@@ -440,7 +442,7 @@
}
}
} finally {
- // Restore the older position if it was higher
+ // Restore the older position if it was higher since
this is used for lag-protection
$this->setWaitForPositionIfHigher( $oldPos );
}
}
@@ -465,8 +467,8 @@
$ok = true; // no applicable loads
}
} finally {
- // Restore the older position if it was higher
- $this->setWaitForPositionIfHigher( $oldPos );
+ # Restore the old position, as this is not used for
lag-protection but for throttling
+ $this->mWaitForPos = $oldPos;
}
return $ok;
@@ -485,8 +487,8 @@
}
}
} finally {
- // Restore the older position if it was higher
- $this->setWaitForPositionIfHigher( $oldPos );
+ # Restore the old position, as this is not used for
lag-protection but for throttling
+ $this->mWaitForPos = $oldPos;
}
return $ok;
--
To view, visit https://gerrit.wikimedia.org/r/348193
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0767e9831b8fd7fd115a472354977e3c1e12114a
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