Skip to content

fix(builds): persist readiness across cache eviction - #15135

Merged
loks0n merged 9 commits into
mainfrom
codex/durable-build-callbacks
Nov 2, 2026
Merged

loks0n merged 9 commits into
mainfrom
codex/durable-build-callbacks

Conversation

@loks0n

@loks0n loks0n commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Successful Sites and Functions builds can remain building if a readiness marker disappears from cache. Readiness now joins existing deployment fields with the stored output artifact; cache is used only for event deduplication.

  • Exit records buildDuration, including zero runtime. Complete records buildEndedAt.
  • Queuing clears inherited duration, completion and adapter results, including duplicate deployments. Manifest processing writes static or ssr; an empty/failed manifest retains the configured site adapter or uses the static default. Configured fallback files are preserved.
  • Success requires duration, completion, a processed site adapter and stored output. Failures terminate immediately; a later exit supplies measured runtime.
  • Finalization decides the outcome before one guarded terminal update, with the latest-deployment pointer, activation and site adapter pinning in the same transaction. Log append and deduplication retain their existing transaction protection.

No new attribute, schema preparation or migration is required. Drain builds before replacing Jobs consumers: previously queued deployments can contain an inherited adapter, and mixed worker versions use different completion semantics. Already-lost callbacks require reconciliation or rebuilding. Cloud rollout is tracked in appwrite-labs/cloud#7123.

Validation: Deployment library suite passed (51 tests), plus 24 temporary public-worker scenarios covering reordered callbacks, cache loss, zero runtime, delayed unmeasured exits, manifest failures, adapter races, cancellation and retries. JobsCallbacksTest remains deleted from the repository as requested. Targeted Pint, PHPStan, Rector and monorepo validation passed. CI runs the existing Functions and Sites E2E lanes; the temporary SQLite/storage checks do not replace a staging drill through the real orchestrator, queue, S3 and Cloud edge distribution.

Related: appwrite-labs/cloud#7123

@loks0n loks0n self-assigned this Oct 30, 2026
@luxor-code-review

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

Copy link
Copy Markdown

Review complete. 🟡 1 medium

💬 Inline comments (1)

  • 🟡 Adapter mismatch missed when site adapter pre-set before manifest — Jobs.php:784

Build-job callback deduplication moves from ephemeral cache markers to a persisted string-array callbacks attribute, so at-least-once queue redeliveries are deduplicated after the handler applies rather than before. The Jobs worker is restructured around that: detect() now runs on the manifest callback before success, finalization happens inside a withTransaction block that pins the site adapter under a row lock, and onExit seals failed exits earlier. The schema change ships as a V25 migration adding the attribute to every project's deployments collection, with a phpunit.xml tweak enabling the new SQLite-backed suite.

Files Change
src/Appwrite/Platform/Modules/Functions/Workers/Jobs.php Rewrites callback handling to dedupe via the persisted callbacks array, moves detect() before success, and finalizes deployments inside a transaction with adapter pinning
app/config/collections/projects.php Adds the callbacks string-array attribute (size 16, default []) to the deployments collection
src/Appwrite/Migration/Version/V25.php Creates the callbacks attribute per project, warning-and-continuing on existing/duplicate attributes
tests/e2e/Services/Functions/JobsCallbacksTest.php New SQLite-backed e2e suite pinning dedup-after-apply, readiness join, and mismatch/cancellation semantics
phpunit.xml Registers the new test suite

Reviewed commit: 5db39a2

@ghost

ghost commented Oct 30, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Build readiness is derived from persisted deployment state and the stored output artifact, while cache remains responsible for callback deduplication. Callback processing persists build duration and completion, updates terminal deployment state and activation together, and resets build-specific fields when deployments are queued. The deployment unit test covers reset behavior and callback subscription for manual uploads.

Latest changes: The newest commits clear inherited build duration and completion timestamps when queuing a deployment and assert that both values are reset by the upload flow.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
src/Appwrite/Deployment/Deployments.php Reset build duration and completion timestamps alongside the adapter when queueing builds.
src/Appwrite/Platform/Modules/Functions/Workers/Jobs.php Persist readiness inputs, reconcile callbacks with stored output, and finalize deployment outcome and activation transactionally.
tests/unit/Deployment/UploadCallbacksTest.php Verify queued upload state clears inherited build results while retaining the fallback file and artifact callback subscription.

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

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

@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

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → codex/durable-build-callbacks (after).

Metric Before After Change
🚀 Requests/sec 216.36 222.08 ⚪ +2.6%
⏱️ Latency P50 78.64 ms 78.56 ms ⚪ -0.1%
⏱️ Latency P95 189.85 ms 178.79 ms 🟢 -5.8%
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 78.56 178.79 13,680 222.08 -11.06
Account 141.74 268.66 720 12.36 +4.41
TablesDB 77.09 150.57 7,440 122.9 -7.54
Storage 69.81 164.27 3,600 61.43 -6.87
Functions 106.96 197.17 1,920 33.49 -16.2

Top API waits (after)

API request Max wait (ms)
functions.delete 389.01
account.name.update 387.09
tablesdb.rows.create 359
storage.buckets.create 341.11
functions.create 333.26

@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

@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 replaces the in-memory cache markers used to deduplicate Functions build-job callbacks with a persisted callbacks attribute on deployments, restructures detection and finalization in the Jobs worker, adds the V25 migration and collection-schema entry, and pins the new contract with a dedicated e2e suite.

Key findings

  • 🟡 Adapter mismatch missed when site adapter pre-set before manifest — Jobs.php:784

@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

@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

@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

@loks0n
loks0n merged commit bb0f131 into main Nov 2, 2026
65 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