Aaron Schulz has uploaded a new change for review.

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

Change subject: Make getCacheSetOptions() and WAN cache handle broken 
replication
......................................................................

Make getCacheSetOptions() and WAN cache handle broken replication

TTL_LAGGED now triggers if the slave or I/O threads stopped

Change-Id: I5e7bf2d33b8d3a60182ec53a93d65f7e55f02222
---
M includes/db/Database.php
M includes/libs/objectcache/WANObjectCache.php
2 files changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/01/255801/1

diff --git a/includes/db/Database.php b/includes/db/Database.php
index c0cf067..68f94b6 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -3820,7 +3820,7 @@
         * @param IDatabase $db1
         * @param IDatabase ...
         * @return array Map of values:
-        *   - lag: highest lag of any of the DBs
+        *   - lag: highest lag of any of the DBs or false on error (e.g. 
replication stopped)
         *   - since: oldest UNIX timestamp of any of the DB lag estimates
         *   - pending: whether any of the DBs have uncommitted changes
         * @since 1.27
@@ -3830,7 +3830,11 @@
                foreach ( func_get_args() as $db ) {
                        /** @var IDatabase $db */
                        $status = $db->getSessionLagStatus();
-                       $res['lag'] = max( $res['lag'], $status['lag'] );
+                       if ( $status['lag'] === false ) {
+                               $res['lag'] = false;
+                       } elseif ( $res['lag'] !== false ) {
+                               $res['lag'] = max( $res['lag'], $status['lag'] 
);
+                       }
                        $res['since'] = min( $res['since'], $status['since'] );
                        $res['pending'] = $res['pending'] ?: 
$db->writesPending();
                }
diff --git a/includes/libs/objectcache/WANObjectCache.php 
b/includes/libs/objectcache/WANObjectCache.php
index 16e894e..720946a 100644
--- a/includes/libs/objectcache/WANObjectCache.php
+++ b/includes/libs/objectcache/WANObjectCache.php
@@ -378,7 +378,7 @@
 
                $wrapExtra = array(); // additional wrapped value fields
                // Check if there's a risk of writing stale data after the 
purge tombstone expired
-               if ( ( $lag + $age ) > self::MAX_READ_LAG ) {
+               if ( ( $lag + $age ) > self::MAX_READ_LAG || $lag === false ) {
                        // Case A: read lag with "lockTSE"; save but record 
value as stale
                        if ( $lockTSE >= 0 ) {
                                $ttl = max( 1, (int)$lockTSE ); // set() 
expects seconds
@@ -389,7 +389,7 @@
 
                                return true; // no-op the write for being unsafe
                        // Case C: high replication lag; lower TTL instead of 
ignoring all set()s
-                       } elseif ( $lag > self::MAX_READ_LAG ) {
+                       } elseif ( $lag > self::MAX_READ_LAG || $lag === false 
) {
                                $ttl = $ttl ? min( $ttl, self::TTL_LAGGED ) : 
self::TTL_LAGGED;
                                $this->logger->warning( "Lowered set() TTL for 
$key due to replication lag." );
                        // Case D: medium length request with medium 
replication lag; ignore this set()

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

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

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

Reply via email to