Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/util/PhabricatorGlobalLock.php
Show First 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | protected function doLock($wait) { | ||||
$result = queryfx_one( | $result = queryfx_one( | ||||
$conn, | $conn, | ||||
'SELECT GET_LOCK(%s, %f)', | 'SELECT GET_LOCK(%s, %f)', | ||||
$lock_name, | $lock_name, | ||||
$wait); | $wait); | ||||
$ok = head($result); | $ok = head($result); | ||||
if (!$ok) { | if (!$ok) { | ||||
// See PHI1794. We failed to acquire the lock, but the connection itself | |||||
// is still good. We're done with it, so add it to the pool, just as we | |||||
// would if we were releasing the lock. | |||||
// If we don't do this, we may establish a huge number of connections | |||||
// very rapidly if many workers try to acquire a lock at once. For | |||||
// example, this can happen if there are a large number of webhook tasks | |||||
// in the queue. | |||||
self::$pool[] = $conn; | |||||
throw id(new PhutilLockException($lock_name)) | throw id(new PhutilLockException($lock_name)) | ||||
->setHint($this->newHint($lock_name, $wait)); | ->setHint($this->newHint($lock_name, $wait)); | ||||
} | } | ||||
$conn->rememberLock($lock_name); | $conn->rememberLock($lock_name); | ||||
$this->conn = $conn; | $this->conn = $conn; | ||||
▲ Show 20 Lines • Show All 221 Lines • Show Last 20 Lines |