Skip to content

Fix deletion worker pagination over retained documents - #14159

Merged
loks0n merged 2 commits into
mainfrom
codex/fix-delete-pagination
Oct 6, 2026
Merged

loks0n merged 2 commits into
mainfrom
codex/fix-delete-pagination

Conversation

@loks0n

@loks0n loks0n commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

When a deletion worker lists at least two full pages of retained documents, listByGroup() keeps the first cursor and rereads the second page indefinitely. In Cloud SFO, deleting a function with 2,837 deployments repeatedly published invalidations for the same 1,000 deployments, filling the edge queue with millions of jobs and preventing deletion from completing. See appwrite-labs/cloud#6322.

Replace the manual pagination loop with the database library’s existing iterate() method. Keep the 1,000-document page size, callback and completion log; remove 22 production lines.

Validation: targeted Pint and PHPStan checks pass. Before removing the regression test from this PR, it was observed failing on the original code at repeated resource sequence 1,001 and passing with the fix on local PHP and in the Appwrite development container. The final diff contains no regression test.

The full Cloud → edge → Redis invalidation path was not run end to end. Production root cause was independently confirmed with a bounded read-only database reproduction, recorded on the incident. Cloud must consume the fixed CE source and deploy the deletion worker before production is repaired; queue eviction and interrupted deletion recovery remain tracked on the incident.

@loks0n loks0n self-assigned this Oct 6, 2026
@ghost

ghost commented Oct 6, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

No concrete defects found in the pagination change or its regression test after checking callers and CI test discovery.

Replaces the deletion worker’s manual pagination loop with the database library’s iterator, preserving the 1,000-document page size, callbacks, and completion logging. Adds a SQLite-backed worker regression that verifies execution retention visits 2,837 functions and one site exactly once without deleting the resources.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
src/Appwrite/Platform/Workers/Deletes.php Uses Database::iterate() in listByGroup() instead of accumulating cursor queries.
tests/e2e/Services/Functions/DeletesTest.php Exercises maintenance pagination with a real SQLite database and detects duplicate retention requests promptly.

Reviewed 17466c3 · 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 S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → codex/fix-delete-pagination (after).

Metric Before After Change
🚀 Requests/sec 192.37 195.64 ⚪ +1.7%
⏱️ Latency P50 87.56 ms 88 ms ⚪ +0.5%
⏱️ Latency P95 221.05 ms 212.25 ms ⚪ -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 88 212.25 12,483 195.64 -8.8
Account 179.83 344.6 657 10.89 +8.41
TablesDB 84.26 159.11 6,789 108.63 -23.03
Storage 82.29 175.33 3,285 54.62 +4.25
Functions 131.78 260.8 1,752 29.77 +18.48

Top API waits (after)

API request Max wait (ms)
account.name.update 504.86
account.prefs.update 470.78
functions.variables.update 391.56
functions.create 381.13
tablesdb.rows.create 364.7

@loks0n
loks0n merged commit 181cd5a into main Oct 6, 2026
49 checks passed
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