Skip to content

Fix MERGE16_FIXME: cleanup AO vacuum, PartitionSelector, and qual pushdown#1820

Open
lss602726449 wants to merge 12 commits into
apache:mainfrom
lss602726449:fix-merge16-fixmes
Open

Fix MERGE16_FIXME: cleanup AO vacuum, PartitionSelector, and qual pushdown#1820
lss602726449 wants to merge 12 commits into
apache:mainfrom
lss602726449:fix-merge16-fixmes

Conversation

@lss602726449

Copy link
Copy Markdown
Contributor

Summary

  • Remove unnecessary vacuum_set_xid_limits calls for AO/AOCO tables: AO tables don't have per-tuple transaction IDs, so freeze/cutoff computation is meaningless. Removed the calls from vacuum_ao.c, appendonlyam_handler.c (CLUSTER), and aocsam_handler.c (CLUSTER). Fixed cluster.c to properly reset relminmxid for AO tables. Deleted the now-unused vacuum_set_xid_limits function entirely.

  • Remove incorrect FIXME in PartitionSelector: The CreatePartitionPruneState call is correct for Cloudberry's join-based partition pruning (distinct from ExecInitPartitionPruning which adds initial pruning + subplan map renumbering). Also removed two dead declarations (ExecCreatePartitionPruneState, ExecFindInitialMatchingSubPlans) left over from PG14.

  • Add UNSAFE_HAS_SUBPLAN flag for qual pushdown safety: Replaced the incorrect reuse of UNSAFE_NOTIN_PARTITIONBY_CLAUSE (a "soft" unsafe flag that still allows window run conditions) with a proper UNSAFE_HAS_SUBPLAN flag (hard block) for output columns containing subplans. This prevents unsafe pushdown of subplan-containing quals into subqueries in Cloudberry's distributed execution model.

Test plan

  • Compilation passes with --enable-cassert
  • make installcheck regression tests pass
  • isolation2 tests pass
  • Verify AO/AOCO VACUUM and CLUSTER operations work correctly
  • Verify partition pruning with PartitionSelector still works

@tuhaihe tuhaihe requested review from chenjinbao1989 and reshke June 16, 2026 03:43
@lss602726449 lss602726449 force-pushed the fix-merge16-fixmes branch 2 times, most recently from f18cf09 to 968a42d Compare June 22, 2026 02:23
AO/AOCO tables have no per-tuple xmin/xmax -- visibility is managed
via visibility map at segment level, not per-tuple transaction IDs.
The freeze limits computed by vacuum_set_xid_limits are meaningless
for AO tables. Worse, passing MultiXactCutoff to vac_update_relstats
(vacuum) or swap_relation_files (CLUSTER) incorrectly sets relminmxid
on AO tables (whose relminmxid should remain InvalidMultiXactId),
causing them to unnecessarily participate in database-wide datminmxid
calculation.

Fix by:
- vacuum_ao.c: remove vacuum_set_xid_limits call, pass Invalid values
  directly to vac_update_relstats
- appendonlyam_handler.c / aocsam_handler.c: remove vacuum_set_xid_limits
  call in copy_for_cluster, return Invalid values to caller
- cluster.c: relax MultiXactId assert to allow InvalidMultiXactId,
  and reset relminmxid to InvalidMultiXactId for AO tables (matching
  the existing relfrozenxid override)

vacuum_set_xid_limits was a pre-PG16 API kept only for AO callers.
With all callers removed, delete the function and its declaration.
The CreatePartitionPruneState() call in nodePartitionSelector.c is
correct -- PartitionSelector only needs the pruning data structure,
not the initial pruning and subplan map renumbering that
ExecInitPartitionPruning() adds on top. Remove the incorrect FIXME.

Also remove two dead declarations in execPartition.h:
- ExecCreatePartitionPruneState: renamed to CreatePartitionPruneState
  in PG15 (commit 297daa9), declaration was never cleaned up
- ExecFindInitialMatchingSubPlans: folded into ExecFindMatchingSubPlans
  in the same refactor, declaration was never cleaned up
The subplan check in check_output_expressions was incorrectly using
UNSAFE_NOTIN_PARTITIONBY_CLAUSE, which only prevents normal pushdown
but still allows the qual to be pushed as a window run condition.
Subplans in output expressions should completely block pushdown in
Cloudberry's distributed execution model.

Add a dedicated UNSAFE_HAS_SUBPLAN flag and include it in the fully
unsafe set in qual_is_pushdown_safe, so quals referencing output
columns containing subplans are never pushed down.
…ryFileUsage

Re-enable temporary file size reporting to pgstat and the associated
Assert in FileClose. Fix a SIGSEGV in ReportTemporaryFileUsage that
occurred during process exit when the resource owner was already
released.
…c_mpp_query

The commented-out code stripped write permissions from RTEs on non-root
slices. This is unnecessary because InitPlan already skips permission
checks on non-writer segments (execMain.c:1821). Additionally, PG16
moved requiredPerms from RTE to RTEPermissionInfo, making the original
code incompatible.
The forceoverwrite check is unnecessary here because
verify_dir_is_empty_or_create already handles non-empty directories
before tar extraction begins.
…d output

Enable pg_waldump validation in singlenode prevent_ao_wal test (was
disabled by MERGE16_FIXME). Broaden matchignore to handle both "fatal"
and "error" messages from pg_waldump. Add missing blank lines in
expected output after pg_waldump command output.
Re-enable segwalrep/select_throttle in isolation2_schedule and
workfile_mgr_test in singlenode. Fix gpstop -ari to -arf for singlenode
mode where immediate shutdown causes crash recovery and blocks
connections.
verify_cpu_usage() only used the first sample (all_info[0]) instead of
averaging all collected samples, making it sensitive to single-sample
fluctuations on busy CI machines. Use the mean of all samples as the
function comment originally intended.
…ouble-release

Cloudberry has a built-in scalar 'complex' type whose complex_in doesn't
support PG16's soft-error API. Rename to 'complex_t' composite type in
rowtypes tests to avoid conflict.

Fix record_in double ReleaseTupleDesc bug: remove 6 redundant
ReleaseTupleDesc calls before 'goto fail', since the fail label already
releases tupdesc. The double-release caused SIGSEGV on malformed
composite type input via pg_input_is_valid.
…e DDL

Two fixes for the flaky heap_blks_vacuumed=9/index_vacuum_count=2 in
the worker-changed scenario:

1. procarray.c: use globalxmin instead of xmin for def_vis_xid_data
   computation per the GPDB_14_MERGE_FIXME comment, ensuring GlobalVis
   considers distributed transaction xmin boundaries.

2. Remove inline CREATE OR REPLACE FUNCTION wait_for_mirror_down and
   its SELECT calls from vacuum_progress tests. The DDL dispatch to
   segments advanced DistributedLogShared->oldestXmin past compact XIDs,
   causing the new vacuum worker in post-cleanup to see stale segments
   as recyclable.
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.

1 participant