From 96f35d42d78e97bb620ec8b6134b427bd793ed2c Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 15 Feb 2017 13:43:48 -0800 Subject: [PATCH] Add version to ChronologyProtector key This handles incompatible non-namespaced DBMasterPos values still in cache by ignoring them. The cache value validation has also been improved. Bug: T158217 Change-Id: I0e25cd1390e72d8ee0c31e6bb24e9184cbbcf49f --- includes/libs/rdbms/ChronologyProtector.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/includes/libs/rdbms/ChronologyProtector.php b/includes/libs/rdbms/ChronologyProtector.php index 1c28188516..8b1aabe3cd 100644 --- a/includes/libs/rdbms/ChronologyProtector.php +++ b/includes/libs/rdbms/ChronologyProtector.php @@ -75,7 +75,7 @@ class ChronologyProtector implements LoggerAwareInterface { public function __construct( BagOStuff $store, array $client, $posTime = null ) { $this->store = $store; $this->clientId = md5( $client['ip'] . "\n" . $client['agent'] ); - $this->key = $store->makeGlobalKey( __CLASS__, $this->clientId ); + $this->key = $store->makeGlobalKey( __CLASS__, $this->clientId, 'v1' ); $this->waitForPosTime = $posTime; $this->logger = new NullLogger(); } @@ -301,8 +301,9 @@ class ChronologyProtector implements LoggerAwareInterface { $min = null; foreach ( $data['positions'] as $pos ) { - /** @var DBMasterPos $pos */ - $min = $min ? min( $pos->asOfTime(), $min ) : $pos->asOfTime(); + if ( $pos instanceof DBMasterPos ) { + $min = $min ? min( $pos->asOfTime(), $min ) : $pos->asOfTime(); + } } return $min; @@ -321,8 +322,10 @@ class ChronologyProtector implements LoggerAwareInterface { $curPositions = $curValue['positions']; // Use the newest positions for each DB master foreach ( $shutdownPositions as $db => $pos ) { - if ( !isset( $curPositions[$db] ) - || $pos->asOfTime() > $curPositions[$db]->asOfTime() + if ( + !isset( $curPositions[$db] ) || + !( $curPositions[$db] instanceof DBMasterPos ) || + $pos->asOfTime() > $curPositions[$db]->asOfTime() ) { $curPositions[$db] = $pos; } -- 2.20.1