MDL-65072 core_lock: Locks with a zero timeout return asap

This commit is contained in:
Brendan Heywood
2019-03-14 16:55:31 +11:00
parent 3271c39c74
commit ecbe920656
3 changed files with 3 additions and 3 deletions

View File

@@ -188,7 +188,7 @@ class postgres_lock_factory implements lock_factory {
do {
$result = $this->db->get_record_sql('SELECT pg_try_advisory_lock(:locktype, :token) AS locked', $params);
$locked = $result->locked === 't';
if (!$locked) {
if (!$locked && $timeout > 0) {
usleep(rand(10000, 250000)); // Sleep between 10 and 250 milliseconds.
}
// Try until the giveup time.