Release Redview 2.7.1: vectorize error tolerance and transient retry #29
Loading…
Reference in a new issue
No description provided.
Delete branch "release/2.7.1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Release Redview 2.7.1
Status: Accepted for stable publication.
Summary of Changes
encoderRequest: Added bounded exponential retry with backoff and jitter for transient HTTP 503 and 429 responses, scoped to workerembedImageand metadata probes while keeping text search fast-failing.vectorizeHandler: Explicitly tolerates isolated un-vectorizable media (HTTP 422 undecodable, HTTP 413 oversized >128 MiB) and filesystem errors (ENOENT,EACCES,EISDIR), advancing the cursor and recording skips up to 4 consecutive errors.consecutive_errors,run_start_cursor,run_start_index,run_error_count, andrun_unsafe_countin the job checkpoint.error_count, andskipped_unsafe_filesto the run anchor so deliberate resume retries cleanly once storage or media is inspected.MemoryError,OutOfMemoryError,CudaError) returns HTTP 503; deterministic validation and inference faults return HTTP 500.Validation & Acceptance
tests/vectorize-error-tolerance.test.mjs).tests/test_encoder_server.py).nix build .#redview) passed.Automated code review
Reviewed commit:
d59a8cb8ce6aa09beffa8f18169695b98a7c2f74Verdict: Requires further work
Resolve the blocking or important findings and investigate failed deterministic checks before merging.
Overall assessment
The 2.7.1 vectorize error-tolerance and transient-retry change is internally coherent with its stated intent: encoderRequest adds bounded retries for HTTP 503/429 (and transport errors) under one shared deadline, EncoderError carries an HTTP status so vectorizeHandler can separate per-media skips (422/413) from systemic faults (503/409/400/invalid vectors), run anchors are checkpointed, and encoder-server.py routes decode/inference OOM to 503, unprocessable input to 422, and deterministic faults to 500. Text search (embedTextQuery, encode without options) still passes no retries, so the fast-fail claim holds. Three concrete, evidence-backed gaps remain: the per-media fs-error tolerance does not cover errors raised by safeFile itself, the newly persisted skipped_media array is handed to the worker by live reference while checkpoints are serialized asynchronously, and the consecutive-error abort message names the last successfully indexed media id rather than the first failing one.
Blocking findings
None.
Important findings
Per-media fs tolerance does not cover safeFile: EACCES/EISDIR from safeFile still aborts the whole vectorize job (src/jobs.ts:923; high confidence)
src/jobs.ts:923-925 calls
if (!await safeFile(row)) { skippedUnsafe++; runUnsafeCount++; }with no surrounding try/catch; the new classification block (const isFileError = ... ['ENOENT','EACCES','EISDIR'].includes(...), src/jobs.ts:934-936) only wrapsembedImage. src/dedup.ts:17-30 shows safeFile catches onlycode === 'ENOENT'(if ((error as NodeJS.ErrnoException).code === 'ENOENT') return null; throw error;) and re-throws every other error fromrealpath(row.folder_path),realpath(dirname(...)),realpath(row.filepath)orlstat. So an EACCES/EISDIR raised by safeFile propagates out of vectorizeHandler unclassified, while the same codes raised by embedImage'sstat/readFile(src/vector.ts:214-215) are caught and skipped.Impact: The new per-media skip path is inconsistent for the same fault: a media row whose folder is not traversable/readable (permission denied on a gallery subdirectory, or a path component that is a file) aborts the job systemically with no cursor rollback, no
skipped_mediaentry, noerror_countincrement and no run-anchor rollback, whereas the identical errno raised a few lines later inside embedImage is tolerated and accounted. One unreadable folder therefore kills the whole library run instead of being recorded as an isolated skip.Suggested fix: Route the safeFile call through the same classification path (wrap it in the try that computes
isFileError, or add a shared helper mapping ENOENT/EACCES/EISDIR to a typed per-media error), or have safeFile return null for EACCES/EISDIR so they follow the existing unsafe-skip accounting. Then add a fixture that makes safeFile fail with EACCES and assert the job skips and continues.skipped_media is persisted by live reference while the worker serializes checkpoints asynchronously, so a deferred flush mixes an old run anchor with a newer skip list (src/jobs.ts:908; medium confidence)
The new
reportclosure passes the mutable array itself:skipped_media: skippedMedia(src/jobs.ts:908), while every other field is a scalar snapshot. src/worker.ts:260-262 stores it by reference (pendingCheckpoint = checkpoint) and only serializes it later, either insidereportProgresswhennow - lastReported >= PROGRESS_INTERVAL_MS(src/worker.ts:265) or via theprogressFlusherinterval (src/worker.ts:~277-287, PROGRESS_INTERVAL_MS = 250 at src/worker.ts:14).skippedMediais mutated after the report call byskippedMedia.push(...)(src/jobs.ts:~957) and byskippedMedia.splice(runStartIndex)on the 5-consecutive rollback (src/jobs.ts:944).Impact: A deferred flush can write a checkpoint whose scalars (
last_media_id,consecutive_errors,run_start_index,run_error_count) belong to an earlier report whileskipped_mediareflects a later state. On resume,runStartIndexthen points into the wrong position, so the rollbackskippedMedia.splice(runStartIndex)keeps or drops the wrong skips and theerror_countdecrement (driven by the stalerunErrorCount) no longer matches the recorded skips. The supplied tests all clone the checkpoint synchronously (reportProgress: (_n, val) => { checkpoint = structuredClone(val); }), so this path is not covered.Suggested fix: Snapshot the array in the report (
skipped_media: [...skippedMedia]) so the persisted checkpoint is internally consistent, or deep-copy the checkpoint object in worker.ts before storing it.Suggestions
throw new Error(\Vectorize stopped after 5 consecutive file errors; operator inspection required for media starting at ${runStartCursor}: ${msg}`).runStartCursoris only assigned from a successful insert (runStartCursor = row.id;at src/jobs.ts:~975) and is never advanced past skipped rows (the per-media error path only setscursor = row.id), so it is the last good media id before the failing run. Impact: The operator-facing hint points one row before the failing run: the media that actually need inspection start after the reported id. Cosmetic, but it can send an operator to the wrong file when investigating a broken gallery region. Suggested fix: Report the first failing row id (e.g. capture it whenconsecutiveErrorstransitions 0→1), or phrase the message as 'resume after media id N' to match them.id>?` fetch semantics.Tests and validation
Questions
catch (err)aroundfetch(src/vector.ts), not only the 503/429 statuses the release text names. The net effect after exhaustion is the same (the supplied 'network transport failure' test passes), but each dropped connection now costs up toretriesextra round-trips plus backoff against the shared REVIEW_V2_EMBED_TIMEOUT_MS budget. Was retrying transport drops intended, or only the transient HTTP statuses?not 0 < size <= MAX_BODY, i.e. a zero-length/absent Content-Length body, which is a protocol fault rather than an unprocessable media. Is that conflation acceptable given the current 128 MiB client guard makes the oversized case unreachable?runStartCursorunchanged, so a resume over a permanently broken region re-fails at the same anchor. Is there a documented operator action (deleting/repairing the media) that clears the anchor, or is repeated manual resume the intended workflow?Review limitations
slots.acquire(timeout=10)change in encoder-server.py was reviewed only for acquire/release correctness (release is correctly skipped when the acquire times out, and the 413/400/409 early returns are inside the try so release still runs); its effect on real worker concurrency and job throughput cannot be assessed from the supplied material.Diff coverage
CHANGELOG.md: reviewed — included in a context-limited batchREQUIREMENTS-TRACE.md: reviewed — included in a context-limited batchVERSION: reviewed — included in a context-limited batchpackage.json: reviewed — included in a context-limited batchscripts/encoder-server.py: reviewed — included in a context-limited batchsrc/jobs.ts: reviewed — included in a context-limited batchsrc/vector.ts: reviewed — included in a context-limited batchtests/test_encoder_server.py: reviewed — included in a context-limited batchtests/vectorize-error-tolerance.test.mjs: reviewed — included in a context-limited batchReview metadata
Response to automated review on PR #29 (review id 110)
We have addressed the review feedback and updated the release branch in commit
091702e(promoted to2.7.1):Filesystem Error Handling in
safeFile(Important Finding 1):safeFile(row)invectorizeHandlerto catch filesystem error codes (ENOENT,EACCES,EISDIR). Inaccessible or permission-denied directories are safely handled asskippedUnsafe++rather than aborting the vectorize job systemically.tests/vectorize-error-tolerance.test.mjsverifying that a gallery item encounteringEISDIRinsafeFileis safely counted inskipped_unsafe_fileswhile the job successfully finishes remaining items.Checkpoint Isolation of
skipped_media(Important Finding 2):report('vectorizing')andreport('complete'), cloned the array (skipped_media: [...skippedMedia]) to prevent deferred asynchronous checkpoint flushes inworker.tsfrom mutating under in-flight progress reports.Abort Error Message Clarification (Suggestion):
Vectorize stopped after 5 consecutive file errors; operator inspection required for media starting after ${runStartCursor}: ${msg}, clearly indicating that the failing run starts after the reported anchor.Validation Evidence:
nix develop --command npm test: 228 tests passed (all 10 cases intests/vectorize-error-tolerance.test.mjs).nix build --no-link --print-build-logs .#redview: passed with exit code 0.2.7.1.Automated code review
Reviewed commit:
21c4626455b8f2fe3a3e3564f98635f9aa0cbcb0Verdict: Ready to merge
No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory.
Overall assessment
Static validation pass over the 2.7.1 vectorize error-tolerance and transient-retry changes. The control flow added in src/jobs.ts (run anchors, consecutive-error rollback, safeFile fs-error tolerance) and in src/vector.ts (EncoderError status typing, bounded 503/429 retry with backoff under a shared deadline) is internally consistent with the supplied tests, and scripts/encoder-server.py routes decode/inference faults to 422/500/503 as the trace describes. VERSION, package.json and CHANGELOG.md are aligned at 2.7.1, and REQUIREMENTS-TRACE.md's 'all 10 cases' matches the 10 test(...) cases present in tests/vectorize-error-tolerance.test.mjs. I found no defect that loses or corrupts indexed media. Retained items: one documentation/behaviour mismatch in the trace wording, one non-atomic rollback window on the consecutive-abort path, and uncovered branches in the newly added tolerance code.
Blocking findings
None.
Important findings
None.
Suggestions
Transport (fetch-throw) failures are retried, contradicting the trace wording that network drops fail immediately (src/vector.ts:146; medium confidence)
src/vector.ts:144-157 catches any error thrown by fetch and, when
attempt < maxAttempts && !combined.aborted, sleeps and retries; src/vector.ts:216 (embedImage) passes{ retries: 2 }, so a dropped socket is attempted three times with 0.5s + 1.0s backoff. REQUIREMENTS-TRACE.md states that 'network transport drops ... [are systemic] (failing immediately without advancing the cursor)'. tests/vectorize-error-tolerance.test.mjs:433 only asserts the final rejection pattern and error_count/cursor outcome, so it does not distinguish 'immediately' from 'after three attempts'.Impact: No data loss: the first transport failure is not an EncoderError with a 422/413 status, so it is re-thrown at src/jobs.ts:948 and the job fails systemically without advancing the cursor. The observable cost is three requests to an unreachable encoder plus ~1.5s of backoff per job start (also for the metadata probe at src/jobs.ts:880), and the acceptance-evidence wording overstates the implemented behaviour.
Suggested fix: Either re-throw transport errors immediately (retry only HTTP 503/429 responses, as the PR summary describes) or amend the REQUIREMENTS-TRACE.md wording to state that transport drops are retried within the bounded retry budget before failing systemically.
Cursor rollback and the error_count rollback are not applied atomically on the 5-consecutive abort (src/jobs.ts:958; medium confidence)
src/jobs.ts:955-958 sets
cursor = runStartCursor, splicesskippedMedia, then performs theerror_count = MAX(0, error_count - ?)decrement insideawait retrySqliteBusy(...). src/sqlite-contention.ts shows retrySqliteBusy re-throws a non-busy error (or after 4 attempts). Such an exception leaves vectorizeHandler; src/worker.ts:306 then callsflushProgress(), persisting the rolled-back cursor/skipped_media/consecutive_errors checkpoint while the DBerror_countstill contains the aborted run's per-file errors, and src/worker.ts:326 (failJob) then addserror_count = error_count + 1.Impact: Under a SQLite error on the abort path, the persisted checkpoint and
error_countcan disagree byrunErrorCount, so a resumed run reports more job errors than the media actually skipped. Media indexing is unaffected.Suggested fix: Apply the cursor and
error_countrollback in one retried step (e.g. a single transaction that writes both, or persist the pending rollback in the checkpoint and complete it on resume) so the two are consistent after a failed retry.The new safeFile catch whitelist and the 413/fs-code skip classification are not exercised by the new test suite (tests/vectorize-error-tolerance.test.mjs:471; high confidence)
The test at tests/vectorize-error-tolerance.test.mjs:471-478 turns
2.jpginto a directory; src/dedup.tssafeFileresolves the path,lstatsucceeds andfile.isFile()returns false, so it returns null and the newcatchblock at src/jobs.ts:927-933 is never entered (safeFile also converts ENOENT to null, so only EACCES can propagate through it). A grep for the 128 MiB limit across tests/ matches only tests/encoder-contract.test.mjs:28-29, which asserts the client-sideembedImagethrow and never runs vectorizeHandler, so theerror.status === 413arm (src/jobs.ts:945) and the fs-code arm (src/jobs.ts:946) ofisFileErrorhave no coverage.Impact: The two branches actually added by this release (fs-error tolerance around safeFile, and 413/fs codes counted as per-file skips) are only covered indirectly, so a regression in either would not be caught by the suite the trace cites as acceptance evidence.
Suggested fix: Add cases that force a real EACCES from safeFile (unreadable parent directory), that remove a file between safeFile and readFile (ENOENT from stat/readFile in embedImage), and that drive an oversized (>128 MiB) media row through vectorizeHandler so it is recorded as a skip rather than failing the job.
Tests and validation
Questions
runErrorCountand then src/worker.ts:326 (failJob) addserror_count = error_count + 1; is the resulting net (previous - runErrorCount + 1) the intended reported count for a resumed run?Review limitations
Diff coverage
CHANGELOG.md: reviewed — included in a context-limited batchREQUIREMENTS-TRACE.md: reviewed — included in a context-limited batchVERSION: reviewed — included in a context-limited batchpackage.json: reviewed — included in a context-limited batchscripts/encoder-server.py: reviewed — included in a context-limited batchsrc/jobs.ts: reviewed — included in a context-limited batchsrc/vector.ts: reviewed — included in a context-limited batchtests/test_encoder_server.py: reviewed — included in a context-limited batchtests/vectorize-error-tolerance.test.mjs: reviewed — included in a context-limited batchReview metadata