Skip to content

test(integration): survive intermittent SQL Server 2025 startup crashes - #796

Merged
samtrion merged 4 commits into
mainfrom
fix/integration-container-exit
Sep 26, 2026
Merged

samtrion merged 4 commits into
mainfrom
fix/integration-container-exit

Conversation

@samtrion

@samtrion samtrion commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On main, the integration tests failed with ContainerNotRunningException: Container <id> exited with code 1. The container is the SQL Server fixture, and SQL Server crashed while starting up. This is an intermittent upstream bug, and changing the image did not remove it. The fixture now replaces a container that crashes during startup, with at most 3 attempts. Every retry is reported. The PR also moves the image off a stale preview tag and fixes an unrelated flaky RabbitMQ test.

Root cause

  • Run 36242350353 (main, 1160c28): 125 failed tests, all from SqlServerContainerFixture.InitializeAsync on net10.0. All 250 exited with code 1 lines name the same container id; net8.0 and net9.0 passed.
  • Crash signature. Testcontainers already includes the container's stdout and stderr in the exception:
    This program has encountered a fatal error and cannot continue running
             Reason: 0x00000002
        Stack Trace: ... sqlpal.dll ... lsasrv.dll ... lsass.exe ...
       Distribution: Ubuntu 24.04.3 LTS
         Last errno: 11 (Resource temporarily unavailable)
    
    This is failure signature B in microsoft/mssql-docker#974. SQL Server 2025 crashes intermittently at startup, and more often when several containers start at once. Our run starts one SQL Server container per target framework (net8/9/10) at the same moment, so it hits the concurrent case.
  • The ubuntu-22.04 base does not avoid it. The first commit of this PR moved to 2025-CU9-ubuntu-22.04, based on the issue's "0 crashes in ~250 starts" on 22.04. The issue itself says that only bounds the rate and does not make it zero. After the rebase, run 36255943687 crashed the same way on the new image: 133 SQL Server failures on net10.0, one container, Ubuntu 22.04.5 LTS, Reason: 0x00000002, sqlpal and lsasrv in the stack. The 22.04 claim from the first version of this PR was wrong.
  • Frequency. In the 80 CI runs I scanned before this PR (49 failed), the crash appears once. So it is rare per run, but when it hits, it takes out every SQL Server test for that TFM.
  • Stale image. The fixture had used 2025-RTM-ubuntu-24.04-preview since chore(docker): update mcr.microsoft.com/mssql/server docker tag to v2025 #534. No GA tag has the -preview suffix, so loose versioning never proposed a cumulative update.

Decision: stay on SQL Server 2025 and retry

Changes

  • SqlServerContainerFixture
    • Uses mcr.microsoft.com/mssql/server:2025-CU9-ubuntu-22.04: same engine major, current CU, and the lower-rate base.
    • On ContainerNotRunningException during StartAsync, it disposes the container and builds a fresh one, up to 3 attempts. A crash on the final attempt still fails the tests with the full container output.
    • Each retry is logged to stderr with the crash output. On GitHub Actions it is also written to the job summary as a warning, because dotnet test does not print output from passing runs.
  • renovate.json: regex versioning for mcr.microsoft.com/mssql/server (YYYY-CU<n>[-GDR<n>]-ubuntu-<ver>). It stays on the same Ubuntu base and never matches preview, RC or CTP tags. The file is byte-identical to the template after chore(renovate): track SQL Server CU/GDR tags on a fixed Ubuntu base template-dotnet#371, so the next template sync changes nothing.
  • RabbitMqMessageTransportIntegrationTests: the test exchange is now declared with autoDelete: false.
    • TUnit creates a new test class instance per test, so each test opens its own connection and exclusive queue.
    • When the previous test's connection closed, its queue binding was removed and the broker deleted the auto-delete exchange asynchronously.
    • Sometimes that happened after the next test's no-op ExchangeDeclare, and the following QueueBind failed with 404 NOT_FOUND - no exchange 'pulse.integration.test'.
    • Seen in run 36229149003 (PR chore(deps): update dependency microsoft.aspnetcore.signalr.client to v10.0.12 #776) and in run 36247301567 on this PR.

Test evidence

  • dotnet build Pulse.slnx -c Release: 0 warnings, 0 errors, including the CSharpier.MSBuild check.
  • CI on the final commit: results are added below once the Run Tests job has run 3 times.

@samtrion
samtrion requested a review from a team as a code owner September 26, 2026 14:05
@samtrion
samtrion requested a review from Hnogared September 26, 2026 14:05
@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.77%. Comparing base (7e0ac93) to head (b9456a2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #796      +/-   ##
==========================================
+ Coverage   95.70%   95.77%   +0.07%     
==========================================
  Files         270      270              
  Lines       10466    10466              
  Branches      953      953              
==========================================
+ Hits        10016    10024       +8     
+ Misses        243      235       -8     
  Partials      207      207              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The fixture used the stale 2025-RTM-ubuntu-24.04-preview image. SQL Server 2025 images on the ubuntu-24.04 base crash intermittently during startup with a sqlpal/LSASS fatal error (Reason 0x00000002, errno 11), more often when several containers start at once (microsoft/mssql-docker#974). Integration tests start one container per target framework concurrently, so a single crash failed every SQL Server test of that TFM. Switch to 2025-CU9-ubuntu-22.04, which is not affected.
Loose docker versioning could not move the 2025-RTM-ubuntu-24.04-preview tag to any GA cumulative update. Use regex versioning for mcr.microsoft.com/mssql/server so CU and GDR releases are proposed on the same Ubuntu base while preview, RC and CTP tags are ignored.
TUnit creates a new test class instance per test, so each test opens its own connection and exclusive queue. The exchange was declared auto-delete; closing the previous test's connection removed its queue binding and the broker deleted the exchange asynchronously, sometimes after the next test's idempotent ExchangeDeclare, so its QueueBind failed with 404 NOT_FOUND. Declare the exchange without auto-delete; it lives only as long as the per-session container.
@samtrion
samtrion force-pushed the fix/integration-container-exit branch from 5b145db to b113f21 Compare September 26, 2026 16:34
@samtrion samtrion changed the title test(integration): run SQL Server 2025 CU9 on the ubuntu-22.04 base test(integration): survive intermittent SQL Server 2025 startup crashes Sep 26, 2026
… startup

The ubuntu-22.04 base did not avoid the intermittent SQL Server 2025 startup crash (sqlpal/LSASS fatal error, Reason 0x00000002). Run 36255943687 hit it again on 2025-CU9-ubuntu-22.04 and failed all 133 SQL Server tests on net10.0.

When a container exits before it is ready, dispose it and start a fresh one, up to 3 attempts. Each retry is written to stderr and, on GitHub Actions, to the job summary so the crash rate stays visible. A crash on the last attempt still fails the tests with the container output.

Refs: microsoft/mssql-docker#974
@samtrion
samtrion force-pushed the fix/integration-container-exit branch from 1734927 to b9456a2 Compare September 26, 2026 17:19
@samtrion
samtrion merged commit 236a95e into main Sep 26, 2026
24 checks passed
@samtrion
samtrion deleted the fix/integration-container-exit branch September 26, 2026 19:18
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