A hand-edited or interrupted settings-file migration heals on stores that expose the managed PostgreSQL on the network - #4465
Merged
erikdarlingdata merged 2 commits intoSep 27, 2026
Conversation
…eys too pg_file_settings reports an error row for listen_addresses on an exposed store: the command line always outranks the rendered darling-managed.conf line (which stays loopback-only), so PostgreSQL reports that mismatch as an error, not merely applied=false. The MigratedUnstamped path (a hand edit of darling-managed.conf, or a crash inside Step B) treated ANY error row from that file as a failure, so an exposed store in that state reported Failed on every start and its stamp never healed. Extracts the scan into FindUnstampedManagedFileErrors and reuses DarlingStoreHostProfile.CommandLineOnlyKeys, the same skip ManagedConfMigrationRunner.VerifyStepB already applies for the sibling case.
…mped-command-line-keys # Conflicts: # Darling/Darling.Tests/ManagedConfMigrationRunnerTests.cs
erikdarlingdata
marked this pull request as ready for review
September 27, 2026 13:35
erikdarlingdata
deleted the
fix/managed-conf-unstamped-command-line-keys
branch
September 27, 2026 13:35
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.
Why
A store that exposes its managed PostgreSQL on the network always starts it with
listen_addressesandportforced onto thepg_ctl -ocommand line, which outranks the settings file unconditionally. The rendereddarling-managed.confline forlisten_addressesalways stays loopback-only, sopg_file_settingsreports that file row witherror = "setting could not be applied"— not merelyapplied = false— because its value differs from what's actually in force.A prior fix taught
ManagedConfMigrationRunner.VerifyStepBto skip these command-line-owned keys. The same trap existed in theMigratedUnstampedre-verification path: it treats ANY error row whose source file isdarling-managed.confas a failure, with no such skip. A store in that state (reached by a hand edit of the file, or a crash inside Step B) reported Failed on every start, and its verified stamp never healed, on any store with a configured network endpoint.The sweep
MigratedUnstampedre-verificationdarling-managed.conferror row with no key skip;listen_addresses's command-line-override error row always failed it on an exposed store.ResumePending/CompareAndFinish/ManagedConfFileSettings.CompareCompareonly flags a NEW error row relative to the BEFORE snapshot taken from the same live server; the command-line override is already in force both before and after Step A runs (it doesn't change across the migration), so the same error row appears on both sides and is never "new."VerifyStepBDarlingStoreHostProfile.CommandLineOnlyKeys.ComputeAndStoreManagedConfVerdictsAsync(verdicts)CommandLineOnlyKeysa fixedHostSettingVerdict.CommandLinerow before any classification runs, and only scanspg_file_settingserrors for the eight sizing keys —listen_addresses/portare never in that error scan at all.HealLegacyMaintenanceWorkMem,MigrateManagedConfAsync's other branches)maintenance_work_mem/legacy conf structure; never reads apg_file_settingserror row forlisten_addressesorport.--check-settings(GatherSettingProfilesAsync)AttributeManagedSetting/ClassifyVerdict; never queriespg_file_settingserror rows, and never touchesCommandLineOnlyKeysat all.ManagedConfFile.RenderBodyWhat changes
ManagedConfMigrationRunner.FindUnstampedManagedFileErrors: extracts theMigratedUnstampedscan into a small, unit-testable static helper, reusingDarlingStoreHostProfile.CommandLineOnlyKeys(never copying the list) to skipport/listen_addresseserror rows, exactly asVerifyStepBalready does.DarlingManagedPostgres.cs'sMigratedUnstampedcase now calls that helper instead of inlining the scan.Pins
All in
Darling.Tests(unit, no live database):FindUnstampedManagedFileErrors_ListenAddressesOverriddenByCommandLine_IsNotAnError— the command-linelisten_addresseserror row alone reportsHasError = false.FindUnstampedManagedFileErrors_PortOverriddenByCommandLine_IsNotAnError— same forport.FindUnstampedManagedFileErrors_RealErrorOnOtherKey_StillReportsError— a real error row on another key (e.g.work_mem) still reportsHasError = truewith that key named, alongside a skippedlisten_addressesrow that does not appear in the mismatched keys.RenderBody_ListenAddresses_IsAlwaysLoopbackOnly— a fast pin thatManagedConfFile.RenderBodyalways renderslisten_addresses = '127.0.0.1', the fact every path above depends on.Row shapes reuse the address
192.0.2.10(RFC 5737 documentation range) where an address stand-in is needed; no real IP appears.RED (runtime, on
origin/dev):ManagedConfMigrationRunner.FindUnstampedManagedFileErrorsdoes not exist ondev— a compile-only RED for the new pins (the method itself is the extraction).DarlingManagedPostgres.cs'sMigratedUnstampedcase is a private branch of a private async method (MigrateManagedConfAsync), reachable only fromEnsureRunningAsync's own switch on the migration state — there is no public seam that reaches it without a real Windows PostgreSQL start, and the extraction is behavior-preserving (the helper's loop is the exact inline loop that used to sit in that case, plus the skip), so no new runtime-reachable seam is introduced or needed. The mutations below prove the fix and the render assumption it depends on, at runtime, against the code as actually committed:Mutation A — the skip itself: deleted the
CommandLineOnlyKeysskip block fromFindUnstampedManagedFileErrors(all of it, not just thelisten_addressesbranch) and rebuilt. All threeFindUnstampedManagedFileErrors_*facts went RED, nothing else:(The third fact fails too: with the skip gone,
hasErrorstill comes outtruethere, butmismatchedKeysnow also carries thelisten_addressesrow the fact asserts is absent.) Reverted (git checkout --the one file);git diff --statempty; rebuilt clean.Mutation B — the render assumption every path above depends on: changed
DarlingManagedPostgres.BuildConfAppend's renderedlisten_addresses = '127.0.0.1'literal to'0.0.0.0'and rebuilt.RenderBody_ListenAddresses_IsAlwaysLoopbackOnlywent RED, nothing else:Reverted;
git diff --statempty; rebuilt clean. Both mutations went RED exactly as expected, so no test-only fix was needed.After both reverts and the merge with
dev's ownVerifyStepBcommand-line skip (landed separately ondevin the meantime, keeping both fixes and both test sets side by side), the green totals:ManagedConfMigrationRunnerTests24/24,ManagedConfFileTests34/34,ManagedConfMigrationTests43/43,DocCommentHygieneTests77/77.Build:
dotnet build Darling/Darling.Tests/Darling.Tests.csproj -c Release -p:EnableWindowsTargeting=true— 0 warnings, 0 errors.Gated tests
Not run here, because they need Windows and the PostgreSQL runtime packages. These are the tests the test-only run must show passing:
ManagedConfUpgradePathTests.*_GatedUpgradeInPlace_*RuntimeAdvance_*Postgres17Store_*CHANGELOG entry
SECTION: Fixed
ENTRY:
REF:
[A hand-edited or interrupted settings-file migration heals on stores that expose the managed PostgreSQL on the network #4465]: A hand-edited or interrupted settings-file migration heals on stores that expose the managed PostgreSQL on the network #4465