Skip to content

fix(apphost): pin MongoDB to mongo:7 with mongo-data-v7 volume#346

Merged
mpaulosky merged 2 commits into
devfrom
squad/345-fix-apphost-mongodb-crash
May 17, 2026
Merged

fix(apphost): pin MongoDB to mongo:7 with mongo-data-v7 volume#346
mpaulosky merged 2 commits into
devfrom
squad/345-fix-apphost-mongodb-crash

Conversation

@mpaulosky

Copy link
Copy Markdown
Owner

Summary

Fixes two cascading AppHost/MongoDB container crashes introduced when Aspire.Hosting.MongoDB 13.3.3 defaulted to mongo:8.2.

Root causes

# Symptom Exit code Cause Fix
1 MongoDB container crashes ~30 s after start 139 (SIGSEGV) mongo:8.2 requires AVX CPU instructions; virtualized hosts that don't expose AVX segfault immediately Pin image to mongo:7 via .WithImageTag("7")
2 MongoDB 7 container refuses to start after image fix 62 mongo-data volume was initialised by mongo:8.2 (featureCompatibilityVersion 8.2); MongoDB 7 rejects data files from a newer major version Rename volume to mongo-data-v7

Changes

  • src/AppHost/AppHost.cs.WithImageTag("7") + .WithDataVolume("mongo-data-v7") on the AddMongoDB chain
  • src/AppHost/AppHost.csprojAspire.AppHost.Sdk bumped 13.3.213.3.3 to align with Directory.Packages.props
  • tests/AppHost.Tests/MongoDbContainerConfigurationTests.cs — new regression suite (4 tests) asserting image tag, volume name, and source-level guards

No application business logic was changed. No secrets or connection strings are included.

Testing

Suite Result
AppHost.Tests (full, no filter) ✅ 52 passed, 1 skipped (pre-existing Playwright flake), 0 failed
Architecture.Tests ✅ 16/16
Domain.Tests ✅ 67/67
Web.Tests ✅ 210/210
Web.Tests.Bunit ✅ 104/104
Pre-push gate (markdown lint, dotnet format, release build, unit + integration) ✅ All passed

Review gate

Aragorn: CONDITIONALLY APPROVED — no code changes required, gate clears on AppHost.Tests 0 failures. ✅ Condition satisfied.

Closes #345

- Add .WithImageTag("7") to prevent MongoDB 8.x AVX/SIGSEGV crash (exit 139)
- Rename volume to mongo-data-v7 to avoid featureCompatibilityVersion 8.2
  mismatch crash (exit 62) when reusing an 8.x-initialised volume
- Bump Aspire.AppHost.Sdk from 13.3.2 to 13.3.3 to align with Directory.Packages.props
- Add MongoDbContainerConfigurationTests regression suite (Gimli)
- Update squad history and decisions for boromir, gimli, sam

Closes #345

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 17, 2026 22:49
@github-actions github-actions Bot added the squad Squad triage inbox — Lead will assign to a member label May 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ PR Added to Squad Triage Queue

This PR has been labeled with squad and added to the triage queue.

Next steps:

  • The squad Lead will review and assign to an appropriate team member
  • A squad:member label will be added after triage

If you know which squad member should handle this, you can add the appropriate squad:member label yourself.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes local Aspire MongoDB startup failures by pinning the AppHost MongoDB container to MongoDB 7 and moving it to a version-suffixed data volume, with regression coverage and squad process notes.

Changes:

  • Pins AppHost MongoDB to mongo:7 and mongo-data-v7.
  • Aligns the AppHost SDK version with centralized Aspire package versions.
  • Adds AppHost regression tests and documents the operational decision/history.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/AppHost/AppHost.cs Applies the MongoDB image tag and data volume fix.
src/AppHost/AppHost.csproj Bumps the Aspire AppHost SDK to 13.3.3.
tests/AppHost.Tests/MongoDbContainerConfigurationTests.cs Adds regression coverage for the MongoDB image and volume configuration.
.squad/decisions.md Records the decision and validation for the MongoDB pin/volume rename.
.squad/agents/sam/history.md Adds investigation notes for the Web/MongoDB wiring diagnosis.
.squad/agents/gimli/history.md Adds test coverage work history for the AppHost MongoDB regression tests.
.squad/agents/boromir/history.md Adds infrastructure findings and validation history for the AppHost fix.

