Skip to content

[Bug]: 409 CONFLICT for durable execution authority expiry has no stable error code #906

Closed

Description

@loveRhythm1990

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) sets owner_pod_id, owner_lease_expires_at (NOW(6) + 45s), and run_generation = 0 atomically in the same INSERT, inside a transaction that is committed (tx.commit()) before persist_run_start returns.
  • Immediately afterward (no DB work in between), stream_chat calls confirm_execution_authority → renew_owner_lease (crates/services/src/runs.rs:22626), whose UPDATE ... WHERE owner_pod_id = ? AND run_generation = ? AND owner_lease_expires_at >= NOW(6) AND status IN (...) AND cancellation_requested_at IS NULL should match the row that was just committed with exactly those values — but on the occurrence I captured, it matched 0 rows, producing Superseded → 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

  1. 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.
  2. 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

  1. added
    kind/bug
    on Sep 28, 2026
  2. loveRhythm1990 commented on Sep 28, 2026

    @loveRhythm1990
    CollaboratorAuthor

    Agent | Codex | model/tier not exposed

    Main-branch verification and scoped fix

    Verified against main at 715d539d21ed3806ded8dd7e3d6452d7e293f85d.

    The missing domain error code is confirmed: all three activation Superseded branches 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:

    • The current database store defaults to a 120-second lease, not 45 seconds. The Server builder uses that default. The 45-second default belongs to the in-memory implementation; the actual QA deployment revision still needs verification.
    • The lease begins at the run INSERT. Execution-slot admission, initial event inserts, display-projection insertion, and commit still follow inside the transaction. The default Server also queries the delegation-projection target after insert/commit before returning from run-start persistence. Thus a successful commit does not imply a newly started, full lease budget.
    • A zero-row renewal can reflect any failed predicate (identity, owner, generation, status, cancellation, or expiry). Superseded alone 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.

  3. loveRhythm1990 commented on Sep 28, 2026

    @loveRhythm1990
    CollaboratorAuthor

    Agent | Codex | model/tier not exposed

    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.

  4. changed the title [-]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[/+] on Sep 28, 2026
  5. loveRhythm1990 commented on Oct 10, 2026

    @loveRhythm1990
    CollaboratorAuthor

    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.

  6. XuPeng-SH commented on Oct 20, 2026

    @XuPeng-SH
    Collaborator

    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.

  7. endlesschasey-ai commented on Nov 6, 2026

    @endlesschasey-ai
    Contributor

    Re-validation request: historical fresh-run failure likely fixed by #1105

    MOI side completed a deep root-cause analysis (matrixflow#17527). Code/commit evidence:

    Ask: please re-validate #906 against post-#1105 origin/main and 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions