Skip to content

fix(ingest): retry transient storage unavailability during session commit (#4494) - #4621

Open
now-ing wants to merge 2 commits into
volcengine:mainfrom
now-ing:fix/iss-4494-backfill-transient-retry
Open

now-ing wants to merge 2 commits into
volcengine:mainfrom
now-ing:fix/iss-4494-backfill-transient-retry

Conversation

@now-ing

@now-ing now-ing commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Root cause

ingest backfill calls SessionReplayer.commit_if_needed once per session. When commit_session hits a transient path-lock conflict — the report shows Windows ERROR_LOCK_VIOLATION (os error 33) on .../.path.ovlock mapped to UnavailableError("Storage backend unavailable: internal error: lock error") — the exception propagates to the orchestrator's per-session except, which logs [ingest:codex] session <id> failed and moves on. Nothing retries the commit: on a 597-session / 50,099-message backfill, one flaky lock permanently cost that session its memory extraction (the run ended with 1 errors).

The append path is already crash-safe (persisted batch intent + reconcile()), but the commit step had no equivalent tolerance for transient storage errors.

Fix

commit_if_needed and maybe_commit_on_threshold now route through a new _commit_with_retry helper:

  • Retries are scoped to UnavailableError — the class the server maps transient lock/IO conflicts to. Deterministic failures (NotFoundError, validation errors, …) keep their current raise-through semantics.
  • Bounded backoff: 5s / 20s / 60s (initial try + 3 retries, ~85s worst case), chosen to ride out brief cross-process lock holders without stalling a long backfill.
  • Each retry logs a warning with session id and attempt count, so transient flakiness stays visible in backfill output.
  • Delays are injectable via SessionReplayer(commit_retry_delays=...) for tests; default is a module constant.
  • If retries are exhausted the error still surfaces, and the cursor store's needs_commit flag remains set — a subsequent backfill run picks the session up again.

How verified

  • 3 new regression tests in tests/ingest/test_replay.py (fast, conftest-free):
    • commit failing twice with UnavailableError then succeeding → commit lands, needs_commit cleared, exactly 3 client calls;
    • persistent unavailability → UnavailableError raised after initial + 3 retries, needs_commit still set for a later run;
    • non-transient ValueError → raised on the first call, no retry.
  • Full file: 11 passed (8 pre-existing + 3 new), no behavior change on the green paths.

…mmit (volcengine#4494)

A single transient path-lock conflict during commit_session (surfacing as
UnavailableError, e.g. Windows ERROR_LOCK_VIOLATION on .path.ovlock) silently
cost one backfilled session its memory extraction: the orchestrator logged it
and moved on, and nothing retried the commit later.

commit_if_needed and maybe_commit_on_threshold now route through
_commit_with_retry, which retries only UnavailableError with a bounded backoff
(5s/20s/60s by default, injectable for tests). Deterministic failures keep
their current raise-through semantics; the store's needs_commit flag stays set
while retries are exhausted so a later run can still pick the session up.
maybe_commit_on_threshold routes through _commit_with_retry too but no
test executed it: adds a transient-failure retry case and a
below-threshold no-op case.
@now-ing

now-ing commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Heads-up for triage: #4661 (unified model retry boundaries) deletes the session-layer _run_retryable_phase2_step wrapper that this PR builds around — its approach is "retry transient failures once more at the session-commit layer", while #4661 moves the retry budget entirely into the provider layer and turns Phase 2 step failures terminal (archive marked failed, no .done marker).

If #4661 lands first, this PR's retry loop becomes dead code and the PR should be narrowed to whatever survives (the session commit retryable classification and telemetry are still relevant). If this lands first, #4661 will need a small rebase here. Either way the two are mutually exclusive on the retry part — flagging so the ordering can be decided once instead of twice.

@now-ing

now-ing commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Cross-linking for reviewer/maintainer awareness: #4729 (fix(ingest): reconcile ambiguous session commits) landed today and touches the same commit_if_needed call site as this PR. I reviewed it in detail — the two are complementary, not overlapping:

  • this PR: retry only transient UnavailableError (5s/20s/60s) at the commit call site;
  • fix(ingest): reconcile ambiguous session commits #4729: on any commit exception, re-read pending_tokens and treat zero as "the commit actually landed", clearing needs_commit instead of risking a duplicate submission on the next pass.

If this PR merges first, #4729 will rebase its try/except wrapper around self._commit_with_retry(...) (exact merged shape posted in my review there: #4729 (comment) — see the review comment). If #4729 merges first, this PR's _commit_with_retry drops in as the inner call unchanged. Either order converges to the same behavior; happy to do the rebase leg on whichever side is second if maintainers prefer.

This branch has not been deployed

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant