Repository navigation
fix(runtime): classify execution authority activation conflicts - #909
mergify[bot] merged 1 commit into
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of e2d6f86: no actionable findings.
Reviewed all three changed files and issue #906, then traced create_run, ordinary streaming activation, idempotent streaming activation, execution-authority confirmation, the database renewal predicate, and HTTP/SSE-to-CLI error handling.
- All three Superseded branches preserve the existing 409 classification and now expose the same stable domain code. The confirmed and storage-error paths, local cleanup, heartbeat startup, and durable recovery behavior remain unchanged.
Supersededcomes from a false renewal result, which does not identify the failed predicate.owner_renewal_not_matchedand the new user message accurately describe that uncertainty; the log records the correct stage, user/session/run identities, and expected generation at each call site.- The durable start precedes these failures. The response correctly omits pre-admission rejection metadata. The SSE adapter preserves the domain code, classifies the conflict by HTTP status, and keeps it non-retryable; CLI admission detection additionally requires
metadata.admission_state == "rejected", so merely adding this code does not turn an already-persisted run into a rejected submission. - The helper adds only error-path formatting/logging, with no extra storage query, lease extension, retry loop, or recovery state.
Validation: git diff --check passed and all workflows for this head passed. Inspected the runtime CI logs: 6,196 tests passed, including both new tests and the existing refused-subrun-activation regression. The new public-entrypoint test exercises all three response branches, verifies the coded response and absence of local execution state, and confirms the idempotent run remains durable. HTTP/admin/settings contract checks also passed.
Limit: Rust/Cargo are unavailable locally, so I did not independently rerun the Rust tests. This review establishes the error-contract/diagnostic change; it does not reproduce or explain the original QA zero-row renewal incident. Keeping #906 open for that investigation is appropriate.
Merge Queue Status
This pull request spent 21 minutes 4 seconds in the queue, including 20 minutes 35 seconds running CI. Required conditions to merge
|
e2d6f86 to
bbb0a46
Compare
## Summary When a database owner-lease renewal matches zero rows, activation currently has a stable error code but only a generic `owner_renewal_not_matched` diagnostic. Add elapsed renewal time, configured lease duration, and a bounded best-effort post-update authority snapshot to identify the state visible after rejection. Reuse the canonical exact-session authority reader and database-clock classifier. Labels cover missing identity/session mismatch, owner/generation mismatch, inactive/cancellation state, expiry at the later snapshot, and authority that is current at that later observation. Both runtime callers pass their exact monotonic attempt deadline. The read uses at most 250 ms and one quarter of the remaining attempt; it is skipped below a 1 ms share. Completed SQL errors release the synchronized connection; only a timed-out exchange discards it. Every diagnostic outcome preserves the rejected result. Successful renewals do not issue a diagnostic query. ## Related issue Refs #906. **This is a diagnostic follow-up, not a claimed fix for the unreproduced QA incident. Keep #906 open.** The confirmed missing-error-code defect was already fixed by merged #909. A zero-row UPDATE alone does not establish its cause, and a later snapshot can race further changes. ## Change type - [x] Bug fix (diagnostic gap) - [x] Documentation - [x] Test ## User and compatibility impact Rejected renewals may spend up to the smaller of 250 ms and one quarter of the remaining caller attempt on diagnostics. Near-exhausted attempts skip the read so an already-known refusal can return without waiting on diagnostics. Existing cancellation and authority fencing remain in force. Logs carry scoped opaque run/session identity and snapshot labels; actual owner pod values are not logged. No schema/config change. ## Architecture and complexity delta - Canonical owner extended: `DatabaseRunStateStore::renew_owner_lease`. - Existing owners inspected: activation confirmation, generation/status/cancellation/lease UPDATE predicates, exact authority reader/classifier, cancellation-safe pooled connection, and durable recovery. - Reuse the existing authority reader/classifier; no alternative ownership decision, new lease state, fallback, or detached diagnostic worker. - The snapshot cannot turn a rejected renewal into authority. Lease TTL, renewal UPDATE predicates, recovery and retry ownership remain with their existing implementations. ## Verification - Local `cargo fmt --all --check` and `git diff --check`: passed. - Local compilation and database tests were not run because the workstation recently froze during builds and is low on disk. The previous head passed its execution lanes; the review-fix head is undergoing fresh CI. No QA incident reproduction pass is claimed. - Added opt-in real MatrixOne regression: a newly inserted run's first renewal succeeds; independently invalidating owner, generation, status, cancellation, lease expiry, or session identity rejects public renewal and asserts the actual emitted `snapshot_reason` for each authority predicate. - Added offline virtual-time regression for a 185 ms attempt, near-spent attempts, timeout and read-failure labels. A live single-slot pool regression checks connection identity reuse after a completed SQL error and replacement after a timed-out read. - Public entrypoint covered: `RunStateStore::renew_owner_lease` on `DatabaseRunStateStore`. - Database verification: new regression requires `ASTRA_TEST_DB_IT=1` with live MatrixOne; retained canonical query is reused. No schema/migration change. This must pass the remote online core-services lane. ## Final checklist - [x] Added owning-layer regression and unhappy-path cases. - [x] Documented diagnostic scope, timeout and evidence limits. - [x] Diff inspected for secrets/private data and generated files. - [x] Conventional Commit title; feature branch based on main. Approved-by: XuPeng-SH <[email protected]>
Summary
Give the three start-activation
Supersededconflicts a stableexecution_authority_not_currentcode and a safe message asking the user to check session status before trying again. Record the activation stage, user/session/run IDs and expected generation in structured logs without asserting that lease expiry was the cause.Related issue
Refs #906. Implements the confirmed error-contract/diagnostic gap described in the correction comment. The QA zero-row renewal incident is not root-caused by this PR; keep the issue open for that investigation.
Change type
User and compatibility impact
HTTP status remains 409;
error_codeis now populated. English response text no longer claims proven expiry. This is not pre-admission rejection: the durable run already exists, so noadmission_state: rejectedor automatic retry advice is added. No schema/config/client changes.Architecture and complexity delta
Verification
cargo test -p astra-runtime --lib refused_activation -- --nocapture: 3 passed, including existing subrun refusal coverage.make format-checkandgit diff --check: passed.cargo clippy -p astra-runtime --lib -- -D warnings: passed.Final checklist