r84323 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84322‎ | r84323 | r84324 >
Date:12:58, 19 March 2011
Author:tstarling
Status:ok
Tags:
Comment:
MFT r84322: do not show error to user on connection refused etc.
Modified paths:
  • /branches/wmf/1.17wmf1/includes/PoolCounter.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/includes/PoolCounter.php
@@ -151,44 +151,47 @@
152152 } else {
153153 $status = $this->poolCounter->acquireForMe();
154154 }
155 -
156 - if ( $status->isOK() ) {
157 - switch ( $status->value ) {
158 - case PoolCounter::LOCKED:
159 - $result = $this->doWork();
160 - $this->poolCounter->release();
161 - return $result;
 155+
 156+ if ( !$status->isOK() ) {
 157+ // Respond gracefully to complete server breakage: just log it and do the work
 158+ $this->logError( $status );
 159+ return $this->doWork();
 160+ }
 161+
 162+ switch ( $status->value ) {
 163+ case PoolCounter::LOCKED:
 164+ $result = $this->doWork();
 165+ $this->poolCounter->release();
 166+ return $result;
 167+
 168+ case PoolCounter::DONE:
 169+ $result = $this->getCachedWork();
 170+ if ( $result === false ) {
 171+ /* That someone else work didn't serve us.
 172+ * Acquire the lock for me
 173+ */
 174+ return $this->execute( true );
 175+ }
 176+ return $result;
162177
163 - case PoolCounter::DONE:
164 - $result = $this->getCachedWork();
165 - if ( $result === false ) {
166 - /* That someone else work didn't serve us.
167 - * Acquire the lock for me
168 - */
169 - return $this->execute( true );
170 - }
 178+ case PoolCounter::QUEUE_FULL:
 179+ case PoolCounter::TIMEOUT:
 180+ $result = $this->fallback();
 181+
 182+ if ( $result !== false ) {
171183 return $result;
172 -
173 - case PoolCounter::QUEUE_FULL:
174 - case PoolCounter::TIMEOUT:
175 - $result = $this->fallback();
176 -
177 - if ( $result !== false ) {
178 - return $result;
179 - }
180 - /* no break */
 184+ }
 185+ /* no break */
 186+
 187+ /* These two cases should never be hit... */
 188+ case PoolCounter::ERROR:
 189+ default:
 190+ $errors = array( PoolCounter::QUEUE_FULL => 'pool-queuefull', PoolCounter::TIMEOUT => 'pool-timeout' );
181191
182 - /* These two cases should never be hit... */
183 - case PoolCounter::ERROR:
184 - default:
185 - $errors = array( PoolCounter::QUEUE_FULL => 'pool-queuefull', PoolCounter::TIMEOUT => 'pool-timeout' );
186 -
187 - $status = Status::newFatal( isset($errors[$status->value]) ? $errors[$status->value] : 'pool-errorunknown' );
188 - /* continue to the error */
189 - }
 192+ $status = Status::newFatal( isset($errors[$status->value]) ? $errors[$status->value] : 'pool-errorunknown' );
 193+ $this->logError( $status );
 194+ return $this->error( $status );
190195 }
191 - $this->logError( $status );
192 - return $this->error( $status );
193196 }
194197
195198 function __construct( $type, $key ) {
Property changes on: branches/wmf/1.17wmf1/includes/PoolCounter.php
___________________________________________________________________
Modified: svn:mergeinfo
196199 Merged /trunk/phase3/includes/PoolCounter.php:r84322

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84322Don't refuse to do work just because the pool counter server is down. This se...tstarling12:55, 19 March 2011

Status & tagging log