Repository navigation
Commit 2c436bf
feat(api): routing-after-tx go-live + guarded routing publishers (#181)
* feat(api): routing-after-tx go-live + guarded routing publishers
Rewrite deploy/rollback routing consistency, split out of the
Deploy-on-GitHub branch (PR #179):
- routing KV is written only AFTER the go-live DB commit; a failed
in-tx check publishes zero routing (no rollback class)
- durable `routing_published` marker on deployments (migration 0026)
+ hourly live-routing reconciler heals degraded publishes
- all routing publishers serialize on the project FOR UPDATE lock and
re-check active-ness before writing (deploy, rollback, domains,
suspension, retention, cron sync, queue-token backfill)
- domain activation claims its row conditionally; deletion runs under
the project lock; stale queue routes are swept uniformly
- rollback derives serving type from the target deployment's manifest,
not the project's current type
Migration note: 0026_cuddly_lilith keeps its original journal identity
(when=1780982697858) so environments that already applied it (staging)
skip it and fresh environments apply it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(api): exempt explicitly-unpublished rows from the reconciler recency window
Review finding (P1): rollback to a target older than 24h clears
routing_published without touching deployed_at, so a failed post-commit
publish left the active deployment permanently invisible to the hourly
reconciler — dispatch would serve stale/missing KV forever.
The recency window now bounds only legacy NULL-marker rows (the one-time
backfill mass). Rows explicitly marked false (sole writer:
markRoutingUnpublished in the rollback go-live tx) are always eligible —
the set is bounded by the active-pointer join and self-clears on heal.
deployed_at stays untouched: it is ever-went-live history used by
retention/admin.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(api): treat a deleting/missing project as superseded in the routing publish chokepoint
A parked deploy/rollback publisher — or the hourly reconciler — resuming during
teardown (after teardownProject set status='deleting' and deleted the routing KV
entries, but before deleteProjectCascade removed the row) re-passed the
pointer-only active check in publishRoutingIfStillActive and re-created the
slug/domain:*/queue:* routes, leaving permanent orphan routes the reconciler
could never heal once the row was gone.
publishRoutingIfStillActive now re-reads projects.status under the project lock
(new lockProjectForPublish sibling, leaving the shared
lockProjectAndGetActiveDeploymentId untouched) and returns 'superseded' when the
row is missing or status='deleting'. getRecentlyLiveActiveDeployments also
excludes deleting projects so the reconciler never selects them.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(api): lock routing-suspension fan-out + handle rollback publish rejection
setProjectsRoutingSuspension did a lock-free per-key get→modify→put. A
suspender's pre-publish snapshot could overwrite a concurrent publisher's
fresh route after it set routing_published=true, leaving permanently stale
routing the reconciler skips (it heals only unpublished rows). Wrap the
slug + domain fan-out in one project FOR UPDATE lock tx — the same lock
publishers hold — so `suspended` is folded onto the re-read fresh route.
Closes the cursor "Unguarded suspension clobbers routing" finding and the
codex "Wire suspension updates through the guarded RMW" finding (same race).
The rollback handler's post-commit publishRoutingIfStillActive await sat
outside any catch: a transient Hyperdrive/lock error after the go-live
commit returned 500 for an already-committed rollback, prompting users to
retry a completed operation. Treat a thrown helper the same as a 'failed'
publish so the row stays routing-unpublished and the hourly reconciler
heals it; the endpoint returns success/degraded.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(api): refuse domain activation while project is deleting
tryActivateDomain took the project FOR UPDATE lock but never re-read
status, so a pending-domain verification interleaving with
teardownProject could re-PUT domain:<host> for a project about to be
cascade-deleted, leaving an orphan route the reconciler can't heal
(teardown deletes slug/domain KV lock-free, then cascade-deletes rows
last). Swap lockProjectAndGetActiveDeploymentId -> lockProjectForPublish
and bail (write nothing, claim nothing) on a missing/deleting project,
mirroring publishRoutingIfStillActive's same-lock guard.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 0bdedb9 commit 2c436bf
28 files changed
Lines changed: 9052 additions & 856 deletions
File tree
- .github/workflows
- packages/api
- drizzle
- meta
- src
- admin
- routes
- observability
- provisioning
- routes
- test
- integration
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments