Skip to content

fix(deletes): never fall back to the platform database for a missing project - #14812

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/deletes-missing-project
Oct 22, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/deletes-missing-project

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

What

The worker project resource returns an empty document when a queued job's project no longer exists, and the worker getProjectDB mapped an empty project to the platform database. Only the maintenance job guarded against this.

  • Deletes skips 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.
  • The worker getProjectDB returns 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 realtime getProjectDB resources are unchanged; getAudit and the migrations worker already check for an empty project before calling it.
  • The Messaging worker skips external messages for a project that no longer exists, since its dbForProject resource resolves an empty project to the platform database.
  • The maintenance task queued the cache sweep with no project and relied on that fallback to reach the platform cache collection. 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

…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.
@luxor-code-review

luxor-code-review Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 1 medium

💬 Inline comments (1)

  • 🟡 Unguarded delete types now fail forever for deleted projects — message.php:96

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.

Files Change
app/init/worker/message.php Worker getProjectDB now throws Project not found for an empty project; only the console project still maps to the platform DB.
src/Appwrite/Platform/Workers/Deletes.php Adds an empty-project skip guard for DELETE_TYPE_DOCUMENT (exempting projects and rules) alongside the existing DELETE_TYPE_MAINTENANCE guard.
src/Appwrite/Platform/Tasks/Maintenance.php Enqueues DELETE_TYPE_CACHE_BY_TIMESTAMP with the console project so the cache sweep resolves the correct database and app-console cache path; tightens retention signatures to int.

Reviewed commit: 22c4250

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 22, 2026
@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The reviewed changes preserve the intended platform-wide cleanup paths and safely skip work that requires a missing project.

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.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 4
File Change
app/init/worker/message.php Restricts the worker project-database fallback to the console project and rejects missing projects.
src/Appwrite/Platform/Tasks/Maintenance.php Queues the cache sweep against the console project.
src/Appwrite/Platform/Workers/Deletes.php Skips project-dependent jobs when the project is missing, while preserving platform-wide jobs and project/rule document deletes.
src/Appwrite/Platform/Workers/Messaging.php Skips external messaging jobs when their project no longer exists.

Reviewed the commits since fc138f8 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · See the inline comments. Summary

Comment thread app/init/worker/message.php Resolved
…eueing

The worker dbForProject resource resolves an empty project to the platform database, so the lookup and failure update must not run for one.

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread app/init/worker/message.php Resolved

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

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.
@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/deletes-missing-project (after).

Metric Before After Change
🚀 Requests/sec 193.9 194.45 ⚪ +0.3%
⏱️ Latency P50 85.67 ms 90.03 ms 🔴 +5.1%
⏱️ Latency P95 213.8 ms 206.48 ms ⚪ -3.4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 90.03 206.48 12,483 194.45 -7.33
Account 163.93 308.37 657 10.96 -12.74
TablesDB 86.93 159.83 6,789 108.82 -2.65
Storage 83.77 194.12 3,285 53.85 +3.56
Functions 125.2 243 1,752 29.43 -19.19

Top API waits (after)

API request Max wait (ms)
functions.variables.update 540.7
functions.create 441.52
account.name.update 404.69
tablesdb.rows.create 387.56
account.prefs.update 372.63

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@ChiragAgg5k
ChiragAgg5k merged commit 39b6b9c into main Oct 22, 2026
70 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/deletes-missing-project branch October 22, 2026 17:46
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…roject

fix(deletes): never fall back to the platform database for a missing project

(cherry picked from commit 39b6b9c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant