Repository navigation
The temp-spill family of a PostgreSQL analysis pass: spilled bytes per second of observed time from the reset-aware pg_database_stats difference, work_mem graded only on that evidence and lifted to the incident line only when the spill fires, the offending statements in the drill-down; the same read emits PG_TPS with a half-window trend and the counter-derived PG_DEADLOCK_RATE on the alert band's measured tiers (#3542 lane 6) - #3681
Merged
Merged
Conversation
…r second of observed time from the reset-aware pg_database_stats difference, work_mem graded only on that evidence and lifted to the incident line only when the spill fires, the offending statements in the drill-down, and the one pg_database_stats read now also emits PG_TPS with a half-window trend and the counter-derived PG_DEADLOCK_RATE on the alert band's measured tiers (#3542 lane 6)
This was referenced Sep 19, 2026
erikdarlingdata
added a commit
that referenced
this pull request
Sep 19, 2026
… PRs across the #3653, #3542 and #3691 waves, #3704, #3710, #3712 and #3735, spliced once (#3751) Sixty-five PRs merged to dev since #3672 (the first splice) across two seats - the coordinator's #3653 brains-review residue lanes and the wave-2 worker's #3542 / #3691 PostgreSQL-target engine lanes - and by rule none touched this file; each returned its entry to a buffer. This is the one splice. Text-only; one file; nothing outside ## [Unreleased] and the definition block moves. [Unreleased] gains a ### Changed between ### Added and ### Fixed (Keep-a-Changelog order) for the nine entries whose subject is a designed behaviour that now behaves differently - routing (#3712 confidence chooses the channel), gating (#3692 tempdb persistence, #3734 blocking/LRQ gates, #3724 peak-and-mean), the wire shape (#3719 one error envelope), the review guard's drift arm (#3673), lineage metadata (#3723) and two grading changes (#3693, #3747). Twenty-two new capabilities append to ### Added (the sixteen PostgreSQL-target fact families and rungs, CONFIG_CHANGED, the recurrence label, the V134/V135 columns, the review traps file, the measurement census); thirty-two defects append to ### Fixed. Order within each section is ascending PR number, as #3672 did. Every entry is one line and verbatim from its buffer (trailing whitespace only). Four PR pairs fold into one entry as the buffers wrote them (#3738+#3746, #3683+#3686, #3681+#3685, #3726+#3729); #3695 carries three entries. #3673 has no issue and cites none, like the file's ninety-six other ref-less entries. Five definitions added ([#3691], [#3704], [#3710], [#3712], [#3735]) at the end of the [Unreleased] run, which stays one ascending run (3517..3735). No archive touched; the split was not run. tools/changelog/changelog_archive.py verify: all PASS (1,483 bold entries, floor 1,329; 1,363 distinct refs resolve; 1,372 definitions; CRLF throughout; 409,263 bytes under the ceiling). Client-hygiene grep over the file: zero hits.
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.
What does this PR do?
Lane 6 of #3542 (v1 step 6, design §3.9) — PARTIAL, do not close. A PostgreSQL operator now learns, from one
analyze_servercall, that sorts and hashes are spilling to temp files, how fast, in which database, against whatwork_mem, and which statements are doing it — andwork_memadvice appears only when that evidence exists.The family, and where each number comes from
PG_TEMP_SPILL(pg_temp) — spilled bytes per second of OBSERVED time (context.ObservedDurationMs, never the nominal window), frompg_database_stats.temp_bytes/temp_filesdifferenced perdatabase_nameseries with the reset-aware shape taken verbatim fromDarlingPgDatabaseReader.PgDatabaseSql—ROW_NUMBER() OVER series > 1 AND stats_reset IS DISTINCT FROM LAG(stats_reset),GREATEST(raw, 0)— so apg_stat_reset()mid-window is clamped AND reported (stats_reset_count,counter_rewind_countride the fact). That comment records the NULL→timestamp first-reset trap; this is the fifth site of the shape and re-derives nothing. The fact names the database that spilled the most with its share, and carrieswork_mem_bytes/max_connectionsread off the config facts emitted a moment earlier so the advice can do arithmetic with the host's numbers.CONFIG_PG_WORK_MEM— evidence-gated (D5), made structural. It is not inConfigAdvisoryRoots(verified; plumbing left it out). Its base is 0 unless the Database read stampedtemp_spill_bytes_per_seconto it at or above the spill floor, and then it isConfigAdvisoryBase(0.4), lifted to exactly the 0.5 incident line by the spill co-fire (KnobCoFireBoost, 0.4 × 1.25 — the shapeshared_buffersandmax_wal_sizetake). No spill fact → 0. Spill below the floor → 0. The VALUE is never graded: there is no rightwork_memwithout the workload.PG_TPS(pg_database) — context, base 0:xact_commit + xact_rollbackper observed second, rollback share stamped, and per the coordinator's additiontps_trend(second-half rate minus first-half rate, each over its own observed time apportioned by the intervals that fell in it; stamped only when both halves were observed) plustps_first_half/tps_second_half, for lane 3's parked offered-vs-delivered co-fire.PG_DEADLOCK_RATE(pg_database) — the COUNTER's deadlocks per observed hour, never apg_deadlocksrow count (the rate SQL is pinnedDoesNotContain("pg_deadlocks")). The exemplar count from the log capture is a separate read behind its own degrade and rides asexemplar_countbesidecounter_count, so the advice can say "the engine counted 99; 3 were captured from the log" and why the two differ (design §6 C). 25/hr grades Critical.PG_HIT_RATIOis declared and deliberately NOT emitted — the hit ratio is an arm of lane 2'sPG_BUFFER_CACHE_PRESSURE; a second fact over the same counters would double-count (D2). The Database.cs doc says so.Lineage of every bar (#3538 A5/A7)
TempSpillConcerningBytesPerSec= 1 MiB/s,TempSpillCriticalBytesPerSec= 10 MiB/s — unmeasured, chosen, not measured; calibrate against the per-servertemp_bytes/s distribution overpg_database_statsbefore the next release; the fact carriesthreshold_lineage = 0. Below the floor the fact is 0, not the formula's fraction, so a trickle never arms the knob. The baseline-relative z the design names is lane 9's; this is the v1 spot fact and says so.DeadlockWarnPerHour= 5,DeadlockCriticalPerHour= 20 — measured:ServerHealthThresholds.DeadlockWarnPerHourDefault/DeadlockCriticalPerHourDefault(A single resolved deadlock bands a server Critical: DeadlockSeverity is count > 0 with no magnitude tier, so Critical stops discriminating on any OLTP fleet #3368, 14 days × 43 servers, 14,448 server-hours), the same tiers the fleet card already bands a PostgreSQL server'sFleetPgDeadlockSqldifference on. Repeated by value becausePerformanceMonitor.Analysisreferences nothing (thePostgresOutagePredictorThresholdsargument);PgTargetTempTestspins the pairs equal, theFactScorerTestsidiom.WorkMemBootValMb= 4 — engine-defined (the compiledboot_val), used only for "the shipped default" in prose.TempCauseBoost0.3,KnobCoFireBoostby reference) — unmeasured, marked.Why the spill is also amplified by the knob having co-fired
Found by executing the pins: a spill exactly at the floor is 0.5 and the co-fired knob is exactly 0.5; the inference engine orders entry points by severity and breaks ties by emission order, and the config family is emitted first — so the knob rooted, consumed itself, and the spill rooted a second card. With the knob co-fire boosting the spill (≥ 0.65 whenever the knob fired) the spill always leads, the walk is
PG_TEMP_SPILL → CONFIG_PG_WORK_MEM, and the knob is the leaf D5 says it is. A temp-writingPG_BAD_ACTOR_*of the window is the second corroboration.The one edit outside this lane's declared partials, and why
PgTargetScorer.Config.csgains onecase PgTargetFactKeys.ConfigWorkMem: return ScoreConfigWorkMem(fact);arm (body inPgTargetScorer.Temp.cs) and its doc sentence updated. It is required, not convenient:FactScorer.ScoreAllnever amplifies a base of 0, andCONFIG_PG_WORK_MEM's source ispg_config, so its base can only come fromScoreConfigFact— lane 2's own doc comment there saidwork_memis "lane 6's arm … falls to the default 0 until that lane fills it". Lane 2 is merged, so there is no concurrent edit. Without it the exit criterion ("≥ 0.5 on co-fire") is unreachable.Drill-down and graph
PgTargetDrillDownCollector.Queries.cs— the/* filled by lane 6 */seam:pg_temp_spill_statements, the top five statements by differencedtemp_blks_writtenover the window (GREATEST(x − LAG(x), 0)over the full series identity, as the bad-actor detail does), withtemp_bytes_written(8 kB pages stated in bytes beside the spill fact'stemp_bytes),temp_blks_read, calls, time, per-call blocks, and the normalised text +hashtext. Runs whenever the spill is on the path, beside any bad-actor detail. Lane 7's "filled by lane 6" pin still holds.PgTargetRelationshipGraph.Query.cs— the edgePG_TEMP_SPILL → CONFIG_PG_WORK_MEM, predicate "the knob fired" (its verdict, never a size of its own). No edge intoPG_BAD_ACTOR_*: the exact-key problem lane 7 recorded is unsolved; the offenders reach the reader through the drill-down and the amplifier.What it does NOT do
No baseline-relative z on temp rate (lane 9). No
PG_HIT_RATIOfact (by design, above). No edge into a bad actor. No fact when the counters are flat — each fact is emitted only when its own counter moved, the convention every family on this read keeps, and load-bearing: the plumbing e2e pinsAssert.Single(facts)over a day of flat counters and lanes 2/4/7 pintotal_factsover the same series (verified locally: flat series → registry fact only). NoCREATE INDEX(D8).effective_cache_sizenever named.Which component(s) does this affect?
How was this tested?
New:
Darling/Darling.Tests/PgTargetTempTests.cs(compile-verified here; first executed in CI):threshold_lineage = 0stamped;work_mem0 un-stamped, 0 stamped below the floor, 0.4 at it, value not graded; deadlock 0 / 0.25 / 0.5 / 0.75 / 1.0 / 25 → 1.0, no lineage flag; TPS and hit ratio context; the deadlock pair equal toServerHealthThresholdsby value.FactScorer.ScoreAll:work_mem0 with no spill, 0 below the floor, exactly 0.5 on co-fire; the spill 0.5551 × 1.3 / × 1.6 with a temp-writing bad actor; the exact-at-floor tie resolves to ONE storyPG_TEMP_SPILL → CONFIG_PG_WORK_MEMthroughInferenceEngineon the PG graph.effective_cache_size.pg_deadlocksin the rate SQL, no block counters,$4midpoint halves, per-fact> 0gates, the D5 stamp, drill-down shape and cap.DARLING_TEST_PG-gated e2e: 4 h of climbing counters with a reset at T+2h (NULL → timestamp), a flat sibling database, 3 captured graphs, a config snapshot (work_memdefault,max_connections200), one spilling statement; asserts the clamp (239 × 120 MiB, not last-minus-first's 14,400 MiB;stats_reset_count1, rewind 1), 24.75/hr with 99 counted / 3 captured, the TPS halves (12,019/7,200 and 12,120/7,200), the story path, the drill-down offender777, the knob never rooting, the deadlock Critical card.Executed locally before CI: every scorer/advice/story value above through a net10.0 harness over the built assemblies (the tie above was found this way), and the whole collector + drill-down +
DarlingAnalysisService.AnalyzeAsyncagainst a throwawaytimescale/timescaledb:2.28.1-pg18with the exact planted series — outputs match the pins to the digit. Local replay of the lineage regex, the A7 ms check, the collector FROM/JOIN census and the dialect pins over the new consts: clean.Builds (zero new warnings):
PerformanceMonitor.Analysis,Darling/PerformanceMonitor.Darling.Analysis,Darling/Darling.Tests,Lite.Tests(one pre-existing xUnit2000 inLogTailOverlapThresholdPinTests.cs, untouched),deprecated/Dashboard.Tests— all with-p:EnableWindowsTargeting=truewhere windows-targeted.Checklist
dotnet build -c Debug)