Skip to content

Commit 67f99ce

Browse files
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
2 parents 651de17 + 5af1e9e commit 67f99ce

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Doctrine\DBAL\Schema\Schema;
1717
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
19-
use Symfony\Component\Lock\Exception\LockExpiredException;
2019
use Symfony\Component\Lock\Exception\NotSupportedException;
2120
use Symfony\Component\Lock\Key;
2221
use Symfony\Component\Lock\StoreInterface;
@@ -36,6 +35,8 @@
3635
*/
3736
class PdoStore implements StoreInterface
3837
{
38+
use ExpiringStoreTrait;
39+
3940
private $conn;
4041
private $dsn;
4142
private $driver;
@@ -123,11 +124,6 @@ public function save(Key $key)
123124

124125
try {
125126
$stmt->execute();
126-
if ($key->isExpired()) {
127-
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
128-
}
129-
130-
return;
131127
} catch (DBALException $e) {
132128
// the lock is already acquired. It could be us. Let's try to put off.
133129
$this->putOffExpiration($key, $this->initialTtl);
@@ -136,13 +132,11 @@ public function save(Key $key)
136132
$this->putOffExpiration($key, $this->initialTtl);
137133
}
138134

139-
if ($key->isExpired()) {
140-
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
141-
}
142-
143135
if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) {
144136
$this->prune();
145137
}
138+
139+
$this->checkNotExpired($key);
146140
}
147141

148142
/**
@@ -178,9 +172,7 @@ public function putOffExpiration(Key $key, $ttl)
178172
throw new LockConflictedException();
179173
}
180174

181-
if ($key->isExpired()) {
182-
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
183-
}
175+
$this->checkNotExpired($key);
184176
}
185177

186178
/**
@@ -294,7 +286,7 @@ public function createTable(): void
294286
}
295287

296288
/**
297-
* Cleanups the table by removing all expired locks.
289+
* Cleans up the table by removing all expired locks.
298290
*/
299291
private function prune(): void
300292
{

src/Symfony/Component/Lock/Store/ZookeeperStore.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
class ZookeeperStore implements StoreInterface
2727
{
28+
use ExpiringStoreTrait;
29+
2830
private $zookeeper;
2931

3032
public function __construct(\Zookeeper $zookeeper)
@@ -45,6 +47,8 @@ public function save(Key $key)
4547
$token = $this->getUniqueToken($key);
4648

4749
$this->createNewLock($resource, $token);
50+
51+
$this->checkNotExpired($key);
4852
}
4953

5054
/**

0 commit comments

Comments
 (0)