apache / apache/cloudberry

[Bug] GIN index creation fails on AO (Append-Optimized) and PAX tables with internal error (assert.c:48)

Open
#1,493 3 comments 0 reactions 0 assignees View on GitHub
type: Bug
Dominant language
C
Stars
1.4k
Forks
247
Avg merge
4d 3h
Merged PRs (30d)
39

Description

### Apache Cloudberry version

PostgreSQL 14.4 (Apache Cloudberry 2.0.0-incubating build dev) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14.astra4+deb12u1) 12.2.0, 64-bit compiled on Dec 9 2025 14:23:53 (with assert checking)

### What happened

Hello!
GIN indexes cannot be created on AO (Append-Optimized) and PAX tables. The operation fails with the following error:
2025-12-13 12:17:35.354429 MSK,"gpadmin","cbdev",p6569,th180242880,"10.0.0.84","52684",2025-12-13 12:16:40 MSK,154664,con320,cmd1,seg1,,dx335992,x154664,sx1,"FATAL","XX000","Unexpected internal error (assert.c:48)","FailedAssertion(""OffsetNumberIsValid(ItemPointerGetOffsetNumber(&segment->first))"", File: ""ginpostinglist.c"", Line: 338)",,,,,"create INDEX ix_test_gin_table ON public.test_gin_table USING gin(text_field gin_trgm_ops)",0,,"assert.c",48,"Stack trace:
1 0x73a60d2546c3 libpostgres.so errstart + 0x226
2 0x73a60d254910 libpostgres.so errstart_cold + 0x9
3 0x73a60d24dedc libpostgres.so ExceptionalCondition + 0x87
4 0x73a60cc34ea8 libpostgres.so ginPostingListDecodeAllSegments + 0xc2
5 0x73a60cc351b8 libpostgres.so ginPostingListDecode + 0x1b
6 0x73a60cc353e8 libpostgres.so ginCompressPostingList + 0x22b
7 0x73a60cc33f2a libpostgres.so ginEntryInsert + 0x403
8 0x73a60cc345ba libpostgres.so ginbuild + 0x317
9 0x73a60cd52e46 libpostgres.so index_build + 0x461
10 0x73a60cd5553a libpostgres.so index_create_internal + 0x1800
11 0x73a60cd55628 libpostgres.so index_create + 0xe9
12 0x73a60ce34e32 libpostgres.so DefineIndex + 0x1a95
13 0x73a60d105aae libpostgres.so + 0xd105aae
14 0x73a60d1047a0 libpostgres.so standard_ProcessUtility + 0xf92
15 0x73a6082026a2 pax.so + 0x82026a2
16 0x73a60d104aed libpostgres.so ProcessUtility + 0xfc
17 0x73a60d101749 libpostgres.so + 0xd101749
18 0x73a60d1018ea libpostgres.so + 0xd1018ea
19 0x73a60d101f5b libpostgres.so PortalRun + 0x1b8
20 0x73a60d0fb36d libpostgres.so + 0xd0fb36d
21 0x73a60d0fdb54 libpostgres.so PostgresMain + 0x1362
22 0x73a60d04d6af libpostgres.so + 0xd04d6af
23 0x73a60d04f259 libpostgres.so PostmasterMain + 0x16f5
24 0x56595ca989bc postgres main + 0x619
25 0x73a60c44624a libc.so.6 + 0xc44624a
26 0x73a60c446305 libc.so.6 __libc_start_main + 0x85
27 0x56595ca98261 postgres _start + 0x21

The same operation works correctly on HEAP tables.

### What you think should happen instead

GIN index should be created successfully on AO/PAX tables.

### How to reproduce

create extension pg_trgm;

create table public.test_gin_table(id bigint, text_field text)
USING ao_column
WITH (
compresstype=zstd,
compresslevel=1,
blocksize=32768,
checksum=true
)
distributed by (id)
;

insert into public.test_gin_table
(id,text_field)
select
row_number() over(),
attname
from pg_attribute

create INDEX ix_test_gin_table ON public.test_gin_table USING gin(text_field gin_trgm_ops);

### Operating System

Debian 12.2.0

### Anything else

Every time

### Are you willing to submit PR?

- [ ] Yes, I am willing to submit a PR!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/cloudberry/blob/main/CODE_OF_CONDUCT.md).

Contributor guide

Open the contributing guide

Research direction

Start with the SQL reproduction in the issue, then inspect ginpostinglist.c around line 338 and the GIN build path shown in the stack trace. Compare index creation on AO/PAX tables with the working HEAP case. Done means the reproduced GIN index is created successfully on AO and PAX tables without the assertion failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.