Repository navigation
Conversation
A driver snapshot for an existing sandbox applied through the watch loop pinned the record version it had just read and performed a single CAS. Any concurrent write to the same record between that read and the CAS, such as the supervisor session state written while the sandbox comes up, failed the update with a Conflict, and the watch loop dropped the event with only a warning. Drivers that do not re-emit unchanged sandboxes then kept a stale record until the sandbox changed state again or the reconciliation sweep caught up. Re-enter the full update for a bounded number of attempts on Conflict, so each pass re-reads the record and re-runs the ambiguous-snapshot revalidation; a stale snapshot can no longer overwrite a newer gateway-owned transition such as a concurrent stop. Non-conflict failures still surface immediately, and after the bound the update defers to reconciliation with a warning instead of blocking the sequentially processed watch stream. Closes ai-openshell#5959 Signed-off-by: Emilien Macchi <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Watch-driven sandbox updates performed a single CAS against the sandbox record, so a concurrent write between the update's version read and its CAS failed the update and the watch loop dropped the event with only a warning. This PR retries the update a bounded number of times on a conflict. Each pass re-reads the record and revalidates the snapshot; when the retries run out, the update defers to reconciliation.
Related Issue
Closes #5959
Found while investigating #5954. That issue's invisibility symptom is a separate problem: scoped reads are stateless SQL over columns the watch CAS never touches, and providers and services the watch loop never writes fail the same way. The analysis there points at a masked authorization failure or a workspace-column divergence; pinning it needs the
objects.workspacecolumn value for the failing rows, the client's principal flavor from the gateway logon records, and any OCSF authz-denial findings during the NOT_FOUND window. The dropped-event WARN from that report is what this PR fixes.Changes
apply_sandbox_updateretries aPersistenceError::Conflictup to 3 times, re-entering the full update so each attempt re-reads the record; every retry forces the revalidation path (live driver read), so a stale snapshot cannot overwrite a newer gateway-owned transition such as a concurrent stop or a Starting-to-Ready promotionRelease Notes
Sandbox updates from a compute driver's watch stream now retry when a concurrent write to the same sandbox record makes their store update fail, instead of being dropped with a warning. On drivers that do not re-emit unchanged sandboxes, a dropped update previously left the gateway's record stale until the sandbox changed state again.
Testing
cargo fmt --all --check;cargo clippy --workspace --all-targets --features experimental -- -D warnings;cargo clippy -p openshell-server --all-targets --features test-support,experimental -- -D warnings; fullcargo test -p openshell-server --features test-support,experimental;cargo deny check licenses bans sources; the PostgreSQL-backed server lane. Twelve new tests incompute/tests/error_recovery.rscover: convergence after one conflicting write, revalidation against a concurrent stop, retention of a concurrently promoted Ready row against a stale terminal-failure event, the exhaustion deferral, non-conflict errors surfacing without retry, cleanup-after-CAS failures, the conflict error text at the reconcile call site, head-of-line behavior through the real watch loop, a conflict during the Starting-phase gated path with driver re-query, deferral when the lifecycle gate is held, and the session-probe failure path.Checklist