You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(deletes): retire deployments in small batches to stop worker OOMs - #15122
Deployment retention now deletes in batches of 50 instead of utopia-php/database's default 1,000. deleteByGroup gains an optional $batchSize (defaults to Database::BATCH_SIZE, so other callers are unchanged).
Why
fra1 worker-deletes (1Gi) has been OOMKilled ~5×/hour for over a day. One project's hourly maintenance job retires a large backlog of site deployments:
Retiring deployments of sites <project> by requested retention
└─ deleteByGroup('deployments')
└─ deleteDocuments(batchSize: 1000) ← fetches 1000 full rows incl. buildLogs
The worker dies during the first fetch, so nothing is deleted. The queue retries the job 5 times (30s/2m/10m/10m), and the hourly maintenance enqueues it again, so the backlog never drains. Each kill also drops whatever other deletes jobs were in flight on that worker.
50 rows keeps one batch far below the limit. The throughput cost is negligible because every retired deployment already enqueues its own delete job.
Test
No new test. Per AGENTS.md workers are covered by E2E, and batch size is not observable there. The existing deployment-retention E2E covers the retire path.
This PR updates the shared-tables deletion path in Deletes.php so large deployment collections are removed in batches via deleteDocuments() instead of one at a time, reducing memory pressure and iteration overhead during project cleanup. The new optional batch-size argument is forwarded to deleteDocuments() while preserving tenant scoping and per-row callbacks, and a unit test in DeletesTest.php locks the batching behavior.
Files
Change
src/Appwrite/Platform/Workers/Deletes.php
Switches deployment cleanup to batched deleteDocuments() with a batch-size parameter.
tests/unit/Platform/Workers/DeletesTest.php
Adds a unit test covering the batched deletion path.
Deployment retention now deletes deployment documents in batches of 50. The grouped-delete helper accepts an optional batch size and continues using the database default for other callers.
Verdict
New comments
Fixed
Still open
✅ Approved
0
0
0
📂 Walkthrough · 1
File
Change
src/Appwrite/Platform/Workers/Deletes.php
Sets a smaller batch size for deployment retention and forwards configurable batch sizes through deleteByGroup.
Reviewed a95ad8a · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.
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
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.
What
Deployment retention now deletes in batches of 50 instead of utopia-php/database's default 1,000.
deleteByGroupgains an optional$batchSize(defaults toDatabase::BATCH_SIZE, so other callers are unchanged).Why
fra1
worker-deletes(1Gi) has been OOMKilled ~5×/hour for over a day. One project's hourly maintenance job retires a large backlog of site deployments:Retiring deployments … by requested retentionThe worker dies during the first fetch, so nothing is deleted. The queue retries the job 5 times (30s/2m/10m/10m), and the hourly maintenance enqueues it again, so the backlog never drains. Each kill also drops whatever other deletes jobs were in flight on that worker.
50 rows keeps one batch far below the limit. The throughput cost is negligible because every retired deployment already enqueues its own delete job.
Test
No new test. Per AGENTS.md workers are covered by E2E, and batch size is not observable there. The existing deployment-retention E2E covers the retire path.
Related: appwrite-labs/cloud#6673