Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] REINDEX DATABASE CONCURRENTLY breaks temporary PAX tables created with ON COMMIT DELETE ROWS

未关闭
#2,134 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
32/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c, postgresql, sql
领域
databases

调研方向

Start with the reproduction in the issue, then read how the aux table is created in pax_aux_table.cc and how ON COMMIT DELETE ROWS truncation reaches heap_truncate_one_rel through CPaxNontransactionalTruncateTable. FindAuxIndexOid and the check at pax_manifest.cc:753 explain why the leftover _ccnew index breaks later inserts. Done means REINDEX DATABASE CONCURRENTLY leaves the temporary PAX table usable, with a regression test covering it.

由索引模型根据 Issue 内容生成。

描述

type: Bug
Apache Cloudberry version

main

What happened

Reproduce:

CREATE TEMP TABLE p(a int) USING pax ON COMMIT DELETE ROWS DISTRIBUTED BY (a);
REINDEX DATABASE CONCURRENTLY <current_database>;
-- ERROR:  index "pg_pax_blocks_<oid>_idx_ccnew" already contains data (nbtsort.c:327)

INSERT INTO p VALUES (1);
-- ERROR:  .../pax_manifest.cc:753 C ERROR detail: (PG message: unexpected number of index of aux table: 2)
After this, every INSERT into p fails for the rest of the session.

Expected: REINDEX succeeds and the table stays usable, as it does with a non-concurrent REINDEX DATABASE, a plain PAX table, a temporary PAX table without ON COMMIT DELETE ROWS, or a heap table with ON COMMIT
DELETE ROWS.

Cause (from reading the code):

  • The aux table of a temporary PAX table is created as permanent (pax_aux_table.cc). PostgreSQL's rule of never reindexing temporary relations concurrently therefore doesn't apply, and the aux index is rebuilt
    concurrently.
  • Between the concurrent reindex's transactions, the ON COMMIT DELETE ROWS truncation (CPaxNontransactionalTruncateTable, which calls heap_truncate_one_rel) re-initializes every index on the aux table,
    including the unbuilt _ccnew index. The build step then fails.
  • The failed reindex leaves _ccnew behind. FindAuxIndexOid counts invalid indexes too, so every later write fails.
What you think should happen instead

No response

How to reproduce
CREATE TEMP TABLE p(a int) USING pax ON COMMIT DELETE ROWS DISTRIBUTED BY (a);
REINDEX DATABASE CONCURRENTLY <current_database>;
-- ERROR:  index "pg_pax_blocks_<oid>_idx_ccnew" already contains data (nbtsort.c:327)

INSERT INTO p VALUES (1);
-- ERROR:  .../pax_manifest.cc:753 C ERROR detail: (PG message: unexpected number of index of aux table: 2)
After this, every INSERT into p fails for the rest of the session.
Operating System

any

Anything else

No response

Are you willing to submit PR?
  • Yes, I am willing to submit a PR!
Code of Conduct
主要语言
C
星标
1.4k
派生
260
平均合并
4 天 19 小时
30 天内合并 PR
54

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/cloudberry 的其他 Issue

查看 apache/cloudberry 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。