Anchor the cost read on the scan node, not on the first plan line (#753) - #822
Conversation
…ne (#753) Review nit from #820, and it is the same class of defect the suite exists to catch, so it should not have been in the suite. serial_cost read the cost with `grep -m1`, which returns whatever node comes first. The plan under test is a bare columnar scan today, so the first node IS the scan. The moment a node appears above it the helper reports that node's cost instead, silently and with a plausible value. Demonstrated on a plan with an aggregate above the scan: Aggregate (cost=66119.86..66119.87 ...) -> Custom Scan (PgColumnarScan) on c753 (cost=0.00..61101.78 ...) grep -m1 form 66119.87 <- the aggregate anchored form 61101.78 <- the scan The helper now selects the PgColumnarScan line first. Two premises assert the anchor found exactly one such node on each arm, so a plan that stops being a single columnar scan reds the premise instead of quietly costing something else. The suite is 9 of 9, up from 7, and the two new checks are premises rather than assertions about the product. Reported by OffgridwithJD in review of #820. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Y7gXubmW8DDDZPZNPXJHm
|
Reviewed and ran at 3cce6a8. 9 of 9 PASS on pg18a. The fix is right and the One correction to the framingThe defect was latent here, not live. I printed the raw plan for both arms on There is no node above the scan, so That does not weaken the case for fixing it, it is the case. Latent is exactly What makes this better than the nit I raisedI asked for the pipeline; you added a premise, which is the part I would not One leftover, not worth a round trip
Will approve when the suites jobs land. acting as: OffgridwithJD |
OffgridwithJD
left a comment
There was a problem hiding this comment.
Approving at 3cce6a8, the head I reviewed and ran — CI is now 12 of 12, and 9 of 9 locally on pg18a.
The scan_lines == 1 premise is the part that makes this worth having. I asked for a pipeline change; the premise covers a wider class than the one I named, including a node name matching inside another node's property line, and it runs before serial_cost is relied on.
My one note stands and is not a blocker: the defect was latent on this suite's query rather than live, since the plan is a bare PgColumnarScan with nothing above it and both forms return the same number today. That is the reason to fix it, not a reason not to — it passes until the plan gains a node and then reports a plausible wrong one. Worth saying which query the Aggregate plan in the description came from, so the body does not read as a correction of a wrong number that was being reported.
The trailing | head -1 in serial_cost is now provably unreachable as a truncation, given the premise. Drop it whenever you next touch the file.
Merging is yours.
acting as: OffgridwithJD
The review nit from #820, folded in as promised. Test only, no
src/change.The defect is LATENT, not live, and that is the case for fixing it
Correcting my own framing, after @OffgridwithJD printed the raw plan for both
arms. This suite is not misreporting anything today. Its query produces a
bare scan with no node above it:
So
grep -m1and the anchored form return the same number, and the suite stillreports
a 4212.00, sel 1404.00either way.That is the whole point.
serial_costread the cost withgrep -m1, whichreturns whatever node comes first. It is correct here by luck rather than by
construction: the first node happens to be the scan. It stays correct right up
until the plan gains a node above the scan, and then it reports a different
node's cost, silently and with a plausible value.
The mechanism, shown on a query that DOES have a node above the scan, which is
not this suite's query:
Latent is the state worth fixing. This suite exists because a published number
outlived the fixture it described, and a helper that reads a plausible number
from the wrong place is the same failure one level down.
The change
serial_costselects thePgColumnarScanline before extracting the cost. Twopremises assert the anchor found exactly one such node on each arm, ordered
before the check that relies on them.
9 of 9, up from 7. Both new checks are premises rather than new assertions about
the product, so this does not widen what the suite claims.
The
scan_lines == 1premise turned out to defend more than the nit asked for.It also catches a node name matching inside another node's property line, which
@OffgridwithJD reports having been bitten by twice in one day: "Aggregate" inside
Columnar Vectorized Aggregates, and "Sort" inside a Merge Append'sSort Key:.A bare
grep 'Aggregate'on a plan is not a node test.Reported by @OffgridwithJD in review of #820.