Skip to content

Commit c9ab846

Browse files
bug #32076 [Lock] Fix PDO prune not called (jderusse)
This PR was merged into the 4.2 branch. Discussion ---------- [Lock] Fix PDO prune not called | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | NA | License | MIT | Doc PR | NA Saving a key in the PDO store have 2 paths: - the key is didn't exists in the store, the process exit as soon as the key has been savec - the key already exists in the store, the process put off the expiration then run GC to prunbe old keys Calling GC only in the 2nd path was a mistake, if the component is well used, the second could never be used. This PR call the GC in the first path too. Commits ------- fc2dc14 Fix PDO prune not called
2 parents 432c21f + fc2dc14 commit c9ab846

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ public function save(Key $key)
124124

125125
try {
126126
$stmt->execute();
127-
$this->checkNotExpired($key);
128-
129-
return;
130127
} catch (DBALException $e) {
131128
// the lock is already acquired. It could be us. Let's try to put off.
132129
$this->putOffExpiration($key, $this->initialTtl);
@@ -135,11 +132,11 @@ public function save(Key $key)
135132
$this->putOffExpiration($key, $this->initialTtl);
136133
}
137134

138-
$this->checkNotExpired($key);
139-
140135
if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) {
141136
$this->prune();
142137
}
138+
139+
$this->checkNotExpired($key);
143140
}
144141

145142
/**
@@ -289,7 +286,7 @@ public function createTable(): void
289286
}
290287

291288
/**
292-
* Cleanups the table by removing all expired locks.
289+
* Cleans up the table by removing all expired locks.
293290
*/
294291
private function prune(): void
295292
{

0 commit comments

Comments
 (0)