Skip to content

fix(host-service): classify any file its storage cannot map as environmental - #8842

Merged
superset-home merged 1 commit into
mainfrom
sentry/host-service-x-mmap-storage-unavailable
Oct 24, 2026
Merged

superset-home merged 1 commit into
mainfrom
sentry/host-service-x-mmap-storage-unavailable

Conversation

@superset-home

@superset-home superset-home commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

git.getStatus returns a 500 when git cannot mmap a file other than the index because the storage under it cannot deliver the file. Every status refresh on such a machine reports to Sentry.

Over the last 30 days, the message fatal: mmap failed: Operation canceled (or ... Operation timed out) appeared in about 250 git.getStatus events from about 30 machine/release pairs, on releases 1.29.0 through 1.38.0, all macOS. The events are spread across several stack-grouped issues (HOST-SERVICE-X, -7Q, -88, -70 and others), and those groups also collect unrelated git failures. So archiving a group would also mute real failures.

Root cause

#7636 classified this condition when git reads the index (unable to map index file: Operation timed out|canceled). It left the same errnos on other files as 500s. git maps other files through its xmmap() wrapper (wrapper.c): packfiles and pack indexes (packfile.c), and large worktree files when it hashes them for status. On failure that wrapper calls die_errno("mmap failed%s", mmap_os_err()). mmap_os_err() adds text only for ENOMEM, so the line ends in : <strerror(errno)>.

The cause of ETIMEDOUT/ECANCELED from mmap is the one #7636 describes. A cloud-synced folder evicts a file and leaves a dataless placeholder. The sync client then cannot fetch the file back in time, or it cancels the fetch. Or a network volume stops answering. Superset cannot make the file readable. It stays unreadable until the storage recovers or the repository moves off it.

Fix

This adds one pattern to the existing CWD_UNREADABLE / INDEX_STORAGE_UNAVAILABLE → PRECONDITION_FAILED / GIT_ENVIRONMENT branch. The pattern is anchored to git's whole fatal: mmap failed: line, and it accepts only the two storage errnos. The message is kept as-is. As with #7636, the client handles PRECONDITION_FAILED and INTERNAL_SERVER_ERROR the same way, so only reporting changes, not what the user sees.

Still a 500: mmap failed with any other errno, such as Cannot allocate memory.

Verification

Tests written first. Before the pattern change:

(fail) rethrowEnvironmentalGitError > object or worktree file its storage cannot deliver → PRECONDITION_FAILED / GIT_ENVIRONMENT [2.22ms]
 37 pass
 1 fail
Ran 38 tests across 1 file. [79.00ms]

After:

 38 pass
 0 fail
Ran 38 tests across 1 file. [77.00ms]

The negative test is load-bearing. With the pattern temporarily widened to /mmap failed/m, it fails:

(fail) rethrowEnvironmentalGitError > does not claim other index mapping failures or network timeouts [6.58ms]
 37 pass
 1 fail

bunx biome check on both files:

Checked 2 files in 20ms. No fixes applied.

cd packages/host-service && bun run typecheck: tsc --noEmit --emitDeclarationOnly false, exit 0.

bun test src/trpc/router/git (packages/host-service):

 249 pass
 0 fail
Ran 249 tests across 23 files. [55.73s]

Refs HOST-SERVICE-X

Summary by CodeRabbit

  • Bug Fixes
    • Git operations interrupted by canceled or timed-out file mapping are now reported as environment-related errors, making these failures more consistent with other Git environment issues.
    • Memory allocation failures remain classified separately.

…nmental

git's xmmap() reports 'mmap failed: <errno>' for packfiles, pack indexes
and worktree files it hashes. ETIMEDOUT/ECANCELED there come from the
storage layer (an evicted cloud-synced file or a stalled network volume),
the same condition already classified for the index.

Refs HOST-SERVICE-X
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ef79c2db-522a-4e33-be9d-807aa8ae68c5
Commits

Reviewing files that changed from the base of the PR and between 86a6414 and 4953711.

Files selected for processing: 2
  • packages/host-service/src/trpc/router/git/utils/classify-git-error.test.ts
  • packages/host-service/src/trpc/router/git/utils/classify-git-error.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The Git error classifier now maps canceled and timed-out mmap failures to PRECONDITION_FAILED with cause kind GIT_ENVIRONMENT. Tests verify these classifications and confirm that the Cannot allocate memory variant remains unclassified.

Changes: Git mmap error classification

Layer / File(s) Summary
Match and classify mmap failures
packages/host-service/src/trpc/router/git/utils/classify-git-error.ts, packages/host-service/src/trpc/router/git/utils/classify-git-error.test.ts
The classifier matches mmap failures caused by cancellation or timeout and uses the existing PRECONDITION_FAILED / GIT_ENVIRONMENT path. Tests cover both cases and verify that Cannot allocate memory remains unclassified.

Priority: Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: saddlepaddle

Merge Risk: Minimal · up to 49537

The narrow mmap classification is covered by positive and negative tests and is ready to merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title uses conventional commit format and clearly identifies the main change: classifying storage-related mmap failures as environmental errors.
Description check Passed The description is detailed and on-topic. It explains the problem, root cause, fix, scope, negative case, testing, and issue reference. It uses different headings from the template and omits the check…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and on-topic. It explains the problem, root cause, fix, scope, negative case, testing, and issue reference. It uses different headings from the template and omits the checklist, but the required technical information is substantially complete.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This PR appears safe to merge.

Summary

Classifies Git mapping failures caused by canceled or timed-out storage reads as PRECONDITION_FAILED with GIT_ENVIRONMENT.

  • Git storage timeouts and cancellations on mapped files count as environmental errors.

Reviews (1) · Last reviewed commit: "fix(host-service): classify any file its..." · Reviewed by Greptile

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@superset-home
superset-home merged commit 0fd3fda into main Oct 24, 2026
21 checks passed

This branch was previously deployed

1 inactive deployment
preview — 4953711d Deployed Oct 24, 2026 by superset-home via Deploy Docs #12684
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant