/**
  * Initialise a LoadBalancer to give it appropriate chronology protection.
  *
  * If the session has a previous master position recorded, this will try to
  * make sure that the next query to a slave of that master will see changes up
  * to that position by delaying execution. The delay may timeout and allow stale
  * data if no non-lagged slaves are available.
  *
  * @param LoadBalancer $lb
  * @return void
  */
 public function initLB(LoadBalancer $lb)
 {
     if ($lb->getServerCount() <= 1) {
         return;
         // non-replicated setup
     }
     if (!$this->initialized) {
         $this->initialized = true;
         if (isset($_SESSION[__CLASS__]) && is_array($_SESSION[__CLASS__])) {
             $this->startupPositions = $_SESSION[__CLASS__];
         }
     }
     $masterName = $lb->getServerName(0);
     if (!empty($this->startupPositions[$masterName])) {
         $info = $lb->parentInfo();
         $pos = $this->startupPositions[$masterName];
         wfDebug(__METHOD__ . ": LB " . $info['id'] . " waiting for master pos {$pos}\n");
         $lb->waitFor($pos);
     }
 }
Exemple #2
0
 /**
  * Initialise a LoadBalancer to give it appropriate chronology protection.
  *
  * @param LoadBalancer $lb
  */
 function initLB($lb)
 {
     if ($this->startupPos === null) {
         if (!empty($_SESSION[__CLASS__])) {
             $this->startupPos = $_SESSION[__CLASS__];
         }
     }
     if (!$this->startupPos) {
         return;
     }
     $masterName = $lb->getServerName(0);
     if ($lb->getServerCount() > 1 && !empty($this->startupPos[$masterName])) {
         $info = $lb->parentInfo();
         $pos = $this->startupPos[$masterName];
         wfDebug(__METHOD__ . ": LB " . $info['id'] . " waiting for master pos {$pos}\n");
         $lb->waitFor($this->startupPos[$masterName]);
     }
 }
 /**
  * Initialise a LoadBalancer to give it appropriate chronology protection.
  *
  * If the stash has a previous master position recorded, this will try to
  * make sure that the next query to a slave of that master will see changes up
  * to that position by delaying execution. The delay may timeout and allow stale
  * data if no non-lagged slaves are available.
  *
  * @param LoadBalancer $lb
  * @return void
  */
 public function initLB(LoadBalancer $lb)
 {
     if (!$this->enabled || $lb->getServerCount() <= 1) {
         return;
         // non-replicated setup or disabled
     }
     $this->initPositions();
     $masterName = $lb->getServerName($lb->getWriterIndex());
     if (!empty($this->startupPositions[$masterName])) {
         $info = $lb->parentInfo();
         $pos = $this->startupPositions[$masterName];
         wfDebugLog('replication', __METHOD__ . ": LB '" . $info['id'] . "' waiting for master pos {$pos}\n");
         $lb->waitFor($pos);
     }
 }