Skip to content

Fix: disable parallel index build on QD and AO tables (#12) - #15

Merged
my-ship-it merged 1 commit into
cloudberry-contrib:mainfrom
yjhjstz:fix-issue12-disable-parallel-build-on-qd
Jul 16, 2026
Merged

Fix: disable parallel index build on QD and AO tables (#12)#15
my-ship-it merged 1 commit into
cloudberry-contrib:mainfrom
yjhjstz:fix-issue12-disable-parallel-build-on-qd

Conversation

@yjhjstz

@yjhjstz yjhjstz commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

HNSW and IVFFlat manage their own parallel builds via plan_create_index_workers(), bypassing the guard in core's index_build() (catalog/index.c) that disables parallel index builds on the dispatcher and for AO tables.

On the QD, the coordinator's empty, never-analyzed copy of the table still gets a 10-page default size estimate, so parallel workers can be launched (e.g. with min_parallel_table_scan_size lowered). Those workers are forced to GP_ROLE_EXECUTE by ParallelWorkerMain() and inherit QE-only globals (ic_htab_size, numsegmentsFromQD) from the QD leader, where both are 0. The worker then crashes:

  • assert builds: FailedAssertion("ht->size > 0") in initConnHashTable (contrib/interconnect/udp/ic_udpifc.c)
  • non-assert builds: "cannot access table ... in current transaction" from the numsegments sanity check in cdbcat.c

Mirror the core guard in ComputeParallelWorkers() (hnsw) and AssignTuples() (ivfflat). Parallel builds on segments are unaffected: QE backends hand valid interconnect state to their workers, and each segment still uses parallel workers after this change.

Fixes #12


Change logs

Describe your change clearly, including what problem is being solved or what document is being added or updated.

Contributor's checklist

Here are some reminders before you submit your pull request:

  • Make sure that your Pull Request has a clear title and commit message. You can take the Git commit template as a reference.
  • Sign the Contributor License Agreement as prompted for your first-time contribution (One-time setup).
  • Learn the code contribution and doc contribution guides for better collaboration.
  • List your communications in the GitHub Issues or Discussions (if has or needed).
  • Feel free to ask for the cloudberrydb team to help review and approve.

Summary by CodeRabbit

  • Bug Fixes
    • Disabled parallel index building in dispatcher environments where it is unsupported.
    • Prevented parallel index builds for Append-Optimized tables.
    • Improved index build stability by ensuring parallel workers are only used in supported scenarios.

…trib#12)

HNSW and IVFFlat manage their own parallel builds via
plan_create_index_workers(), bypassing the guard in core's
index_build() (catalog/index.c) that disables parallel index builds
on the dispatcher and for AO tables.

On the QD, the coordinator's empty, never-analyzed copy of the table
still gets a 10-page default size estimate, so parallel workers can be
launched (e.g. with min_parallel_table_scan_size lowered). Those
workers are forced to GP_ROLE_EXECUTE by ParallelWorkerMain() and
inherit QE-only globals (ic_htab_size, numsegmentsFromQD) from the QD
leader, where both are 0. The worker then crashes:

- assert builds: FailedAssertion("ht->size > 0") in initConnHashTable
  (contrib/interconnect/udp/ic_udpifc.c)
- non-assert builds: "cannot access table ... in current transaction"
  from the numsegments sanity check in cdbcat.c

Mirror the core guard in ComputeParallelWorkers() (hnsw) and
AssignTuples() (ivfflat). Parallel builds on segments are unaffected:
QE backends hand valid interconnect state to their workers, and each
segment still uses parallel workers after this change.

Fixes cloudberry-contrib#12
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a027da64-e165-4eeb-9477-ff242cf9363d

📥 Commits

Reviewing files that changed from the base of the PR and between ba8a9b3 and 50c234f.

📒 Files selected for processing (2)
  • src/hnswbuild.c
  • src/ivfbuild.c

📝 Walkthrough

Walkthrough

Parallel index builds for HNSW and IVFFlat now disable worker execution when running as a dispatcher or against append-optimized tables. HNSW imports Cloudberry role declarations, while IVFFlat applies equivalent eligibility checks before planning workers.

Changes

Parallel index-build guards

Layer / File(s) Summary
HNSW worker eligibility
src/hnswbuild.c
ComputeParallelWorkers returns zero workers for dispatcher roles and append-optimized tables, with the required Cloudberry declarations included.
IVFFlat worker eligibility
src/ivfbuild.c
AssignTuples only plans and launches parallel workers when the heap exists, the backend is not a dispatcher, and the table is not append-optimized.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: disabling parallel index builds on QD and AO tables.
Description check ✅ Passed The description explains the bug, the fix, and includes the required issue reference and change log section.
Linked Issues check ✅ Passed The changes address #12 by preventing HNSW parallel builds on the QD while preserving valid parallel builds on segments.
Out of Scope Changes check ✅ Passed The ivfflat and AO-related guards are within the stated goal of mirroring the core parallel-build guard behavior.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@my-ship-it my-ship-it left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, thanks

@my-ship-it
my-ship-it merged commit 6ce3c96 into cloudberry-contrib:main Jul 16, 2026
4 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.

[Bug] HNSW parallel index build crashes Cloudberry with FailedAssertion("ht->size > 0") in ic_udpifc.c

2 participants