Index: branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/LSLockManager.php |
— | — | @@ -139,7 +139,7 @@ |
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | | - * Get a connection to a lock server and acquire locks on $keys. |
| 143 | + * Get a connection to a lock server and acquire locks on $keys |
144 | 144 | * |
145 | 145 | * @param $lockSrv string |
146 | 146 | * @param $keys Array |
— | — | @@ -192,7 +192,7 @@ |
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | | - * Attempt to acquire locks with the peers for a bucket. |
| 196 | + * Attempt to acquire locks with the peers for a bucket |
197 | 197 | * |
198 | 198 | * @param $bucket integer |
199 | 199 | * @param $keys Array List of resource keys to lock |
— | — | @@ -249,7 +249,7 @@ |
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | | - * Release all locks that this session is holding. |
| 253 | + * Release all locks that this session is holding |
254 | 254 | * |
255 | 255 | * @return Status |
256 | 256 | */ |
— | — | @@ -265,7 +265,7 @@ |
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | | - * Get the bucket for lock key. |
| 269 | + * Get the bucket for lock key |
270 | 270 | * |
271 | 271 | * @param $key string (40 char hex key) |
272 | 272 | * @return integer |
Index: branches/FileBackend/phase3/includes/filerepo/backend/lockmanager/DBLockManager.php |
— | — | @@ -46,6 +46,8 @@ |
47 | 47 | * 'flags' - DB flags (see DatabaseBase) |
48 | 48 | * 'dbsByBucket' : Array of 1-16 consecutive integer keys, starting from 0, |
49 | 49 | * each having an odd-numbered list of DB names (peers) as values. |
| 50 | + * Any DB named 'localDBMaster' will automatically use the DB master |
| 51 | + * settings for this wiki (without the need for a dbServers entry). |
50 | 52 | * 'lockExpiry' : Lock timeout (seconds) for dropped connections. [optional] |
51 | 53 | * This tells the DB server how long to wait before assuming |
52 | 54 | * connection failure and releasing all the locks for a session. |
— | — | @@ -232,11 +234,19 @@ |
233 | 235 | */ |
234 | 236 | protected function getConnection( $lockDb ) { |
235 | 237 | if ( !isset( $this->conns[$lockDb] ) ) { |
236 | | - $config = $this->dbServers[$lockDb]; |
237 | | - $this->conns[$lockDb] = DatabaseBase::factory( $config['type'], $config ); |
238 | | - if ( !$this->conns[$lockDb] ) { |
| 238 | + $db = null; |
| 239 | + if ( $lockDb === 'localDBMaster' ) { |
| 240 | + $lb = wfGetLBFactory()->newMainLB(); |
| 241 | + $db = $lb->getConnection( DB_MASTER ); |
| 242 | + } elseif ( isset( $this->dbServers[$lockDb] ) ) { |
| 243 | + $config = $this->dbServers[$lockDb]; |
| 244 | + $db = DatabaseBase::factory( $config['type'], $config ); |
| 245 | + } |
| 246 | + if ( !$db ) { |
239 | 247 | return null; // config error? |
240 | 248 | } |
| 249 | + $this->conns[$lockDb] = $db; |
| 250 | + $this->conns[$lockDb]->clearFlag( DBO_TRX ); |
241 | 251 | # If the connection drops, try to avoid letting the DB rollback |
242 | 252 | # and release the locks before the file operations are finished. |
243 | 253 | # This won't handle the case of DB server restarts however. |