Skip to content

Commit 633b776

Browse files
committed
(fix): purge document cache again after transaction commit
The purge inside updateDocument and deleteDocument runs within the transaction, before the write is visible. A concurrent reader landing between that purge and the commit reads the old row and re-caches it, and with no purge following, the stale version is served for up to 24 hours. Purging again after the transaction closes that window.
1 parent 06b2195 commit 633b776

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Database/Database.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6365,6 +6365,9 @@ public function updateDocument(string $collection, string $id, Document $documen
63656365
return $document;
63666366
}
63676367

6368+
// Purge again after commit so readers cannot re-cache the pre-commit version
6369+
$this->purgeCachedDocumentInternal($collection->getId(), $id);
6370+
63686371
if (!$this->inBatchRelationshipPopulation && $this->resolveRelationships) {
63696372
$documents = $this->silent(fn () => $this->populateDocumentsRelationships([$document], $collection, $this->relationshipFetchDepth));
63706373
$document = $documents[0];
@@ -7751,6 +7754,8 @@ public function deleteDocument(string $collection, string $id): bool
77517754
});
77527755

77537756
if ($deleted) {
7757+
// Purge again after commit so readers cannot re-cache the pre-commit version
7758+
$this->purgeCachedDocumentInternal($collection->getId(), $id);
77547759
$this->trigger(self::EVENT_DOCUMENT_DELETE, $document);
77557760
}
77567761

0 commit comments

Comments
 (0)