Repository navigation
fix(storage): preserve LockAcquisitionError through write_context (#4612) - #5764
Open
akushonkamen wants to merge 1 commit into
Open
akushonkamen wants to merge 1 commit into
akushonkamen wants to merge 1 commit into
Conversation
volcengine#4612 VikingFS.write_context wrapped every internal failure into a bare IOError without 'from e', destroying the exception type before the semantic queue's lock-retry guards could see it: - the 'except LockAcquisitionError: raise' guards added by volcengine#4615 (semantic_processor._process_memory_directory, semantic_executor) never matched, so lock conflicts fell through to the generic RuntimeError wrap; - the top-level handler treated them as transient/unknown errors and recorded circuit-breaker failures, so clustered lock contention during reindex could open the breaker and take down unrelated VLM calls; - classify_api_error only inspects __cause__ (not __context__), so it classified the wrapped lock error as unknown. - Add 'except LockAcquisitionError: raise' ahead of the generic wrap so lock conflicts keep their type, letting the existing re-enqueue without breaker path work as designed. - Chain the generic wrap with 'from e' so __cause__ carries the original error for classify_api_error and log chains. fixes volcengine#4612
11 of 21 tasks
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.
Description
#4615 (merged 2026-09-08) added
except LockAcquisitionError: raiseguards sothat lock conflicts in the semantic queue are re-enqueued without tripping the
API circuit breaker. On
mainthose guards are defeated at theVikingFS.write_contextboundary: the function's catch-all wraps everyinternal failure into a bare
IOErrorwithoutfrom e, destroying theexception type before any guard can see it:
openviking/storage/viking_fs/_semantic.py(write_context):raise IOError(f"Failed to write {uri}: {e}")— nofrom e, so__cause__is empty and the type is gone.semantic_processor._process_memory_directory'sexcept LockAcquisitionError: raise(fix(memory): preserve semantic lock errors for abstract retries #4615) never matches; the error fallsinto the generic
RuntimeErrorwrap.isinstance(e, LockAcquisitionError)check(
semantic_processor) never matches either, so lock conflicts are treatedas transient/unknown errors: re-enqueued with
breaker.record_failure.Clustered lock contention during batch reindex therefore accumulates breaker
failures and can open the breaker for unrelated VLM calls — matching the
v0.4.20 follow-up in [Bug]: v0.4.17.1 L0 directory abstracts not generated — Lock error wrapping + missing parent rollup #4612 (
internal error: encrypted write lock error: lock acquire timed out after 1001ms).classify_api_error(utils/model_retry.py) walks only__cause__(not
__context__), so it classified the wrapped lock error asunknown.The same wrapping also affects the L0/L1 directory bootstrap path
(
DirectoryInitializer._ensure_agfs_directory→write_context), which iswhere
.abstract.md/.overview.mdcontention surfaces during memorywrites.
This PR is intentionally narrow: it only restores lock-error type
propagation. It does not implement parent rollup / L0 vector backfill
(Bug 2), does not enqueue memory writes into SemanticQueue (deliberate cost
control per maintainer feedback in #4612; open PR #4657 covers that
direction), does not change reindex task terminal states (main already has a
tracker.failpath), and does not touchov backup --include-vectors.Human Involvement
Related Issue
Fixes #4612 (the "lock error type swallowed" residual defect; see scope note above)
Type of Change
Changes Made
In
openviking/storage/viking_fs/_semantic.py,write_context:except LockAcquisitionError: raiseahead of the generic wrap, solock conflicts keep their type and the existing fix(memory): preserve semantic lock errors for abstract retries #4615 guards
(
semantic_processor/semantic_executor"Let SemanticProcessorre-enqueue this recoverable conflict") become effective again.
from e, so__cause__carries the originalerror for
classify_api_error's cause traversal and for log chains.raise IOError(...)wrap points in the same file are left asthey are; they are recorded here as follow-up candidates only
(
_semantic.pyinternal helpers), not changed in this PR.Testing
New tests (
tests/storage/test_write_context_lock_error.py, all offline; thereal mixin methods run against a minimal fake
_async_agfs, no LLM/storage/local config):
write_contextre-raisesLockAcquisitionErrorwhen an internal filewrite hits a lock conflict (message matches the [Bug]: v0.4.17.1 L0 directory abstracts not generated — Lock error wrapping + missing parent rollup #4612 report verbatim:
... lock acquire timed out after 1001ms) — failed before this fix(surfaced as
OSError);before;
IOError, but with__cause__chainedto the original exception (
__cause__wasNonebefore);_process_memory_directoryre-raisesLockAcquisitionErrorunwrapped (the fix(memory): preserve semantic lock errors for abstract retries #4615 guard this fix restores for wrapped paths);
on_dequeuehandling takes the lock-specific requeuepath (
_requeue_semantic_msg_after_error, nobreaker.record_failure),not the transient branch.
Test results (local,
uv run pytest ... --no-cov -q):