Skip to content

Fix: pg_task / pg_task_run_history column reorder with catversion bump - #1817

Merged
roseduan merged 5 commits into
apache:mainfrom
roseduan:fix/pg-task-catalog-version-bump
Jul 22, 2026
Merged

Fix: pg_task / pg_task_run_history column reorder with catversion bump#1817
roseduan merged 5 commits into
apache:mainfrom
roseduan:fix/pg-task-catalog-version-bump

Conversation

@roseduan

Copy link
Copy Markdown
Contributor

Some non-varlen fields (int32 nodeport, bool active in pg_task; timestamptz start_time / end_time in pg_task_run_history) were declared after CATALOG_VARLEN, which trips LLVM bitcode emission during JIT compilation.

Move them ahead of the varlen block. Because this rearranges the on-disk pg_attribute layout, bump CATALOG_VERSION_NO so an upgraded binary refuses to start against a pre-reorder cluster instead of crashing at runtime with SIGSEGV in heap_form_tuple on the first CREATE TASK.

Adjust ruleutils.c pg_get_dynamic_table_schedule() to fetch the schedule via heap_getattr() since &task->schedule on the Form struct is no longer valid for varlen-section fields.

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


@roseduan
roseduan force-pushed the fix/pg-task-catalog-version-bump branch from b09ca97 to 38d28f2 Compare June 12, 2026 02:54
Some non-varlen fields (int32 nodeport, bool active in pg_task;
timestamptz start_time / end_time in pg_task_run_history) were
declared after CATALOG_VARLEN, which trips LLVM bitcode emission
during JIT compilation.

Move them ahead of the varlen block. Because this rearranges the
on-disk pg_attribute layout, bump CATALOG_VERSION_NO so an upgraded
binary refuses to start against a pre-reorder cluster instead of
crashing at runtime with SIGSEGV in heap_form_tuple on the first
CREATE TASK.

Adjust ruleutils.c pg_get_dynamic_table_schedule() to fetch the
schedule via heap_getattr() since &task->schedule on the Form
struct is no longer valid for varlen-section fields.
@roseduan
roseduan force-pushed the fix/pg-task-catalog-version-bump branch from 38d28f2 to bddb9b0 Compare June 15, 2026 08:38
@roseduan
roseduan requested a review from my-ship-it June 17, 2026 07:27

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

Copilot AI 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.

Pull request overview

This PR fixes a system-catalog layout issue where fixed-length fields were declared after the varlen boundary in pg_task and pg_task_run_history, which can break LLVM bitcode emission during JIT. It reorders the affected columns, bumps CATALOG_VERSION_NO to prevent unsafe in-place upgrades, and updates pg_get_dynamic_table_schedule() to fetch schedule via heap_getattr() since varlen fields are no longer addressable through the FormData_pg_task struct.

Changes:

  • Reorder pg_task and pg_task_run_history columns so fixed-length fields precede the CATALOG_VARLEN section.
  • Bump CATALOG_VERSION_NO to force version mismatch on pre-reorder clusters.
  • Update pg_get_dynamic_table_schedule() to read schedule with heap_getattr().

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/include/catalog/pg_task.h Moves nodeport/active ahead of the varlen block and marks varlen fields under CATALOG_VARLEN.
src/include/catalog/pg_task_run_history.h Moves start_time/end_time ahead of the varlen block; keeps varlen fields under CATALOG_VARLEN.
src/include/catalog/catversion.h Bumps CATALOG_VERSION_NO to reflect on-disk catalog layout change.
src/backend/utils/adt/ruleutils.c Switches schedule extraction to heap_getattr() for varlen safety.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/backend/utils/adt/ruleutils.c
Comment thread src/backend/utils/adt/ruleutils.c

@chenjinbao1989 chenjinbao1989 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@roseduan
roseduan merged commit 9c3d48e into apache:main Jul 22, 2026
70 of 71 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.

4 participants