Repository navigation
fix(deploy): write max_connections after the database and firewall - #272
Merged
Merged
Conversation
The deploy wrote the Postgres server's database, firewall rule and max_connections setting at once, and the server refuses a setting while another operation runs, so a deploy could fail with ServerIsBusy. The setting now depends on the database and firewall rule. The runbook says what a deploy that fails in Azure means.
The limit's timer needs a free thread-pool thread to fire during the parse, which the parallel tests could take, so the two tests that rely on it run in a NonParallel collection after the others.
CalvinAllen
force-pushed
the
fix/deploy/postgres-write-order
branch
from
November 13, 2026 17:07
b3c4631 to
0267abd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#271's deploy failed at
provision-postgreswithServerIsBusy, before the migrations or the web app, so the site kept running #269. The busy operation was the deploy's own.The generated Bicep writes three children of the Postgres server with nothing but
parent: postgres: thecsadventdatabase, theAllowAllAzureIpsfirewall rule, and themax_connectionssetting fromAppHost.cs. ARM writes them all at once, and a flexible server refuses to change a setting while another operation is running. The activity log shows the race on every recent deploy:max_connectionswriteThe live setting is already
429with nothing waiting on a restart. The write only failed because of when it happened.Changes
PostgresWrites.AfterTheOtherChildrenmakes a server setting depend on the server's databases and firewall rules.max_connectionsuses it, so the generated Bicep now has:A deploy waits for the firewall rule, about 50 seconds, before writing the setting.
PostgresWritesTestscompiles a server with a database, a firewall rule and a setting, and checks the setting'sdependsOn. LikeMigrateFirstTests, it needs no AppHost or Docker.The runbook has a new A Deploy That Failed in Azure section: what a failed
provision-…step means, and thatServerIsBusyis fixed by running the Deploy workflow again.Merging this deploys #271 too.
Also: #271's time-limit tests run on their own
APageThatTakesTooLongToReadIsLeftForAPersonfailed once in a full local run. It passed when run alone. The limit is aCancelAftertimer, and its callback needs a free thread-pool thread. A benchmark showed AngleSharp checks the token during the parse (a direct cancel at 50 ms was noticed at 105 ms), and that the 1 ms limit fired 20 times out of 20 with the pool idle. With the pool saturated it fired 0 times out of 10, and the parse ran to the end.ReadTimeLimitTests, in a newNonParallelcollection (DisableParallelization), which runs after the parallel tests.Testing
aspire do publish-azure-environmentin thePublishCheckenvironment, thenaz bicep buildonmain.bicep: it generates thedependsOnabove and compiles.dotnet build: 0 warnings, 0 errors.dotnet test(SDK 11.0.100, Docker): all 1,159 unit tests and 348 integration tests pass. The unit suite also passed three full runs in a row with the timing tests inNonParallel.