Skip to content

test: planner_choice_quality gains its pytest twin, and a plan that fails no longer reads as a fast one (#1341) - #1752

Merged
jdatcmd merged 6 commits into
mainfrom
test/1341-planner-choice-quality-twin
Oct 26, 2026
Merged

jdatcmd merged 6 commits into
mainfrom
test/1341-planner-choice-quality-twin

Conversation

@jdatcmd

@jdatcmd jdatcmd commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

@OffgridwithJD

This ports test/planner_choice_quality.sh to test/pytest/test_planner_choice_quality.py (#1341). The twin runs all 11 checks under the shell's names, one test per check, on a private database with serial planning, as the shell's cluster runs. Each arm runs its EXPLAIN, a warming run and the timed run in one session, so the plan it names is the plan it times.

What was fixed in the shell

1. A plan that fails was read as a fast plan. psql prints Time: after a statement that errors, not only after one that succeeds. run_plan looked only for a timeout, so a chosen plan that raised an error in 2 ms counted as a plan that answered in 2 ms. Main's shell passed every check under two mutations:

  • PgColumnarBeginCustomScan raises at execution: wide range ... chose Custom Scan (PgColumnarScan)=1.489ms ... (0.01x, bound 3x), PASSED.
  • PgColumnarBeginGroupAggScan raises at execution: range scan with aggregate: chose Custom Scan (PgColumnarScan)=1.911ms ... (0.01x, bound 3x), PASSED.

run_plan now reads psql's exit status under ON_ERROR_STOP. It tells the statement-timeout cancel apart by that cancel's own message. A new check, [$label] the chosen plan ran to completion, fails by name. A forced alternative that fails now fails the ratio check as "nothing to compare". Before, main read it as a fast alternative: "15.94x exceeds the 3x bound".

2. The ratio check's name changed with its result. The name carried the bound and the node that won the comparison. Green, it read ... alternative (Index Scan). Red, it read ... alternative (Custom Scan (PgColumnarScan)), a name that no green run had ever recorded. Now the names carry only the query's label. The bound and the winning node are in the display line.

forcing produced a different plan loses its premise: prefix (#1339). With pgcolumnar.enable_custom_scan ignored by the planner, it is the check that goes red.

Why CI's suites job skips it

ci.yml sets PGC_SKIP_TIMING=1, and run_all_versions.sh lists this suite in is_timing_suite. Under that flag the driver does not run the suite at all and records it as SKIPPED (66). If you run the shell directly under the flag, it builds 20,000 rows, runs the plan-shape checks, and records the two measured checks for each query as SKIP.

The twin reads the same flag, under the same condition. It builds the same 20,000-row fixture. It declares the same two checks for each query unrunnable (UNMET_PRECONDITION, under the shell's names), so the session ends INCOMPLETE (exit 67) and never green. Measured on PG17: shell 7 passed + 4 skipped, PASSED; twin 7 pass + 4 unrun, rc=67.

The pytest-cluster job does not set PGC_SKIP_TIMING, so in CI the twin measures. The headroom is wide: clean ratios were 0.02x to 0.05x against the 3x bound on every run. Whether the twin should run there is your call.

Shell and twin under each mutation (PG17)

change main's shell this shell twin
none 9/9 PASSED (PG17) 11/11 PASSED on each of PG15 to PG19 11 passed on each of PG15 to PG19
PGC_SKIP_TIMING=1 (driver skips it) 7 pass, 4 SKIP 7 pass, 4 UNRUN, rc 67
scan100x: pgcolumnar_refined_scan_cost x100, the planner picks the index scan 2 red, under names no green run has (... (Custom Scan (PgColumnarScan))) 2 red: [range ...], [wide ...] the chosen plan is within the bound of the best alternative same 2
scanerrors: PgColumnarBeginCustomScan raises at execution PASSED 2 red: [wide ...] the chosen plan ran to completion, [wide ...] ... within the bound ... same 2
groupaggerrors: PgColumnarBeginGroupAggScan raises at execution PASSED 2 red: [range ...] the chosen plan ran to completion, [range ...] ... within the bound ... same 2
fetcherrors: pgcolumnar_index_fetch_tuple raises (columnar_tableam.c) 2 red, as "15.94x exceeds the bound" 2 red, as "the forced alternative ... failed" same 2
gucignored: the planner ignores pgcolumnar.enable_custom_scan=off 2 red (premise: ...) 2 red: [range ...], [wide ...] forcing produced a different plan same 2

Two single causes of #434 do not change the plan on this fixture, so they are not ledger mutations: dropping the zone-map survival factor alone, or the index-fetch penalty alone, leaves the custom scan chosen (main: 0.03x to 0.08x).

Timing spread, three repeats on PG17 with other agents running on the machine:

  • Clean: shell 0.03x to 0.04x, twin 0.02x to 0.04x.
  • scan100x: shell 23.3x to 25.4x, twin 23.6x to 36.7x.

Gates

  • Ledger: 11 rows, 6 dated by the 5 mutations and 5 never (fixture rows and four premises). Census 4137 -> 4142 never, 2798 -> 2804 dated, 6946 rows. suites_not_covered 75 -> 74.
  • Ledger gate, on each of the five clean logs, against --registered from run_all_versions.sh --list-suites, --against parent: rc 0 on 15 to 19.
  • Orphan scan, on each clean log: orphans=0.
  • Guards: 804 passed (--pgc-expect-tests 804). test_harness_deps.py, test_capability_decline.py and the twin with --pg-config: 41 passed.
  • compare_to_bash.py: literal matches: 3 | template matches: 6 | missing: 0, every bash property is covered. The six label names are templates on both sides ([$label] and f"[{label}]"), as in hilbert_locality.
  • Capability-import scan: [].
  • harness_selftest.sh on PG17: 1248 passed.
  • shellcheck -S error: clean.
  • cluster_tests 3222 -> 3233, by collection. TESTS.md section 296.

Re-checked by me before pushing (PG17, main 4adb2e7): the custom scan refusing to execute: main's shell 9/9 (it read the failed plan as "chose Custom Scan=8.086ms"); this shell 9 + 2 failed, "[wide range, narrow projection] the chosen plan ran to completion: got [no (ERROR: … custom scan refuses to execute)]" and the ratio check as "not a measurement"; the twin 2 failed.

A choice for you, @OffgridwithJD, made provisionally: the CI suites job skips this suite's timing (PGC_SKIP_TIMING=1), but the cluster pytest job doesn't set that flag, so the twin MEASURES there (200,000 rows, the 3x bound). I've left it measuring. A clean run sits at 0.02x–0.04x, so the headroom against a false red is very large. Skipping the timing in that job instead would make the twin unrunnable (rc 67), which fails the job. Say if you'd rather the job set the flag and the twin's timing arms be declared on a nightly instead.

🤖 Generated with Claude Code

@OffgridwithJD OffgridwithJD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdatcmd Approved at a358eabb. Measured on PG17 against main's shell (origin/main tree) and this head, each tree building its own mutated source.

The two shell fixes are red-first

mutant main's shell this shell twin
none 9/9 11/11 11 passed
PgColumnarBeginCustomScan raises unless EXPLAIN-only 9/9 PASS 2 red: [wide range, narrow projection] the chosen plan ran to completion and ... within the bound of the best alternative the same 2
PgColumnarBeginGroupAggScan raises unless EXPLAIN-only 9/9 PASS 2 red, the [range scan with aggregate] pair the same 2
pgcolumnar_refined_scan_cost ×100 2 red, under names no green run has (... (Custom Scan (PgColumnarScan))) 2 red, stable names, 12–15x the same 2, 15–16x
enable_custom_scan ignored by the planner 2 red as premise: the 2 forcing produced a different plan checks the same 2

Error vs timeout

  • A mutant that raises 57014 with a different message ("canceling statement due to user request") reads as ERROR (...) in the shell and failed: ... in the twin, not as a timeout. Main's shell read it as the chosen plan finished within 20s: got [no], because it grepped for canceling.
  • A really slow plan (the scan sleeps 30 s, past the 20 s statement_timeout) reads as no (TIMEOUT) in both, with the ratio check reporting "not a measurement".

Timing in CI's cluster job

PGC_SKIP_TIMING is set only in the shell suites jobs (ci.yml :726, nightly.yml :212), so the twin measures in pytest-cluster. I ran it 5 times on PG17 with all 8 cores held busy by spinning loops: 11 passed each time, and the worst ratio was 0.14x against the 3x bound (the rest 0.03–0.08x). The headroom holds.

Under the flag locally, the twin gives 7 pass + 0 fail + 4 unrun, rc 67, with the 4 measured checks declined under the shell's names. No CI job sets the flag for pytest, so expected_unrunnable.txt needs no rows.

Ledger

The suite had no rows on main, so this seeds it rather than renaming. The 11 rows are the 11 names the head shell emits. The 6 dated rows cite the mutants above, all of which I reproduced except pgcolumnar_index_fetch_tuple raising. The tsv is sorted, and the census agrees with the paragraph: 6935 + 11 = 6946, never 4137 + 5 = 4142, dated 2798 + 6 = 2804.

Needs a restate

Against current main c7f0de45 (#1735 in), it conflicts in check_ledger_budget.txt, TESTS.md, expected_tests.txt and test_compare_to_bash.py. I'll re-approve a restate whose non-registry files are unchanged.

🤖 Generated with Claude Code

jdatcmd and others added 6 commits October 26, 2026 17:53
…ostgreSQL's casts (#1706)

Item 2 of #1706, decided there as option (a). The reader skipped the
TimestampType's isAdjustedToUTC flag and returned the raw microseconds for
either target type. In a New York session a naive (wall-time) column read
into timestamptz came back as 08:00-04 instead of 12:00-04, and an adjusted
column read into timestamp kept its UTC wall time instead of 08:00.

The reader now keeps the flag (the legacy TIMESTAMP_* converted types are
defined as adjusted) and, in those two mixed cases only, converts as
timestamp_timestamptz and timestamptz_timestamp do, in the session zone. It
is written from timestamp2tm, DetermineTimeZoneOffset and tm2timestamp, so it
is the same on every major: PG19 renamed the exported helper, and PG15-18
export none for timestamptz -> timestamp. Same-kind reads, and any read in a
UTC session, are unchanged.

A wall time is not monotonic in its instant across a spring-forward gap: in
New York on 2024-03-10, 02:00, 02:30 and 03:00 become 07:00Z, 07:30Z and
07:00Z. Converted row-group statistics need not bound the converted rows, so
the foreign table no longer skips row groups of a column read this way.
Measured: with skipping left on, `t > '07:15Z'` over such a group returned 0
rows instead of 1.

The Iceberg foreign table's year(), month(), day() and hour() pruning
compared a constant with partition cells the writer computed in the source
field's own kind, while the reader now converts a mixed-kind column's rows.
PgColumnarIcebergTemporalMap now leaves out a field whose Iceberg source type
is the other timestamp kind than its column, so nothing prunes on it.
Measured on PG17 before the guard, in New York: byhour declared timestamptz
with `ts >= '2021-03-01 06:00+00'` returned no rows where iceberg_scan
returned 2,3, and byhour_tz declared timestamp with
`tt <= '2021-02-28 20:00'` returned none where it returned 1,2.

#1707 (merged) is a prerequisite: with the reader honouring the flag and the
old exporter marking timestamp adjusted, a timestamp exported and re-imported
in a New York session came back 08:00 (measured). An arm pins that round trip.

New suite test/parquet_timestamp_zone.sh and its twin, 16 checks, including
the naive file read in a second zone (Tokyo), the repeated hour of the
2024-11-03 fall-back, and test/fixtures/parquet/legacy_timestamp_micros.parquet,
written by main's exporter before #1707 (0c5e924) with only the
TIMESTAMP_MICROS converted type. Two arms in test/iceberg_fdw.sh and its twin.
docs/user-guide.md states the rule; CHANGELOG under Changed.

Measured on PG17:
- Red, the head before the Iceberg guard: both new iceberg_fdw checks, in
  shell and twin ("got [] want [2,3]", "got [] want [1,2]").
- Mutants, the same names in shell and twin: the flag ignored (6), no
  instant-to-wall shift (2), skipping on converted stats (1), main's exporter
  before #1707 (the round trip, 1), the conversion pinned to New York (the
  Tokyo pair, 2), legacy converted types read as naive (the legacy pair, 2),
  the zone offset taken at the wall time read as UTC (the fall-back hour and
  the two gap checks, 3), no Iceberg kind guard (2).
- Green: parquet_timestamp_zone 16/16 and iceberg_fdw 76/76, shell; 16/16 and
  80/80, twin; on each of PG15 to PG19.
- Without pyarrow the twin declines by the shell's skip name.
- docs_style 53/53, harness_selftest 1248/1248, shellcheck clean.

Ledger: 6951 rows, 2811 dated by the mutations and 4140 never.
suites_not_covered 75 -> 75 (a new suite, registered and covered together;
iceberg_fdw is not yet seeded, so its two new checks add no rows),
cluster_tests 3222 -> 3240, TESTS.md section 296. The ledger gate, guards
(804 passed), name grading and the self-test pass over 9ab6a4c.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e operator family (#1712)

The foreign table's group-exclusion check refused any constant whose type
was not the column's. A bare integer literal is int4, so the most ordinary
filter on a bigint column, `WHERE id > 150000`, read every row group; only
`150000::int8` skipped. Answers were correct; reads were not saved.

The check now compares the statistics with the constant through the
operator family's comparison function for (column type, constant type), as
the native zone-map path already did (OffgridwithJD's measurement on
#1712). A family with no such function means no skip. Two details the old
code would have got wrong for a cross-type constant: the NaN check read the
constant as the column's float type (it now reads it by its own type), and
equality called the comparison with the constant first (the column's value
is now always the first argument).

New suite test/parquet_skip_cross_type.sh and its twin, 9 checks, over a
200,000-row file in 4 row groups: int4 constants on an int8 column (>, =,
and on the left), a negative float4 constant on a float8 column, the
answers against the same-type query, and a float4 NaN that must still find
the NaN row its group's statistics leave out.

parquet_export_stats measured the old refusal in six arms ("a cross-type
constant skips nothing", and five like it). Those assertions are now wrong
by design: each is renamed for what it asserts, the skip its same-type twin
gets, keeps its ledger row, and is re-dated by the pre-#1712 reader, which
fails exactly those six in both harnesses. Three soundness arms are added
for the changed predicates that had none ([i8 < 5::int], [i8 < 5],
[f4 < 0.4]); every oracle arm passes. docs/limitations.md states the new
rule.

Measured on PG17:
- Red: the pre-#1712 reader fails the four cross-type skip arms of the new
  suite, in shell and twin.
- Green: 9/9 shell and twin on each of PG15 to PG19; parquet_export_stats
  165/165 shell and twin on each of PG15 to PG19.
- Mutants, the same names in shell and twin: the comparison called with the
  constant first (4, the same-type control among them); the column type's
  own function used for a constant of another type (the negative float4
  arm); the NaN constant read as the column's type (the NaN arm).
- 47 parquet, iceberg and arrow suites on PG17: only parquet_export_stats's
  six refusal arms failed, before they were rewritten; 1044 checks.
- docs_style passes. Guards 476 passed. cluster_tests 2763 -> 2775
  (collected 2775). Ledger 6180 + 12 = 6192 rows, 3886 -> 3892 never,
  2294 -> 2300 dated; the gate passes, ceiling 102.
- Rebased onto #1736 at a93f14b, the registry re-derived there:
  cluster_tests 3240 -> 3252 (collected 3252). Ledger 6951 + 12 = 6963
  rows, 4140 -> 4146 never, 2811 -> 2817 dated. The gate is run on the
  commit after this one.

Stacked on #1736 (and #1707), which touch the same function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…amptz constant (#1712)

OffgridwithJD's review of #1737 measured a wrong answer. For a timestamp
column and a timestamptz constant, timestamp_cmp_timestamptz turns each
statistic, a wall time, into an instant in the session zone, and that is
not monotonic across a spring-forward gap. In New York a row group holding
2024-03-10 02:00, 02:30 and 03:00 has a converted max of 07:00Z but holds
02:30, which is 07:30Z. So `ts > '2024-03-10 07:15+00'::timestamptz`
skipped the group and returned no row; a heap copy returns row 1. The same
held for >= 07:15Z and = 07:30Z.

The group-exclusion check now refuses that pair before choosing the
comparison function. A timestamp constant on a timestamp column still
skips, and a timestamptz column with a timestamp constant is unchanged.
docs/limitations.md and the CHANGELOG entry say so.

parquet_skip_cross_type and its twin gain 7 checks over a naive timestamp
file in 2 row groups, every session in New York: the three predicates
against the heap copy, a same-type control that still skips 1 group, its
answer against the heap, and two premises.

Measured:
- Red: on the rebased head without the guard, PG17, the >, >= and = arms
  fail by the same names in shell (13 passed + 3 failed = 16) and twin
  (3 failed, 13 passed), each "got none want 1".
- Mutant: deleting the guard line reddens the same three names in both
  harnesses, which dates their ledger rows.
- Green: parquet_skip_cross_type 16/16 and parquet_export_stats 165/165,
  shell and twin, on each of PG15 to PG19. parquet_timestamp_zone 16/16
  shell and twin on PG17.
- Guards 804 passed. docs_style passes. cluster_tests 3252 -> 3259
  (collected 3259). Ledger 6963 + 7 = 6970 rows, 4146 -> 4150 never,
  2817 -> 2820 dated; the gate passes against origin/main, ceiling 75.
  compare_to_bash: every bash property is covered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er collide (#1742)

A twin that starts its own S3 or HTTP fixture server takes the port from
pick_port(slot) in a module fixture. Under -n, a module's tests are split across
workers, so every worker runs that fixture. The port depended on the slot only, so
two workers probed the same free port at the same moment and the second bind failed
with "Address already in use" (#1635, #1714, #1721). CI runs the cluster files
serially, so CI stayed green; the guard job and developers run -n.

pick_port now starts each worker in its own block of 64 ports (WORKER_STRIDE), with
the slot as an offset inside it. The worker comes from PYTEST_XDIST_WORKER, so no
fixture changes. Slot 0 is the worker's own cluster, which make_cluster now asks for
through the same function. A slot that does not fit in a block is refused. The walk
on a busy port, the AUX band and the ephemeral-floor contract are unchanged.

test_runshape.py gains test_two_workers_taking_a_fixture_port_do_not_collide: an
inner -n 2 run where each worker takes pick_port(27), waits until the other has a
port, then binds it. On main it is red: "the two workers were given two different
ports: got 1 want 2", and the inner bind fails with [Errno 98] Address already in
use. With the fix it is green.

Measured on PG17 (a copy of the prefix):
- test_iceberg_objstore.py under -n 2: main 3 of 3 red ("premise: sigv4 fixture
  server is up: got '0' want '1'"; "Connection refused"); fixed 16 passed 3 of 3,
  and 16 passed serially.
- test_objstore_listing.py from #1714 under -n 2: as is, 13 failed ("the private
  cluster did not start"); with this pgc_cluster.py, 15 passed 3 of 3 and serially.
- test_connection.py and test_hardening.py under -n 2: 20 passed.

guard_tests 476 -> 477, by collection over NO_CLUSTER; TESTS.md section 10 gains a
row. The guards (477), test_harness_deps.py and test_capability_decline.py with
--pg-config pass over 21182d0.

Review (OffgridwithJD): a 64-port block holds slots 0 to 31, and main's twins
already ask for 32 to 35 (the stack for up to 41), so slot 32 raised at fixture
time: test_iceberg_rest.py "14 errors", ValueError "slot 32 does not fit in a
worker's block of 64 ports". WORKER_STRIDE is now 96 (slots 0 to 47; the AUX band's
2000 ports still give 20 workers). Two guards keep the stride and the corpus from
drifting apart, red first on the 64 stride: every literal pick_port slot fits a
worker's block (it named the 32-35 files), and the corpus's highest slot (35) gets a
port in the band. Green: test_runshape.py 18 passed; the five twins that errored
pass serially (14, 11, 29, 10, 8); iceberg_rest + iceberg_objstore under -n 2, 30
passed; guards 807 passed on main 9ab6a4c (guard_tests 804 -> 807).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le, pinned reader, and a crash no longer passes as a refusal (#1341)

test/pytest/test_parquet_export.py ports all 14 checks of
test/parquet_export.sh by name. Five kinds of shell check could pass with
nothing measured, or vanish; all are fixed in both twins.

- "reject non-columnar table" and "reject unsupported type" passed on any
  error. With the columnar check removed, exporting a heap failed on
  "unsupported columnar format version" and passed; with the type
  refusal formatting the typmod, it failed on "cache lookup failed" and
  passed. Each refusal now needs its own message.
- "parquet values match heap oracle" and "extended values match heap
  oracle" agreed on two empty readings: with the generator's rows never
  inserted, both passed. They now need the generator's ids on both sides
  and the file's row count.
- "duckdb non-null count(b)" compared DuckDB's count with t_col, the
  table under test: with half of t_col deleted before the export, it
  passed. It is now held to the generator's 80002, by check_num.
- Without the duckdb CLI the shell left its four DuckDB checks out
  without a word (10 = 10). It now skips them by name (10 passed + 4
  skipped = 14). A skip, not check_unrunnable: the suites job installs no
  DuckDB CLI, and an INCOMPLETE suite fails its major there.

DuckDB in the twin, as decided on #1341 (option 1 with option 2's
mechanism): the duckdb Python package is pinned at 1.5.6 in
requirements-test.txt; duckdb joins pyarrow in DECLINABLE_CAPABILITIES,
held by four new tests in test_capability_decline.py, written red first;
and the cluster job sets PGC_REQUIRE=pyarrow,duckdb. The twin reaches
duckdb only through require_module, under the shell's check names.

Measured, PG17, shell and twin:
- duckdb absent: the four DuckDB tests decline by name and the run is
  green (10 pass + 4 declined); with PGC_REQUIRE=duckdb the same four fail.
- the columnar check removed, and the type refusal formatting the
  typmod: the refusal red in both; main's shell passed 14 of 14.
- the generator's rows never inserted: 8 red in both; main's shell 5.
- half of t_col deleted: 4 red in both; main's shell 3.
- the type check removed (the backend aborts): the refusal red in both,
  with the same 5 collateral reds in both.
- nine more mutations of src/columnar_parquet.c: each red set identical
  in both twins and in main's shell. DECIMAL written little-endian and a
  negative int4 written as null are red in both readers, pyarrow and
  DuckDB; row-group num_rows one high is red in DuckDB only.
- clean: 14 of 14 on PG15 to PG19 in both twins.

Ledger: 14 rows, 14 dated by the 11 mutations and 0 never.
suites_not_covered 75 -> 74, cluster_tests 3222 -> 3236, guard_tests 804 -> 808, TESTS.md
section 296. The ledger gate, guards (808), name grading and the self-test
pass over 4adb2e7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ails no longer reads as a fast one (#1341)

Ports test/planner_choice_quality.sh to test/pytest/test_planner_choice_quality.py,
all 11 checks by the shell's name, one test per check, on a private database with
serial planning as the shell's cluster runs. Each arm's EXPLAIN, warming run and timed
run share one session, so the plan named is the plan timed.

Two holes in the shell, each measured on PG17 against main and fixed in both twins:

- psql prints "Time:" after a statement that errored, and run_plan only looked for a
  timeout. So a chosen plan that raised an error was read as a fast plan. With
  PgColumnarBeginCustomScan raising at execution, or PgColumnarBeginGroupAggScan,
  main's shell PASSED every check (the grouped query "chose Custom Scan=1.911ms",
  0.01x). run_plan now reads psql's exit status under ON_ERROR_STOP, and tells the
  statement-timeout cancel apart by its own message. A new check, "[$label] the chosen
  plan ran to completion", fails by name; a forced alternative that fails fails the
  ratio check as "nothing to compare" instead of standing in as the fastest plan (main
  read it as 15.94x over the bound).
- The ratio check's name carried the bound and the node that won the comparison, so
  it was "... alternative (Index Scan)" when green and "... alternative (Custom Scan
  (PgColumnarScan))" when red: a red no green run had named. The names now carry only
  the query's label, and the values are in the display line.

"forcing produced a different plan" loses its premise prefix (#1339): with
pgcolumnar.enable_custom_scan ignored by the planner, it is the check that goes red.

PGC_SKIP_TIMING: CI's suites job sets it, and run_all_versions.sh does not run the
suite at all under it (is_timing_suite), which is why CI reports it skipped. Run
directly under the flag, the shell builds 20,000 rows, runs the plan-shape checks and
records the two measured checks per query as SKIP. The twin reads the same flag: it
builds the same fixture, and declares the same two checks per query unrunnable under
the shell's names, so the session ends INCOMPLETE (67), never green.

Five mutations on PG17, each reddening the same names in shell and twin:
scan100x (refined scan cost x100, the planner picks the index scan; 2 ratio checks,
23.3x-25.4x over three shell runs and 23.6x-36.7x over three twin runs), scanerrors 2,
fetcherrors 2, gucignored 2, groupaggerrors 2. Clean, the ratio is 0.02x-0.05x on
every run. 11/11 in shell and twin on each of 15-19.

Ledger: 11 rows, 6 dated by the 5 mutations and 5 never.
suites_not_covered 75 -> 74, cluster_tests 3222 -> 3233, TESTS.md
section 296. The ledger gate, guards (804), name grading and the self-test
pass over 4adb2e7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jdatcmd
jdatcmd force-pushed the test/1341-planner-choice-quality-twin branch from a358eab to bb1b864 Compare October 26, 2026 17:55
jdatcmd added a commit that referenced this pull request Oct 26, 2026
…s left open (#1743)

A worker of parallel_export_parquet learns its multipart upload id only
from the answer to CreateMultipartUpload (POST ?uploads), and the store
creates the upload when the request arrives. A worker that ended while it
waited for that answer left an upload open that nothing could abort.
#1727's exit callback (in this base) aborts an upload a terminated worker
holds the id of; it cannot help a worker that never got the id.

The dispatcher's cleanup now lists the uploads under the export's prefix
(ListMultipartUploads) and aborts each one whose key is exactly one of the
export's part names, part-0000.parquet to part-(nkeys-1).parquet. Any other
key under the prefix is left alone.

- On a cancel or other error the aborts run inside #1744's
  PgColumnarCleanupAndRethrow, in the cleanup callback after
  pexport_cleanup. The helper has copied the handled error out and emptied
  the stack, so a second cancel that lands in a part DELETE cuts short only
  that DELETE: the aborts still run and the first cancel is re-thrown. They
  also run after a worker failed (for example, the workers were terminated).
- Interrupts are held only around bounded waits: 5 s on a timed latch for
  the terminated workers to stop, then 10 s for the listing and aborts.
- New module entries list_uploads and abort_upload, which take a timeout
  that sets a deadline on the handle; ABI 5 -> 6.
- os_wait: this builds on #1727's WL_TIMEOUT (4dc63aa, in this base through
  #1744's stack, not on main). It keeps WL_TIMEOUT for every wait and cuts
  the slice to the time left when a handle has a deadline. The first
  version's comment "os_wait passes no WL_TIMEOUT" is gone; this hunk
  depends on #1727 landing.
- The fixture server already wrote __open_uploads__ (#1721) and had
  __delete_delay__ (#1744). One copy of each is kept; the __open_uploads__
  writer is the module function _write_open_uploads, which --seed-upload
  also uses.

Review of the first version (80ee33e): a second cancel during
pexport_remove_outputs' part DELETEs emptied the error stack (#1741), the
first version's outer PG_CATCH then raised "errstart was not called", and
the aborts never ran. That outer PG_TRY, its copy-flush-rethrow helper and
pexport_spawn_and_wait are removed.

Test: new suite objstore_export_open_uploads and its twin, 30 checks each,
identical names. The fixture server gains ListMultipartUploads, delay hooks
on POST ?uploads, part PUTs and the listing, and --seed-upload. Five arms:
cancel while parts are sent; cancel while every CreateMultipartUpload is
held; the workers terminated there; cancel there, then cancel again once
the first part DELETE has arrived (__delete_delay__ 3 s); and cancel there
while the listing is held. The double-cancel arm was red first on the
rebased first version, PG17, shell and twin alike: "XX000: errstart was not
called", one more errstart line in the server log, and 4 uploads left open.
With the rework: 30/30 on PG15-19, shell and twin.

Ledger: 30 rows, 12 dated by four mutations that redden the same names in
both twins on PG17 (no listing; every listed key aborted; the part match
off by one; the cleanup run with the handled error on the stack), 18 never.
"parts: no upload of this export is left open" is never: on this base
#1727 also closes it, so no single mutation reddens it. never 4488 -> 4506,
dated 3260 -> 3272, rows 7748 -> 7778; suites_not_covered stays 34;
cluster_tests 4027 -> 4057; TESTS.md section 338.

Restated onto main 4500efd, stacked on #1752. main's #1745 added a test
named test_double_cancel_reports_the_first_cancel to test_parallel_flush_optin.py,
so the corpus defined that name twice and two guards in
test_docs_cover_the_corpus.py failed. This twin's test is renamed
test_double_cancel_reports_the_exports_own_cancel, with its TESTS.md row; the
check name it records is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jdatcmd

jdatcmd commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

Restated onto main 4500efd as bb1b864, in one linear stack (this PR sits on #1750), so these eight merge without voiding each other. Every non-registry file carries the same change as before; the registries are re-derived on the new base, and each census agrees with a recount. Guards, the PR's own shell suites on PG16 and PG18, its twins on PG17, compare_to_bash and the ledger gate all pass at this head. Re-approval needed.

@OffgridwithJD OffgridwithJD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdatcmd Re-approved at bb1b864b, restated onto main 4500efdd in the linear stack. Outside the ledger, the budget, expected_tests and TESTS.md, the commit's diff matches the approved a358eabb. The tsv is sorted, and its census (8040/4553/3487 rows/never/dated) matches the budget.

🤖 Generated with Claude Code

@jdatcmd
jdatcmd merged commit bb1b864 into main Oct 26, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants