{{ message }}
Repository navigation
Conversation
…head (appwrite#14420) Collection metadata was previously re-fetched from cache/storage and reconstructed via toCollection() on every database operation, incurring substantial CPU overhead in JSON/array unpacking and object graph construction. This introduces Appwrite\Utopia\Database\Database wrapping Utopia\Database\Database with: - In-process collection memoization within a configurable validation window - Generation token checks to maintain cross-process / cross-node cache coherence - Defensively cloned returns to prevent callers from corrupting the memoized definition - Synchronous local eviction on metadata purge or collection mutation - Transparent bypass during active transactions
Contributor
Contributor
There was a problem hiding this comment.
🟡 Tier B · 2 blocking findings to address. Summary
…eneration around reads - Include adapter hostname in process collection memo key to prevent collisions across multiple database hosts - Capture generation token before metadata read and verify it remains stable after read to guard against race conditions
hansi-codes
Bot
dismissed
their stale review
October 19, 2026 17:06
The findings that requested changes are resolved. See the summary comment for what is still open.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fixes #14420
Collection metadata was previously re-fetched and completely rebuilt (
toCollection()) on every database call, causing ~20–30% API CPU consumption in long-running Swoole worker processes due to repetitive JSON decoding and object tree allocation.Solution
Implemented an in-process metadata memoization layer in
Appwrite\Utopia\Database\Database:getGeneration()) so cross-node updates invalidate stale local entries.purgeCachedDocumentInternal()andpurgeCachedCollection()to invalidate local memo entries when metadata is modified.Appwrite\Database\Factoryto provisionAppwrite\Utopia\Database\Database.Testing
tests/unit/Database/CollectionMetadataCacheTest.php.appwrite/base:2.2.3:OK (20 tests, 59 assertions)PASS (3 files)