[SHOT-187] fix: Make database migration execution timeout configurable - #8143
[SHOT-187] fix: Make database migration execution timeout configurable#8143mimartin12 wants to merge 2 commits into
Conversation
Migrations that rebuild an index on a large Event table can exceed the hardcoded five minute DbUp timeout. The whole upgrade is wrapped in a single transaction, so one slow script rolls the upgrade back and recovery needs manual SQL run against the customer database. The timeout can now be set through globalSettings__sqlServer__migrationExecutionTimeoutSeconds or the MsSqlMigratorUtility timeout option. Leaving it unset keeps the existing five minute default, so upgrades behave exactly as before. Setting it to zero applies no limit, matching sqlcmd and SqlCommand semantics.
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed at The single 🎨 from the previous round — an unparseable timeout silently discarded on the Setup path — is addressed: Code Review DetailsNo findings at or above the reporting threshold. Verified, not flagged:
Dependency Changes
These are the three direct references of the new |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8143 +/- ##
=========================================
+ Coverage 0 67.46% +67.46%
=========================================
Files 0 2312 +2312
Lines 0 100301 +100301
Branches 0 9021 +9021
=========================================
+ Hits 0 67670 +67670
- Misses 0 30353 +30353
- Partials 0 2278 +2278 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🎟️ Tracking
SHOT-187 — follows PM-37891.
📔 Objective
DbMigratorhardcoded a 5 minute DbUp execution timeout. A migration that rebuilds an index on a largeEventtable can exceed it, and because the whole upgrade runs inside a single transaction, one slow script rolls the entire upgrade back. Recovery then requires running SQL by hand against the database.This makes that timeout configurable so operators can complete a long migration without manual DB surgery.
How to set it
globalSettings__sqlServer__migrationExecutionTimeoutSecondsbitwarden.sh/ Setupbwdata/env/global.override.envMsSqlMigratorUtility-t/--timeoutEnvironmentFileBuildernow seeds the key with an empty value so it ships discoverable and with the casing both readers agree on (Helpers.GetValueFromEnvFilematches case-sensitively; the app binds case-insensitively).Behaviour
0means no limit, matchingsqlcmd -t 0,SqlCommand.CommandTimeout, and EF Core.CommandTimeoutthrows on assignment.Verification
Runtime-verified against SQL Server 2022 using a probe migration containing
WAITFOR DELAY '00:05:30':-2— pins the 5 minute default--timeout 0--timeout 3vs a 10s script-2--timeout 60vs a 10s scriptNew
test/Migrator.Testproject coversResolveExecutionTimeout(5 cases).util/Migratorhad no test project before; this followstest/Setup.Test, reusing its exact package versions, so nothing is new to the dependency graph. Also registered the project inbitwarden-server.slnx— every other test project is there, and without it the new test file sits outside thedotnet formatCI gate.Reviewers: this spans three CODEOWNERS areas.
util/Migrator/**andutil/MsSqlMigratorUtility/**are@bitwarden/team-platform-dev,util/Setup/**is joint@bitwarden/dept-shot @bitwarden/team-platform-dev, andsrc/Core/Settings/GlobalSettings.cshas its own owners.