Repository navigation
Conversation
…2092) import_arrow and import_parquet aborted the backend on a table with a projection, on a PostgreSQL 18 or 19 build with assertions. PostgreSQL then restarted every session, and the import rolled back. The import buffers the projection's rows and writes them when the statement ends. For a SELECT that is during portal cleanup, when no snapshot is active. The projection write reads the options catalog with GetTransactionSnapshot(), which nobody had registered, and the first catalog tuple it examined failed the assertion in HeapTupleSatisfiesMVCC. The base table's write already pushes an active snapshot for this reason, but it pops it before the projections are written. flush_ws_projections_ext now pushes its own. Tests, written first and red on main's code on PG18: one check in test/arrow_import.sh and one in test/parquet_import.sh, with their pytest twins in test_arrow_import.py and test_parquet_import.py. Each crosses projection with set_options on four tables and reads crashes from the server log. Ledger: two rows, merged from green runs of both suites on PG15, 16, 17, 18 and 19 in one merge, then from each red PG18 run with --reds-are-real and the mutation "main's code before the #2092 fix". Both rows are dated, so never stays 4894 and the budget does not move: 9660 + 2 = 9662 rows, 4766 + 2 = 4768 dated. Ledger-census: rows=9662 never=4894 dated=4768 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A reviewer found that the arm without set_options (o0p1) of the four new #2092 checks could not fail on main's code. The crash needs a row in the options catalog for any table. The matrix runs o0p1 before any case calls set_options, so in the shell suites and in the arrow pytest the catalog was still empty. The parquet pytest went red on o0p1 only because the arrow test had left a row behind. So these tests were wrong for that arm: their names say "with or without set_options", but only the arm with set_options proved the fix. Each check now gives a neighbour table an options row before the matrix. On main's code o0p1 now crashes in all four, each run on its own. The names and wanted values do not change. The comments and docstrings are rewritten in whole sentences. A new check in test/parallel_copy.sh, and its twin in test_parallel_copy.py, answers #2092's parallel_copy criterion. It loads 1 worker into an empty projection and 2 workers into a projection that already holds rows, each table with an options row. Both fill the projection and no backend dies, on main's code too: parallel_copy does not share the import crash. It is a coverage check, not a regression test of the fix. A mutation that skips every projection write turns it red. With 2 or more workers into an empty projection, parallel_copy hangs, for another reason. That is filed as #2161, and no case covers it. The CHANGELOG entry is rewritten in whole sentences. Registries: cluster_tests 5378 -> 5379. TESTS.md gains the new test and notes the neighbour row. check_ledger.tsv gains one row, merged from green parallel_copy.sh runs on PG15 to 19, then from the red PG18 run under the mutation "flush_ws_projections_ext returns before it writes any projection row" with --reds-are-real. The row is dated, so never stays 4894 and the budget does not change: 9662 + 1 = 9663 rows, 4768 + 1 = 4769 dated. Ledger-census: rows=9663 never=4894 dated=4769 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fix-up: what I did about each problem (commit 0aa1702)All runs: sandbox, PostgreSQL 18.6 and 17.11 built with 1. No
|
| Suite | PG15 | PG16 | PG17 | PG18 | PG19 |
|---|---|---|---|---|---|
arrow_import.sh |
101/101 | 101/101 | 101/101 | 101/101 | 101/101 |
parquet_import.sh |
19 passed, 7 skipped | 19 passed, 7 skipped | 26/26 | 26/26 | 26/26 |
parallel_copy.sh |
97/97 | 97/97 | 97/97 | 97/97 | 97/97 |
These pytest files were run with -n 4: test_arrow_import.py, test_parquet_import.py and test_parallel_copy.py.
PG18: accounting: 225 pass + 0 fail + 0 unrun = 225 134 passed in 9.46s
PG17: accounting: 225 pass + 0 fail + 0 unrun = 225 134 passed in 9.97s
Guard half: 894 passed, accounting: 2440 pass + 0 fail + 0 unrun = 2440. compare_to_bash.py gives missing: 0 for all three pairs.
Registries
expected_tests.txt:cluster_tests5378 -> 5379, by collection over the cluster files (5379 tests collected).TESTS.md: the new test in section 297, and the neighbour row in sections 108 and 140.check_ledger.tsv: one row. It comes from the greenparallel_copy.shlogs on PG15 to 19, then from the mutation's red log with--reds-are-real. The row is dated, soneverstays 4894 and the budget does not change.census-commits:2 change test/check_ledger.tsv since d52f6e8c (merge base with origin/main), 0 refused.
Still not verified
- Non-assert builds.
- The red on PG19.
- The full pytest cluster suite.
parallel_copyinto a partitioned target with a projection.
ubuntu-latest moved from ubuntu-24.04 to ubuntu-26.04 between 2026-11-12 and 2026-11-22. Since then `sudo -E` no longer carries GITHUB_BASE_REF into run_all_versions.sh. The ledger gate then cannot find the PR's base and refuses: "no trustworthy prior ceiling: GITHUB_BASE_REF is unset". Every PR fails suites (PG 17) and suites (PG 18) although every suite passes (#2056, and every PR from #2127 to #2159). The step now names the variable in the env list, so it reaches the gate whatever sudo preserves. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pshot Since ubuntu-latest moved to 26.04, the suites (PG 17/18) jobs fail with "ledger integrity failure: no trustworthy prior ceiling: GITHUB_BASE_REF is unset", although the suites pass. PR #2162 (845c83e) fixes the CI step but is not in main yet, so this branch takes it to let CI go green. CHANGELOG.md: both entries kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged the CI fix from #2162 into this branch (ab858bd)What I merged. Why. No suite failed in either job: both logs hold 0 Local checks on ab858bd (PG 18.6)
|
Fixes #2092.
Problem
pgcolumnar.import_arrow()andpgcolumnar.import_parquet()abort the backend on a table that has a projection, on a PostgreSQL 18 or 19 build with assertions. PostgreSQL then restarts every session, and the import rolls back.docs/how-to.mdadds a projection and later imports an Arrow file. A reader who runs the guide from top to bottom hits the crash once the projection example works (it fails today, #2093).The crash needs a row in the options catalog, for any table.
set_optionson the table gives one. Without it, a projection alone crashes once another table has an options row. The tests give a neighbour table one first, so the case withoutset_optionsfails on main's code too.Cause
The import buffers the projection's rows and writes them when the statement ends, in
pgcolumnar_executor_end. An import is aSELECT, so its statement ends in portal cleanup, where no snapshot is active. The projection write (flush_ws_projections_ext) builds a write state, which reads the options catalog withGetTransactionSnapshot(). Nobody has registered that snapshot, so the first catalog tuple examined failsAssert(snapshot->regd_count > 0 || snapshot->active_count > 0)inHeapTupleSatisfiesMVCC. PostgreSQL 15, 16 and 17 have no such assertion.The base table's write (
pgcolumnar_flush_row_group) already pushes an active snapshot for this reason. It pops it before the projections are written, so the projection write runs without one. A plainINSERT ... SELECTdoes not reach this, because itsExecutorEndruns with the statement's snapshot still active.I confirmed this with temporary logging (removed): during the failing import, the projection flush ran with
ActiveSnapshotSet()false, and the options read got a snapshot withregd_count=0 active_count=0.The fix
flush_ws_projections_ext(src/columnar_write_state.c) pushesGetTransactionSnapshot()as the active snapshot when none is set, and pops it after the projection writers are flushed. This is the same patternpgcolumnar_flush_row_groupuses. It changes nothing when a snapshot is already active.Update after review (commit 0aa1702)
A verifier found four problems. The review fix-up comment lists each with its output. In short:
parallel_copycheck (shell and pytest) loads into a table with a projection.parallel_copydoes not share this crash. With 2 or more workers into an empty projection it hangs, for another reason: filed as interchange: parallel_copy into a table with an empty projection hangs until cancelled with 2 or more workers #2161.sqlblock ofdocs/how-to.mdin order. On this branch: 0 backend crashes. On main's code, with theeventscolumns that docs: eight SQL examples in the how-to, user guide and SQL reference fail when run as written #2093 says are missing: 1 crash, at "Import and export Arrow".set_optionscould not fail on main's code. Each check now gives a neighbour table an options row first; on main's code that case now crashes in all four tests.The sections below describe the first commit. The red output there predates the neighbour fix; the comment has the new red output.
Red, on main's code (PG18.6 with assertions, d52f6e8)
Shell,
test/arrow_import.shandtest/parquet_import.sh:Each case reads
o<set_options>p<projection>:<imported>/<rows in table>/<rows in projection>.pytest (the tests had their first names then; they were renamed later so that no test name appears twice in the corpus):
The 2 errors are the fixtures' teardown, whose connection the crash closed. In the parquet test,
o0p1(projection only) crashed too, because the arrow test had left an options row in the catalog.Green
The build has no compiler warnings on PG15, 16, 17, 18 and 19 (
grep -c warning:gave 0 on each).Suites run
On the committed C code and shell suites. I renamed the two pytest functions after these runs, before committing; nothing else changed.
arrow_import.shparquet_import.shprojections.shprojection_update.shprojection_rewrite.shprojection_parallel.shprojection_drop_column.shprojection_rename_restore.shprojection_privilege.shsorted_projection.shnative_projection.shThe 7 skips on PG15 and 16 are the partitioned-parent checks, which need PG17, as on main.
pytest, with
-n 4:test_arrow_import.py,test_parquet_import.py,test_arrow_import_encoding.py,test_import_deferred.py,test_import_exclusion.py,test_projections.py,test_projection_*.py(7 files),test_sorted_projection.pyandtest_native_projection.py:After the rename,
test_arrow_import.pyandtest_parquet_import.pyagain: 37 passed on PG18 and 37 passed on PG17.Guard half, as the README shows:
894 passed,accounting: 2440 pass + 0 fail + 0 unrun = 2440.compare_to_bash.pygivesmissing: 0for both pairs.Registries
expected_tests.txt:cluster_tests5376 -> 5378, collected over the filesNO_CLUSTERdoes not name (5378 tests collected).TESTS.md: both tests in the tables of sections 108 and 140, and the section text.check_ledger.tsv: two rows. They come from one merge of green logs of both suites on PG15 to 19, then from each red PG18 log with--reds-are-real. Both rows are dated, sochecks_never_observed_redstays 4894 andcheck_ledger_budget.txtdoes not change.census-commits: 0 refused.expected_unrunnable.txt: no change. Neither test declines on any major.CHANGELOG.md: a Fixed entry.Not verified
🤖 Generated with Claude Code