Comment on lines +40 to +45
Pin the MongoDB container image to a stable tag in AppHost.cs:

```csharp
var mongo = builder.AddMongoDB("mongodb")
.WithImageTag("8.0") // pin away from 8.2 which SIGSEGVs
.WithDataVolume("mongo-data")

### mongo:8.2 (Aspire.Hosting.MongoDB 13.3.3 default) causes exit 139 (SIGSEGV)

When diagnosing MongoDB container crashes under Aspire, check the image tag first. Exit code 139 is SIGSEGV — an image-level crash, not an application wiring defect. The fix is to pin the container image with `.WithImageTag("8.0")` in AppHost. Web timeout logs are downstream symptoms of the container crash and should not be mistaken for wiring bugs.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results Summary

479 tests   478 ✅  26s ⏱️
  6 suites    1 💤
  6 files      0 ❌

Results for commit 2c116de.

@codecov

codecov Bot commented May 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.14%. Comparing base (b3cb66a) to head (8b908f9).
⚠️ Report is 3 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #346   +/-   ##
=======================================
  Coverage   80.14%   80.14%           
=======================================
  Files          68       68           
  Lines        1682     1682           
  Branches      201      201           
=======================================
  Hits         1348     1348           
  Misses        244      244           
  Partials       90       90           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Append Scribe correction superseding the earlier mongo:8.0 guidance with the accepted mongo:7 plus mongo-data-v7 fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mpaulosky
mpaulosky enabled auto-merge (squash) May 17, 2026 23:01
@mpaulosky
mpaulosky merged commit c0a44c7 into dev May 17, 2026
16 checks passed
@mpaulosky
mpaulosky deleted the squad/345-fix-apphost-mongodb-crash branch May 17, 2026 23:05
mpaulosky added a commit that referenced this pull request May 18, 2026
## Summary

Closes #348

Working as Boromir (DevOps/Infra) + Sam (Backend) + Gimli (Tester).

## Root Cause

After PR #346 (mongo:7 + mongo-data-v7 fix) was merged, MongoDB
containers continued crashing in the running environment. Investigation
revealed the active Aspire AppHost was built from the **main repo's
stale local `dev` branch** — 2 commits behind `origin/dev`, still
launching `mongo:8.2` → exit 139 (SIGSEGV/AVX).

Identified via: `ps aux | grep AppHost.dll` — DLL path revealed the
wrong repo root.

## Changes

### Boromir (DevOps/Infra)
- Pulled and rebuilt main repo AppHost (`git pull origin dev` + `dotnet
build`) — **0 errors**, MongoDB now uses `mongo:7` + `mongo-data-v7`.
- Added rule 6 to `.squad/skills/mongodb-dba-patterns/SKILL.md`: sync
main repo before starting Aspire; use `ps aux | grep AppHost.dll` to
identify the active build.
- Added investigation findings to `boromir/history.md`.

### Sam (Backend)
- Full backend audit: `MongoDbBlogPostRepository`,
`MongoDbCategoryRepository`, `BlogDbContext`, `Program.cs` — all
correct. **No production code change required.**
- Added findings to `sam/history.md`.

### Gimli (Tester)
- Added `SeedMyBlogData_Makes_Seeded_Posts_Visible_On_The_Blog_Page`
integration test to `MongoSeedDataIntegrationTests` — asserts seeded
posts are visible via the real AppHost-wired Web/MongoDB path.
- Added findings to `gimli/history.md`.

## Validation

- `MongoDbContainerConfigurationTests` — 4/4 ✅
- `Web.Tests.Integration` (Testcontainers) — 29/29 ✅
- All pre-push gates passed (markdownlint, build, unit tests,
integration tests) ✅
- AppHost.Tests build: 0 errors, 0 warnings ✅

## Volume State

| Volume | Status |
|---|---|
| `mongo-data` | ⚠️ FCV-contaminated (mongo:8.2 data, UUID-format). Do
not use with mongo:7. |
| `mongo-data-v7` | ✅ Clean, numeric-ident format, lock file 0 bytes.
Safe for mongo:7. |

---------

Co-authored-by: Boromir <boromir@squad.dev>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

squad Squad triage inbox — Lead will assign to a member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Sprint 19] Fix AppHost MongoDB container crash under Aspire

2 participants