Repository navigation
fix(deletes): never fall back to the platform database for a missing project - #14812
Conversation
…project A delete job whose project was removed after it was queued resolved to an empty project, and the worker's getProjectDB mapped that to the platform database. Document deletes for a removed project are now skipped (its own deletion cleans that data), getProjectDB refuses an empty project, and the cache sweep is queued for the console project instead of relying on the fallback.
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
The change tightens project-to-database routing in workers: an empty project now raises an explicit error rather than quietly using the platform database, which previously masked deleted-project races and misrouted cache cleanup.
Reviewed commit: 22c4250 |
🟢 Tier S · Ready to merge
This PR prevents stale worker jobs from using the platform database when their project has been deleted. It narrows the worker database fallback, skips missing-project messaging and project-specific deletion work while preserving platform-wide cleanup, and queues cache maintenance for the console project. Latest changes: The newest commits consolidate missing-project handling in Deletes into a pre-dispatch guard, preserving platform-wide jobs and project/rule document deletes while skipping other work, and remove the separate maintenance-only guard.
📂 Walkthrough · 4
Reviewed the commits since |
…eueing The worker dbForProject resource resolves an empty project to the platform database, so the lookup and failure update must not run for one.
There was a problem hiding this comment.
This PR makes the worker-side getProjectDB throw on an empty project instead of silently falling back to the platform DB, adds a deleted-project skip guard for DELETE_TYPE_DOCUMENT in the deletes worker, and tags the cache-by-timestamp maintenance message with the console project.
Key findings
- 🟡 Unguarded delete types now fail forever for deleted projects — message.php:96
getProjectDB now refuses an empty project, so a queued job for a deleted project would throw and be redelivered. Only platform-wide jobs and project or rule documents still run without one.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
…roject fix(deletes): never fall back to the platform database for a missing project (cherry picked from commit 39b6b9c)
What
The worker
projectresource returns an empty document when a queued job's project no longer exists, and the workergetProjectDBmapped an empty project to the platform database. Only the maintenance job guarded against this.Deletesskips any job whose project no longer exists, before dispatching on its type. Platform-wide jobs (files, team projects, realtime, schedules, exports, reports) and project or rule documents, which only use the payload and the platform database, still run. The project's own deletion already removes the skipped data. This replaces the separate maintenance guard.getProjectDBreturns the platform database only for the console project and throws for an empty project, so any other job that reaches it for a removed project fails instead of touching platform data. HTTP, CLI and realtimegetProjectDBresources are unchanged;getAuditand the migrations worker already check for an empty project before calling it.dbForProjectresource resolves an empty project to the platform database.cachecollection. It now queues it for the console project, which resolves to the same database and purges files from the console cache directory (app-console), the one the API writes to.Compatibility
A cache sweep message queued by an older maintenance task (no project) is skipped once after the upgrade; the next scheduled run uses the new message. Callers that override
Deletes::action()are unaffected because its signature did not change.Tests
No new test. The affected code is a worker and the worker container resource, which AGENTS.md leaves to e2e coverage, and no
src/library changed. Reproducing the guarded case in e2e would mean deleting a project while a user or bucket delete job for it is still queued, which is a timing race the suite cannot set up deterministically. The existing Users, Storage, Teams, Functions, Sites and project-deletion e2e suites cover the unchanged path where the project exists, including console-project jobs.Related: appwrite-labs/cloud#6673