* @return IMaintainableDatabase
* @throws MWException
*/
- private function getDB( $shardIndex ) {
+ private function getConnection( $shardIndex ) {
if ( $shardIndex >= $this->numServerShards ) {
throw new MWException( __METHOD__ . ": Invalid server index \"$shardIndex\"" );
}
$dataRows = [];
foreach ( $keysByTable as $shardIndex => $serverKeys ) {
try {
- $db = $this->getDB( $shardIndex );
+ $db = $this->getConnection( $shardIndex );
foreach ( $serverKeys as $tableName => $tableKeys ) {
$res = $db->select( $tableName,
[ 'keyname', 'value', 'exptime' ],
$this->debug( "get: retrieved data; expiry time is " . $row->exptime );
$db = null; // in case of connection failure
try {
- $db = $this->getDB( $row->shardIndex );
+ $db = $this->getConnection( $row->shardIndex );
if ( $this->isExpired( $db, $row->exptime ) ) { // MISS
$this->debug( "get: key has expired" );
} else { // HIT
foreach ( $keysByTable as $shardIndex => $serverKeys ) {
$db = null; // in case of connection failure
try {
- $db = $this->getDB( $shardIndex );
+ $db = $this->getConnection( $shardIndex );
$this->occasionallyGarbageCollect( $db ); // expire old entries if any
$dbExpiry = $exptime ? $db->timestamp( $exptime ) : $this->getMaxDateTime( $db );
} catch ( DBError $e ) {
$silenceScope = $this->silenceTransactionProfiler();
$db = null; // in case of connection failure
try {
- $db = $this->getDB( $shardIndex );
+ $db = $this->getConnection( $shardIndex );
// (T26425) use a replace if the db supports it instead of
// delete/insert to avoid clashes with conflicting keynames
$db->update(
$silenceScope = $this->silenceTransactionProfiler();
$db = null; // in case of connection failure
try {
- $db = $this->getDB( $shardIndex );
+ $db = $this->getConnection( $shardIndex );
$encTimestamp = $db->addQuotes( $db->timestamp() );
$db->update(
$tableName,
foreach ( $shardIndexes as $numServersDone => $shardIndex ) {
$db = null; // in case of connection failure
try {
- $db = $this->getDB( $shardIndex );
+ $db = $this->getConnection( $shardIndex );
$this->deleteServerObjectsExpiringBefore(
$db,
$timestamp,
for ( $shardIndex = 0; $shardIndex < $this->numServerShards; $shardIndex++ ) {
$db = null; // in case of connection failure
try {
- $db = $this->getDB( $shardIndex );
+ $db = $this->getConnection( $shardIndex );
for ( $i = 0; $i < $this->numTableShards; $i++ ) {
$db->delete( $this->getTableNameByShard( $i ), '*', __METHOD__ );
}
$db = null; // in case of connection failure
try {
- $db = $this->getDB( $shardIndex );
+ $db = $this->getConnection( $shardIndex );
$ok = $db->lock( $key, __METHOD__, $timeout );
if ( $ok ) {
$this->locks[$key] = [ 'class' => $rclass, 'depth' => 1 ];
$db = null; // in case of connection failure
try {
- $db = $this->getDB( $shardIndex );
+ $db = $this->getConnection( $shardIndex );
$ok = $db->unlock( $key, __METHOD__ );
if ( !$ok ) {
$this->logger->warning(
*/
public function createTables() {
for ( $shardIndex = 0; $shardIndex < $this->numServerShards; $shardIndex++ ) {
- $db = $this->getDB( $shardIndex );
+ $db = $this->getConnection( $shardIndex );
if ( $db->getType() !== 'mysql' ) {
throw new MWException( __METHOD__ . ' is not supported on this DB server' );
}