Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Version and environment (optional)
Observed against an internal QA deployment of astra-runtime (server + astra-cli), commit tracking matrixorigin/Astra main as of 2026-09-28.
Actual behavior
run/lifecycle has a third family of 409 CONFLICT responses that were not covered by #886 ("fix(run-lifecycle): give conflict 409s stable error codes"). All three come from ExecutionAuthorityConfirmation::Superseded and are returned as plain, uncoded errors:
crates/runtime/src/server/run/lifecycle/mod.rs:15326— "durable execution authority expired before activation"crates/runtime/src/server/run/lifecycle/mod.rs:16112— "durable execution authority expired after idempotent claim"crates/runtime/src/server/run/lifecycle/mod.rs:16988— "durable execution authority expired before streaming activation"
All three use bare error_response(StatusCode::CONFLICT, "...".to_string()), unlike the two families #886 fixed (session_execution_slot_occupied, run_intent_run_terminal), which use error_response_coded(...) with a stable error_code. Clients hitting this 409 have no machine-readable way to distinguish it from any other 409 — they can only pattern-match the free-text message.
Separately, and this is the part I have not been able to root-cause, I observed the underlying Superseded condition fire on a request's very first lease confirmation, immediately after its own successful run insert. Tracing the relevant code:
insert_run_row_tx(crates/services/src/runs.rs:13676) setsowner_pod_id,owner_lease_expires_at(NOW(6) + 45s), andrun_generation = 0atomically in the same INSERT, inside a transaction that is committed (tx.commit()) beforepersist_run_startreturns.- Immediately afterward (no DB work in between),
stream_chatcallsconfirm_execution_authority→renew_owner_lease(crates/services/src/runs.rs:22626), whoseUPDATE ... WHERE owner_pod_id = ? AND run_generation = ? AND owner_lease_expires_at >= NOW(6) AND status IN (...) AND cancellation_requested_at IS NULLshould match the row that was just committed with exactly those values — but on the occurrence I captured, it matched 0 rows, producingSuperseded→ the 409 above.
This happened during a window where the backing MatrixOne database was independently showing elevated latency (many single-row SELECT ... FOR UPDATE / INSERT IGNORE statements taking 1.5–5s instead of the expected low milliseconds). I was not able to determine from application-level logs alone whether this is a genuine concurrent writer for the same run_id, or a read-consistency/replication-visibility gap between the commit and the subsequent read under load. I did not find a second writer in the available HTTP-access-log-level traces, but those don't have run_id-level granularity.
Expected behavior
- This 409 family should carry a stable
error_code(e.g.durable_execution_authority_expired, possibly split per variant), matching the pattern fix(run-lifecycle): give conflict 409s stable error codes #886 already established for the other two conflict families. - Separately, worth understanding whether a freshly-inserted run's own first lease-renewal should ever legitimately fail this fast under normal (non-crash, non-explicit-cancel) conditions — if not, there may be a real race or a MatrixOne read-consistency issue under load that deserves its own investigation, distinct from the error-code gap.
Steps to reproduce
I don't have a deterministic repro. The one occurrence I traced happened when submitting a chat message via POST /chat/stream during a period of measurably elevated database latency on the backing store. I was not able to isolate a minimal reproduction.
Additional information
Sanitized log line for the occurrence I traced (hostnames/paths redacted, only opaque identifiers kept):
{"level":"WARN","fields":{
"message":"sse error response emitted to client","http_status":409,"error_code":"CONFLICT",
"retryable":false,"domain_error_code":"",
"session_id":"49a69ce0-11f6-46ea-bdcd-28ac14eca567","run_id":"",
"message":"durable execution authority expired before streaming activation"},
"span":{"http.method":"POST","http.route":"/chat/stream"}}Happy to share more detail if useful, but I'd flag that the root-cause half of this issue is an open question, not a confirmed diagnosis — the error-code gap is the part I'm confident about.
Activity
loveRhythm1990 commentedon Sep 28, 2026
Main-branch verification and scoped fix
Verified against
mainat715d539d21ed3806ded8dd7e3d6452d7e293f85d.The missing domain error code is confirmed: all three activation
Supersededbranches still return a bare HTTP 409. The planned fix adds one stable execution-authority-not-current code, a safe user message, and structured diagnostics identifying the activation stage, run, session, and expected generation. Tests will cover all three response sites. No lease duration, locking, renewal, retry, cancellation, or recovery behavior will change.Corrections to the initial investigation:
Supersededalone does not prove lease expiry, a competing writer, or a MatrixOne visibility defect.This PR will address the confirmed error-contract/diagnostic gap, not claim to reproduce or eliminate the QA incident's underlying cause. The historical root-cause investigation remains open pending correlated timings and durable row evidence. The new error must not declare pre-admission rejection: the run was already persisted, and the existing recovery owner remains responsible for it.
loveRhythm1990 commentedon Sep 28, 2026
Implemented the confirmed error-contract and diagnostic gap in #909, based on current main. All three activation entrypoints now return
execution_authority_not_current, not an unproven expiry claim. Focused lifecycle tests (3) and runtime library Clippy pass locally.This PR deliberately does not close this issue: the QA zero-row renewal occurrence still needs timestamp/predicate evidence to determine its cause. Lease TTL, SQL/locks, retries and durable recovery are unchanged. No QA deployment has been performed.
[-]409 CONFLICT for durable execution authority expiry has no stable error code[/-][+][Bug]: 409 CONFLICT for durable execution authority expiry has no stable error code[/+]fix(runtime): classify execution authority activation conflicts (#909)
loveRhythm1990 commentedon Oct 10, 2026
The missing stable 409 error code was fixed by merged #909 (
execution_authority_not_current). The separate QA report that a newly created run fails its first owner-lease renewal is still not reproduced or explained, so this issue remains open.Opened #972 as a diagnostic follow-up: a zero-row renewal logs elapsed time, configured lease duration, and a bounded best-effort snapshot through the existing exact-session, database-clock authority reader. The snapshot can distinguish the state visible after rejection (owner/generation mismatch, inactive/cancelled, expired, or missing identity), but it cannot prove which predicate caused the earlier UPDATE to fail.
This does not retry or grant ownership after a rejected renewal. Added an opt-in MatrixOne regression covering a successful first renewal and rejection after invalidating each authority predicate. Local formatting and diff checks passed; remote CI is pending. A QA reproduction on the deployed version, correlated by run/session and time with server diagnostics, is still needed before calling the renewal incident resolved.
fix(runtime): diagnose rejected owner lease renewals (#972)
XuPeng-SH commentedon Oct 20, 2026
Scope reconciliation: merged #909 fixed the stable execution_authority_not_current code, and #972 added bounded post-rejection diagnostics. Those changes do not establish the cause of the historical first-renewal rejection: a later snapshot cannot identify the earlier failed predicate. Keep this issue for a correlated reproduction with exact deployed revision/configuration and insert/commit/confirmation timing; no speculative lease increase or authority bypass is justified.
endlesschasey-ai commentedon Nov 6, 2026
Re-validation request: historical fresh-run failure likely fixed by #1105
MOI side completed a deep root-cause analysis (matrixflow#17527). Code/commit evidence:
execution_authority_not_currentis the unified 409: the durable run exists, but this activation cannot prove it still holds current authority. It is not a lease expiry.UPDATE agent_runs) could run on a different pooled connection whose MatrixOne CN snapshot lagged the just-committed INSERT → 0 rows →Superseded→ 409, while the lease TTL was still ~120s.d39864bc(2026-10-21, "activate new runs from committed owner leases", Fixes matrixflow#19270) independently identified this same mechanism — PR body: "a different MatrixOne CN snapshot can lag that commit". The fix returns the committed owner-lease receipt from creation so fresh runs no longer re-renew, and exact retry goesExisting→ stream attach.idc-20261103T041458Z-b19416d5…(2026-11-03) contains fix(runtime): activate new runs from committed owner leases #1105 (ancestor check); there are no commits touchingexecution_authority_not_currentbetweenb19416d5and currentorigin/main(git log -S).Ask: please re-validate #906 against post-#1105
origin/mainand either close it or re-scope it to the residual windows. The residual windows still visible in code are: creation receipt expiry >105s, local fence loss during preparation, binding CAS after cloud provisioning, and resume/recovered-child renewal.If it is re-scoped, the diagnostics needed to pin a future occurrence are: the 0-row updated row snapshot (owner_generation/authority/lease columns),
CONNECTION_ID()/CN identity, INSERT/commit/renew timestamps, a same-connection read probe after the 0-row result; and in the 409/SSE frame:run_id,stage,retryable. That lets MOI do a bounded retry/attach instead of probing blindly.Cross-refs: matrixflow#17527, matrixflow#19270.