Skip to content

fix(content-store): a file deleted mid-listing no longer stalls orphan cleanup - #355

Merged
allisonmahmood merged 1 commit into
mainfrom
fix/337-content-store-enoent
Sep 24, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
fix/337-content-store-enoent

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

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.

walk now skips an entry whose stat returns ENOENT. Other stat errors, such as permission or I/O failures, still fail the listing, and iteration stays lazy. The list doc comment now says a listing is not a snapshot.

Stacked on #353 (branch fix/335-portal-dotnet-description).

Test evidence

  • New test in FilesystemContentStore.test.ts: five files in one directory, list lazily, delete three after the first entry is returned. It failed before the fix with ENOENT: ... stat wrapped as StoreUnavailable. It now returns the first entry and the remaining file.
  • pnpm typecheck and pnpm lint pass.
  • pnpm test: 941 passed, 2 timed out in packages/integrations Postgres 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).

@github-actions github-actions Bot added area:server Touches the server area size:s Under 100 changed lines labels Sep 23, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Astra review

Reviewed origin/fix/335-portal-dotnet-description...476e751b0ee360e7cf4d97dab3c1232953f29ba0 against #337, in one pass without subagents. Merge blockers only.

Standards

No merge-blocking method or YAGNI findings. The change handles the race at the existing per-entry stat, without adding abstractions, retries, or unrelated behavior. The regression test exercises real filesystem deletion through the content store.

Spec

No 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 StoreUnavailable mapping, and the iterator remains lazy. The contract comment documents that listing is not a snapshot.

Verification: pnpm exec vitest run packages/content-store/src/FilesystemContentStore.test.ts passed all 6 tests, including the new overlapping-deletion regression. No full-suite or end-to-end OrphanSweep run performed for this review.

Summary: Standards 0 blockers, no worst issue; Spec 0 blockers, no worst issue.

@allisonmahmood allisonmahmood left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Both reviews are clean: Astra and grok each report 0 findings on Standards and Spec for 476e751. No code changes.

Kept as is: grok's non-blocking note that survivorBeside in the new test is harder to read than the race and a local keep would read faster. The helper exists so a sibling survives whichever name readdir returns first. That keeps the test deterministic, and grok says it is correct. I also left out an EACCES case, as grok recommends. The rethrow is the existing path.

Checks on 476e751 all pass: lint, test (22), test (24), postgres-concurrency, cli-smoke, clerk-live, dependency-review, label. Merge state is CLEAN. It is stacked on #353, so it should land after that PR.

Base automatically changed from fix/335-portal-dotnet-description to main September 24, 2026 13:11
…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]>
@allisonmahmood
allisonmahmood force-pushed the fix/337-content-store-enoent branch from 476e751 to db3cbc6 Compare September 24, 2026 13:11
@allisonmahmood
allisonmahmood merged commit fa6df31 into main Sep 24, 2026
8 checks passed
@allisonmahmood
allisonmahmood deleted the fix/337-content-store-enoent branch September 24, 2026 13:19
allisonmahmood added a commit that referenced this pull request Sep 24, 2026
…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:server Touches the server area size:s Under 100 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

content store: overlapping deletion aborts filesystem listing and delays orphan cleanup

1 participant