From 633b776b3e358a2f53f9f74bea2cc6a146ffd62b Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 10 Jun 2026 10:43:04 +0530 Subject: [PATCH] (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. --- src/Database/Database.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Database/Database.php b/src/Database/Database.php index f9fad6808..1a3a2adf0 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -6365,6 +6365,9 @@ public function updateDocument(string $collection, string $id, Document $documen return $document; } + // Purge again after commit so readers cannot re-cache the pre-commit version + $this->purgeCachedDocumentInternal($collection->getId(), $id); + if (!$this->inBatchRelationshipPopulation && $this->resolveRelationships) { $documents = $this->silent(fn () => $this->populateDocumentsRelationships([$document], $collection, $this->relationshipFetchDepth)); $document = $documents[0]; @@ -7751,6 +7754,8 @@ public function deleteDocument(string $collection, string $id): bool }); if ($deleted) { + // Purge again after commit so readers cannot re-cache the pre-commit version + $this->purgeCachedDocumentInternal($collection->getId(), $id); $this->trigger(self::EVENT_DOCUMENT_DELETE, $document); }