Repository navigation
fix(content-store): a file deleted mid-listing no longer stalls orphan cleanup - #355
Conversation
Astra reviewReviewed StandardsNo merge-blocking method or YAGNI findings. The change handles the race at the existing per-entry SpecNo merge-blocking intent findings. The implementation matches the issue's requested smallest change: "Skip a now-missing object only when the per-entry stat returns ENOENT." Other stat errors are rethrown into the existing Verification: Summary: Standards 0 blockers, no worst issue; Spec 0 blockers, no worst issue. |
allisonmahmood
left a comment
There was a problem hiding this comment.
Reviewed against issue 337 on fix/335-portal-dotnet-description...476e751. One commit, three files. I re-ran the filesystem content-store tests: 6 passed, including the new case. On Node 24.20, after the first yielded name, deleting the others still leaves those names in the open directory stream, and stat returns ENOENT. I saw that for a 5-file directory and a 500-file directory.
Standards
The hunks match the Effect service conventions. Imports stay namespaces, the ContentStore interface stays inline, and the ENOENT skip stays inside the existing opendir walk. Other stat failures still reject into the existing StoreUnavailable cause. The new test runs on the real filesystem layer. No wire, CLI, migration, or glossary surface moved.
Findings: 0.
Spec
The diff does what issue 337 asked.
Skip a now-missing object only when the per-entry stat returns ENOENT. Preserve permission/I/O errors as failures and keep lazy iteration. Listing need not be snapshot-consistent; it should continue to unrelated objects that still exist.
walk still yields one object at a time. ENOENT skips that file. Any other stat error is rethrown, and Stream.fromAsyncIterable still maps it to StoreUnavailable. Azure list is unchanged. A real list failure still abandons the orphan pass:
Effect.catch((error) =>
Effect.logWarning("Orphan sweep could not list file objects.", error._tag).pipe(
Effect.andThen(
Effect.sync(() => {
result.failed += 1;
})
)
)
)A missing file never reaches that catch, so the pass continues to objects that are still there. DeletionSweep lists a patch's files and deletes each name it receives. Skipping a name that is already gone leaves it gone.
The new test taps a real list and deletes through the store after the first object. That is the walk race. The issue's sweep setup is what made the race visible. The failure itself is the stat.
Findings: 0.
Method
Catching ENOENT on the per-entry stat and continuing the generator is the right fix. for await suspends at yield, and Stream.tap runs before the next pull, so the later stat calls see the deleted files. A directory that disappears still fails at opendir. The issue only asked to skip a missing file at stat.
The predicate matches Node 24 fs.promises.stat: an Error whose code is "ENOENT". Elsewhere the repo casts to NodeJS.ErrnoException. Both accept this error. Effect.tryPromise inside the generator would need a runtime this file has already refused. Effect has no incremental directory iterator, which is why walk is an async generator.
YAGNI
The production change is the skip in walk and one sentence on list. There is no helper, retry, snapshot, or sweep edit. "An object deleted mid-listing may be skipped" is the weak guarantee callers have. Azure omits a blob that is gone before its page is read. The sentence does not claim Azure handles ENOENT.
The test is the dense part. survivorBeside exists so one sibling survives whatever name readdir returns first, and the assertion is derived from that. It is correct, and it is harder to read than the race. A local keep would read faster. I would leave the comment that says why a later stat sees ENOENT, and I would not add an EACCES case. The rethrow is the old path, and injecting it wants a seam this bug does not need.
Standards: 0 findings. Spec: 0 findings.
Reviewed by Grok 4.7 via Grok Build.
|
Both reviews are clean: Astra and grok each report 0 findings on Standards and Spec for Kept as is: grok's non-blocking note that Checks on |
…e filesystem listing The filesystem store's list stat'ed every enumerated file and turned an ENOENT into StoreUnavailable for the whole stream, so a concurrent delete made OrphanSweep skip unrelated reclaimable objects until a later pass. Skip an entry whose stat returns ENOENT; other stat errors still fail. Closes #337 Co-Authored-By: Claude Opus 5.5 <[email protected]>
476e751 to
db3cbc6
Compare
…refuses ordinary rows (#356) Stacked on #355 (branch fix/337-content-store-enoent). If the configured single-row limit was larger than both the batch limit and the Postgres limit, the runtime refused an ordinary `tables.insert` or `tables.update` with 413 before that row's own limit was checked. Default limits are unaffected. Closes #328. The HTTP reader caps each request body at `Runtime.maxCallBytes`, which was `max(batchBytes + callBytes, postgresBytes)`. That maximum now also includes `rowBytes + callBytes`. The per-operation and stored-row checks are unchanged. Test evidence: a new `Runtime.test.ts` case uses the ticket's settings (row 2048, batch 512, call 512, postgres 512). It sends an insert through the real runtime HTTP handler, which returned 413 before the fix and returns 200 after it. `pnpm typecheck` and `pnpm lint` pass. In `pnpm test`, 942 tests passed. Two integration Postgres tests timed out under machine load and pass when run alone. Implemented by Claude Opus 5.5 via Claude Code (foreman run orchestrated by Claude Fable 5.1).
On the filesystem store, if a file was deleted after the listing had enumerated it but before its stat, the whole listing failed with
StoreUnavailable. OrphanSweep then abandoned the pass, leaving unrelated reclaimable objects until a later sweep. Closes #337.walknow skips an entry whosestatreturnsENOENT. Other stat errors, such as permission or I/O failures, still fail the listing, and iteration stays lazy. Thelistdoc comment now says a listing is not a snapshot.Stacked on #353 (branch fix/335-portal-dotnet-description).
Test evidence
FilesystemContentStore.test.ts: five files in one directory, list lazily, delete three after the first entry is returned. It failed before the fix withENOENT: ... statwrapped asStoreUnavailable. It now returns the first entry and the remaining file.pnpm typecheckandpnpm lintpass.pnpm test: 941 passed, 2 timed out inpackages/integrationsPostgres tests under machine load. Both files pass when re-run alone (9/9).Implemented by Claude Opus 5.5 via Claude Code (foreman run orchestrated by Claude Fable 5.1).