rdbms: Use plain array to store position data
Bug: T317606 Change-Id: Ifcc103cbb4ebdc2baf768bc7ded9cb23aae73e25
This commit is contained in:
parent
fe301b4cb1
commit
44c197d06a
1 changed files with 13 additions and 3 deletions
|
|
@ -868,9 +868,10 @@ class LoadBalancer implements ILoadBalancerForOwner {
|
|||
|
||||
// Check if we already know that the DB has reached this point
|
||||
$srvName = $this->getServerName( $index );
|
||||
$key = $this->srvCache->makeGlobalKey( __CLASS__, 'last-known-pos', $srvName, 'v1' );
|
||||
$key = $this->srvCache->makeGlobalKey( __CLASS__, 'last-known-pos', $srvName, 'v2' );
|
||||
|
||||
/** @var DBPrimaryPos $knownReachedPos */
|
||||
$knownReachedPos = $this->srvCache->get( $key );
|
||||
$knownReachedPos = $this->unmarshalPosition( $this->srvCache->get( $key ) );
|
||||
if (
|
||||
$knownReachedPos instanceof DBPrimaryPos &&
|
||||
$knownReachedPos->hasReached( $this->waitForPos )
|
||||
|
|
@ -917,7 +918,7 @@ class LoadBalancer implements ILoadBalancerForOwner {
|
|||
$ok = ( $result !== null && $result != -1 );
|
||||
if ( $ok ) {
|
||||
// Remember that the DB reached this point
|
||||
$this->srvCache->set( $key, $this->waitForPos, BagOStuff::TTL_DAY );
|
||||
$this->srvCache->set( $key, $this->waitForPos->toArray(), BagOStuff::TTL_DAY );
|
||||
}
|
||||
|
||||
if ( $close ) {
|
||||
|
|
@ -927,6 +928,15 @@ class LoadBalancer implements ILoadBalancerForOwner {
|
|||
return $ok;
|
||||
}
|
||||
|
||||
private function unmarshalPosition( $position ) {
|
||||
if ( !is_array( $position ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$class = $position['_type_'];
|
||||
return $class::newFromArray( $position );
|
||||
}
|
||||
|
||||
public function getConnection( $i, $groups = [], $domain = false, $flags = 0 ) {
|
||||
return $this->getConnectionRef( $i, $groups, $domain, $flags );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue