Merge branch '4.3' into 4.4
* 4.3: Fix PDO prune not called Fix Expiring lock in PDO and ZooKeeper [Lock] fix bad merge
This commit is contained in:
commit
67f99ce226
@ -16,7 +16,6 @@ use Doctrine\DBAL\DBALException;
|
|||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Lock\Exception\LockConflictedException;
|
use Symfony\Component\Lock\Exception\LockConflictedException;
|
||||||
use Symfony\Component\Lock\Exception\LockExpiredException;
|
|
||||||
use Symfony\Component\Lock\Exception\NotSupportedException;
|
use Symfony\Component\Lock\Exception\NotSupportedException;
|
||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
use Symfony\Component\Lock\StoreInterface;
|
||||||
@ -36,6 +35,8 @@ use Symfony\Component\Lock\StoreInterface;
|
|||||||
*/
|
*/
|
||||||
class PdoStore implements StoreInterface
|
class PdoStore implements StoreInterface
|
||||||
{
|
{
|
||||||
|
use ExpiringStoreTrait;
|
||||||
|
|
||||||
private $conn;
|
private $conn;
|
||||||
private $dsn;
|
private $dsn;
|
||||||
private $driver;
|
private $driver;
|
||||||
@ -123,11 +124,6 @@ class PdoStore implements StoreInterface
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
if ($key->isExpired()) {
|
|
||||||
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
} catch (DBALException $e) {
|
} catch (DBALException $e) {
|
||||||
// the lock is already acquired. It could be us. Let's try to put off.
|
// the lock is already acquired. It could be us. Let's try to put off.
|
||||||
$this->putOffExpiration($key, $this->initialTtl);
|
$this->putOffExpiration($key, $this->initialTtl);
|
||||||
@ -136,13 +132,11 @@ class PdoStore implements StoreInterface
|
|||||||
$this->putOffExpiration($key, $this->initialTtl);
|
$this->putOffExpiration($key, $this->initialTtl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($key->isExpired()) {
|
|
||||||
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) {
|
if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) {
|
||||||
$this->prune();
|
$this->prune();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->checkNotExpired($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,9 +172,7 @@ class PdoStore implements StoreInterface
|
|||||||
throw new LockConflictedException();
|
throw new LockConflictedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($key->isExpired()) {
|
$this->checkNotExpired($key);
|
||||||
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -294,7 +286,7 @@ class PdoStore implements StoreInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanups the table by removing all expired locks.
|
* Cleans up the table by removing all expired locks.
|
||||||
*/
|
*/
|
||||||
private function prune(): void
|
private function prune(): void
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,8 @@ use Symfony\Component\Lock\StoreInterface;
|
|||||||
*/
|
*/
|
||||||
class ZookeeperStore implements StoreInterface
|
class ZookeeperStore implements StoreInterface
|
||||||
{
|
{
|
||||||
|
use ExpiringStoreTrait;
|
||||||
|
|
||||||
private $zookeeper;
|
private $zookeeper;
|
||||||
|
|
||||||
public function __construct(\Zookeeper $zookeeper)
|
public function __construct(\Zookeeper $zookeeper)
|
||||||
@ -45,6 +47,8 @@ class ZookeeperStore implements StoreInterface
|
|||||||
$token = $this->getUniqueToken($key);
|
$token = $this->getUniqueToken($key);
|
||||||
|
|
||||||
$this->createNewLock($resource, $token);
|
$this->createNewLock($resource, $token);
|
||||||
|
|
||||||
|
$this->checkNotExpired($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user