Mailing List Archive

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: rdbms: make LoadBalancer::waitForAll() better respect the ti...
Aaron Schulz has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/404497 )

Change subject: rdbms: make LoadBalancer::waitForAll() better respect the timeout
......................................................................

rdbms: make LoadBalancer::waitForAll() better respect the timeout

If several replicas (or even all) had replication stuck, then the timeout
would happen for each server, one after another.

Change-Id: Id5431360b9cde7e5dc0115a1f41b9903003f47c4
---
M includes/libs/rdbms/loadbalancer/LoadBalancer.php
1 file changed, 4 insertions(+), 0 deletions(-)


git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/97/404497/1

diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
index e80b952..c57d095 100644
--- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php
+++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
@@ -524,9 +524,13 @@
$serverCount = count( $this->mServers );

$ok = true;
+ $since = microtime( true );
for ( $i = 1; $i < $serverCount; $i++ ) {
if ( $this->mLoads[$i] > 0 ) {
$ok = $this->doWait( $i, true, $timeout ) && $ok;
+ if ( ( microtime( true ) - $since ) >= $timeout ) {
+ break; // timeout reached
+ }
}
}
} finally {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id5431360b9cde7e5dc0115a1f41b9903003f47c4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <aschulz@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: rdbms: make LoadBalancer::waitForAll() better respect the ti... [ In reply to ]
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/404497 )

Change subject: rdbms: make LoadBalancer::waitForAll() better respect the timeout
......................................................................


rdbms: make LoadBalancer::waitForAll() better respect the timeout

If several replicas (or even all) had replication stuck, then the
timeout would happen for each server, one after another.

Change-Id: Id5431360b9cde7e5dc0115a1f41b9903003f47c4
---
M includes/libs/rdbms/loadbalancer/LoadBalancer.php
1 file changed, 8 insertions(+), 1 deletion(-)

Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified



diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
index e80b952..9c5a107 100644
--- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php
+++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
@@ -518,6 +518,8 @@
}

public function waitForAll( $pos, $timeout = null ) {
+ $timeout = $timeout ?: $this->mWaitTimeout;
+
$oldPos = $this->mWaitForPos;
try {
$this->mWaitForPos = $pos;
@@ -526,7 +528,12 @@
$ok = true;
for ( $i = 1; $i < $serverCount; $i++ ) {
if ( $this->mLoads[$i] > 0 ) {
- $ok = $this->doWait( $i, true, $timeout ) && $ok;
+ $start = microtime( true );
+ $ok = $this->doWait( $i, true, max( 1, (int)$timeout ) ) && $ok;
+ $timeout -= ( microtime( true ) - $start );
+ if ( $timeout <= 0 ) {
+ break; // timeout reached
+ }
}
}
} finally {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id5431360b9cde7e5dc0115a1f41b9903003f47c4
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <aschulz@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklemail@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits