Stores that expose the managed PostgreSQL on the network finish the settings-file migration - #4464
Merged
Merged
Conversation
A store with a configured network endpoint always starts PostgreSQL with listen_addresses forced onto the pg_ctl command line, which outranks postgresql.conf/darling-managed.conf unconditionally. The settings-file migration's Step B compared the rendered file's listen_addresses line against pg_file_settings and read a real mismatch, because PostgreSQL reports that file row with an error once the running value differs from the file's -- confirmed against a live PostgreSQL 18 instance. Step B now skips both command-line-owned keys (port, listen_addresses) using the same list the host profile already defines, instead of comparing them against a file position they can never win.
erikdarlingdata
marked this pull request as ready for review
September 27, 2026 13:05
erikdarlingdata
deleted the
fix/managed-conf-verify-command-line-keys
branch
September 27, 2026 13:06
erikdarlingdata
added a commit
that referenced
this pull request
Sep 27, 2026
…that expose the managed PostgreSQL on the network (#4465) Stores that expose the managed PostgreSQL on the network re-verify a settings file left unstamped by a hand edit or an interrupted start, instead of reporting a failure on every start. This is the same cause as #4464, on the unstamped re-verification. An exposed store always starts PostgreSQL with port and listen_addresses on the pg_ctl command line, which outranks the file. So pg_file_settings reports darling-managed.conf's loopback-only listen_addresses row as an error on every start. - The re-verification's scan moves into ManagedConfMigrationRunner.FindUnstampedManagedFileErrors. It is the previous inline loop, plus a skip for DarlingStoreHostProfile.CommandLineOnlyKeys, the same list VerifyStepB uses. DarlingManagedPostgres calls it and builds the Failed outcome as before. Nothing changes the address or port the store listens on. - The other comparisons over pg_file_settings and pg_settings rows need no change: - Step A compares new error rows against the same server's earlier snapshot; - the verdicts already skip the command-line keys; - the startup heal and --check-settings do not read error rows; - VerifyStepB was fixed in #4464. - Tests: - FindUnstampedManagedFileErrors: listen_addresses and port overridden by the command line are not errors, and a real error on another key still is; - ManagedConfFileTests.RenderBody_ListenAddresses_IsAlwaysLoopbackOnly pins the rendered listen_addresses to 127.0.0.1.
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.
The managed-conf migration's second step (Step B) never finished on a store that exposes its managed PostgreSQL on the network. This change lets it finish.
Classification: P (real bug)
Confirmed against a live PostgreSQL 18 instance (a fresh container, no operator conf), not just from code reading:
-c listen_addresses=127.0.0.1,<private>on the command line and alisten_addresses = '127.0.0.1'line inpostgresql.conf, after a reload,pg_file_settingsreports that file rowapplied=false, error=setting could not be applied, andpg_settings.source = command line.-c listen_addresses=127.0.0.1on the command line (loopback only — no network endpoint configured) and the same file line, the file row reportsapplied=true, error=(none)— the values happen to agree, so it verifies clean.That matches what the installed stores showed: the store with no network endpoints (command line =
127.0.0.1, matching the file's rendered loopback value) verifies clean; the stores with a network endpoint (command line =127.0.0.1,<private>) get anerrorrow forlisten_addresses, whichManagedConfMigrationRunner.VerifyStepBwas counting as a mismatch.Where:
Darling/PerformanceMonitor.Darling.Service/ManagedConfMigrationRunner.cs,VerifyStepB(was comparing every keyParseConfText(renderedText)yields against apg_file_settings-attributed row with no error).portnever shows this symptom because darling.json's port and the rendered file's port line are normally the same value, so the file row still reportsapplied=truewith no error even though it's not the one actually in force — onlylisten_addressesdiverges in VALUE (the network IP) between what the file renders and what the command line carries.DarlingStoreHostProfile.CommandLineOnlyKeys(["port", "listen_addresses"]) already exists for exactly this pair, used by the separateComputeAndStoreManagedConfVerdictsAsyncdiagnostic path, butVerifyStepBnever consulted it.Effect on a real store: Step B restores the previous verified file every start it runs (the "restore" branch fires because
previousTextis passed) and reportsFailed. It repeats every start — nothing in the retry path changes the outcome, since the same command-line/file mismatch recurs identically each time. This blocks the settings-file migration from ever completing on a store with a network endpoint (the store itself keeps running fine on the previous file; no connectivity impact — the command line is in force everywhere, confirmed by the field read).Forward risk on a store that has only just done Step A (no
listen_addressesrow in its managed file yet): its next start runs Step B, which renderslisten_addresses = '127.0.0.1'again and hits the identical command-line mismatch — it would log the same failure at its next start once it also has a network endpoint. Fixed by the same change.Introduced by: the #4215/#4336 Step-B work (
ManagedConfMigrationRunner.VerifyStepB, part of the #4215 conf-migration series). Network endpoints were not exercised by Step B's original test suite — every existingVerifyStepB_*pin builds its rows and rendered text with values that already agree.The fix
VerifyStepBnow skipsDarlingStoreHostProfile.CommandLineOnlyKeysentirely — never looked up againstpg_file_settings, on either side of the comparison — reusing the product's existing list rather than adding a second one. This is the smaller, correct change: the alternative (not renderinglisten_addresses/portintodarling-managed.confat all) would touchManagedConfFile.RenderBody, which every other Step-B/Step-A pin and the initial-migrationComparepath also read from, for no gain — the file lines themselves are harmless; only comparing them against the command line was wrong. Network-exposure behavior (BuildServerRuntimeOptions,BuildListenAddresses) is untouched.Pins
VerifyStepB_ListenAddressesOverriddenByCommandLine_IsNotAMismatch_OtherKeyStillFails): apg_file_settings-shaped row forlisten_addresseswitherror = "setting could not be applied"is not a mismatch; a real mismatch on another key (work_mem) in the same batch still fails.listen_addresses(required) (VerifyStepB_OnlyListenAddressesOverriddenByCommandLine_Verifies): every OTHER rendered key matches and the only difference is the command-line-overriddenlisten_addressesrow →Status == Verified, the verified stamp is written (ManagedConfMigrationSteps.IsVerifiedtrue against the rendered text), and the managed file is NOT restored topreviousText. This is the pin that shows Step B now completes on a store with a network endpoint, instead of restoring the previous file on every start.port(VerifyStepB_OnlyPortOverriddenByCommandLine_Verifies): the same completion when the command-line-owned key that differs isportinstead.timescale/timescaledb:2.30.1-pg18container with-c listen_addresses=127.0.0.1,192.0.2.10(the RFC 5737 documentation address standing in for the container's own address — no real address recorded anywhere) and an included conf rendering the product's usuallisten_addresses = '127.0.0.1'line, then ran the product's ownManagedConfFileSettings.SnapshotSql(SELECT sourcefile, sourceline, name, setting, applied, error FROM pg_file_settings) against it after a reload. Captured row for the managed file:name=listen_addresses, setting=127.0.0.1, applied=false, error="setting could not be applied"; the same capture with aport = '5555'line added showedname=port, setting=5555, applied=false, error="setting could not be applied". Both new facts' rows use exactly this shape (and comment says so, without the address).VerifyStepB):Darling.Tests.ManagedConfMigrationRunnerTests→ Total: 21, Failed: 3 (the pre-existing mixed-case pin plus both new field-case pins). The required field-case pin's assertion:Assert.Equal() Failure: Values differ / Expected: Verified / Actual: Failed.CommandLineOnlyKeysskip inVerifyStepB(if (false && Array.IndexOf(...) >= 0)) → Total: 21, Failed: 3 (same three pins RED); restored the skip → Total: 21, Failed: 0.Build:
Darling.Tests.csproj0 errors / 0 warnings (-p:EnableWindowsTargeting=true).ManagedConfMigrationTests(43/43),ManagedConfFileTests(33/33) andDocCommentHygieneTests(77/77) also pass on the branch.Lite.Testsuntouched by this change.How to check it
After install, a store with a configured network endpoint logs "conf migration verified (step B)" on startup instead of "failed verification … listen_addresses".
pg_file_settings' file row forlisten_addresses(andport, where the command line pins a different value) may still showapplied=false, error="setting could not be applied"— that's expected: the command line is what's actually in force, and this check no longer treats that row as a mismatch.CHANGELOG entry
SECTION: Fixed
ENTRY:
listen_addressesoutranks the file, so the check no longer compares keys the command line owns.REF:
[Stores that expose the managed PostgreSQL on the network finish the settings-file migration #4464]: Stores that expose the managed PostgreSQL on the network finish the settings-file migration #4464
Refs
Closes #4215 field finding (a
.479report; see field notes for the affected stores' logs — no store or host names carried here).