* @param string $server
* @param RedisConnRef $cref
* @param RedisException $e
+ * @deprecated 1.23
*/
public function handleException( $server, RedisConnRef $cref, RedisException $e ) {
- wfDebugLog( 'redis', "Redis exception on server $server: " . $e->getMessage() );
+ return $this->handleError( $cref, $e );
+ }
+
+ /**
+ * The redis extension throws an exception in response to various read, write
+ * and protocol errors. Sometimes it also closes the connection, sometimes
+ * not. The safest response for us is to explicitly destroy the connection
+ * object and let it be reopened during the next request.
+ *
+ * @param RedisConnRef $cref
+ * @param RedisException $e
+ */
+ public function handleError( RedisConnRef $cref, RedisException $e ) {
+ $server = $cref->getServer();
+ wfDebugLog( 'redis', "Redis exception on server $server: " . $e->getMessage() . "\n" );
foreach ( $this->connections[$server] as $key => $connection ) {
if ( $cref->isConnIdentical( $connection['conn'] ) ) {
$this->idlePoolSize -= $connection['free'] ? 1 : 0;
try {
return $conn->lSize( $this->getQueueKey( 'l-unclaimed' ) );
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
}
return array_sum( $conn->exec() );
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
}
try {
return $conn->zSize( $this->getQueueKey( 'z-delayed' ) );
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
}
try {
return $conn->zSize( $this->getQueueKey( 'z-abandoned' ) );
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
}
JobQueue::incrStats( 'job-insert-duplicate', $this->type,
count( $items ) - $failed - $pushed );
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
return true;
$job = $this->getJobFromFields( $item ); // may be false
} while ( !$job ); // job may be false if invalid
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
return $job;
return false;
}
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
}
// Update the timestamp of the last root job started at the location...
return $conn->set( $key, $params['rootJobTimestamp'], self::ROOTJOB_TTL ); // 2 weeks
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
}
// Get the last time this root job was enqueued
$timestamp = $conn->get( $this->getRootJobCacheKey( $params['rootJobSignature'] ) );
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
// Check if a new root job was started at the location after this one's...
return ( $conn->delete( $keys ) !== false );
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
}
} )
);
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
}
} )
);
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
}
protected function doGetSiblingQueueSizes( array $types ) {
$sizes = array(); // (type => size)
$types = array_values( $types ); // reindex
+ $conn = $this->getConnection();
try {
- $conn = $this->getConnection();
$conn->multi( Redis::PIPELINE );
foreach ( $types as $type ) {
$conn->lSize( $this->getQueueKey( 'l-unclaimed', $type ) );
}
}
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
return $sizes;
return $job;
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
}
JobQueue::incrStats( 'job-abandon', $this->type, $abandoned );
}
} catch ( RedisException $e ) {
- $this->throwRedisException( $this->server, $conn, $e );
+ $this->throwRedisException( $conn, $e );
}
return $count;
}
/**
- * @param $server string
* @param $conn RedisConnRef
* @param $e RedisException
* @throws JobQueueError
*/
- protected function throwRedisException( $server, RedisConnRef $conn, $e ) {
- $this->redisPool->handleException( $server, $conn, $e );
+ protected function throwRedisException( RedisConnRef $conn, $e ) {
+ $this->redisPool->handleError( $conn, $e );
throw new JobQueueError( "Redis server error: {$e->getMessage()}\n" );
}
$result = $this->unserialize( $value );
} catch ( RedisException $e ) {
$result = false;
- $this->handleException( $server, $conn, $e );
+ $this->handleException( $conn, $e );
}
$this->logRequest( 'get', $key, $server, $result );
}
} catch ( RedisException $e ) {
$result = false;
- $this->handleException( $server, $conn, $e );
+ $this->handleException( $conn, $e );
}
$this->logRequest( 'set', $key, $server, $result );
$result = ( $conn->exec() == array( true ) );
} catch ( RedisException $e ) {
$result = false;
- $this->handleException( $server, $conn, $e );
+ $this->handleException( $conn, $e );
}
$this->logRequest( 'cas', $key, $server, $result );
$result = true;
} catch ( RedisException $e ) {
$result = false;
- $this->handleException( $server, $conn, $e );
+ $this->handleException( $conn, $e );
}
$this->logRequest( 'delete', $key, $server, $result );
}
}
} catch ( RedisException $e ) {
- $this->handleException( $server, $conn, $e );
+ $this->handleException( $conn, $e );
}
}
}
} catch ( RedisException $e ) {
$result = false;
- $this->handleException( $server, $conn, $e );
+ $this->handleException( $conn, $e );
}
$this->logRequest( 'add', $key, $server, $result );
}
} catch ( RedisException $e ) {
$result = false;
- $this->handleException( $server, $conn, $e );
+ $this->handleException( $conn, $e );
}
$this->logRequest( 'replace', $key, $server, $result );
$result = $this->unserialize( $conn->incrBy( $key, $value ) );
} catch ( RedisException $e ) {
$result = false;
- $this->handleException( $server, $conn, $e );
+ $this->handleException( $conn, $e );
}
$this->logRequest( 'incr', $key, $server, $result );
* not. The safest response for us is to explicitly destroy the connection
* object and let it be reopened during the next request.
*/
- protected function handleException( $server, RedisConnRef $conn, $e ) {
- $this->redisPool->handleException( $server, $conn, $e );
+ protected function handleException( RedisConnRef $conn, $e ) {
+ $this->redisPool->handleError( $conn, $e );
}
/**