apache / apache/cloudberry

Default storage options for AO tables not persisted to pg_class.reloptions

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

Description

### Issue Description

The system configuration `gp_default_storage_options` defines several defaults, including `blocksize`, `compresstype`, and `checksum`. However, when an AO table is created with only the `WITH (appendonly=true)` clause, **none** of these default values are persisted to the table's metadata in the `pg_class.reloptions` column. The column remains `NULL`.

This behavior differs from Greenplum, which correctly persists all applicable defaults from `gp_default_storage_options` to `pg_class.reloptions`. Since `gp_default_storage_options` is a GUC that can be changed at any time, it is critical that the effective storage options at creation time are explicitly recorded in the metadata. The current behavior in Cloudberry leads to a loss of critical metadata, making it impossible to know the table's original storage properties if the GUC is changed later.

### Reproduction and Evidence

The following raw `psql` session logs demonstrate the issue. The session on Cloudberry shows that the default options are not persisted to `pg_class.reloptions`. The session on Greenplum shows the expected, consistent behavior.

```text
cbdb@robertmu-VirtualBox:~/Projects/cloudberry$ psql
psql (14.4, server 14.4)
Type "help" for help.

cbdb=# select version();
version
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 14.4 (Apache Cloudberry 2.1.0-devel+dev.2019.g1cc76495e18 build dev) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0, 64-bit compiled on Jul 18 2025 11:29:40
(1 row)

cbdb=#
cbdb=# create table tab_ao(i int) with(appendonly=true);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Apache Cloudberry data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE
cbdb=#
cbdb=# select oid, relname, reloptions from pg_class where relname = 'tab_ao';
oid | relname | reloptions
-------+---------+------------
21682 | tab_ao |
(1 row)

cbdb=#
cbdb=# show gp_default_storage_options;
gp_default_storage_options
-------------------------------------------------
blocksize=32768,compresstype=none,checksum=true
(1 row)

cbdb=#

gpdb7@robertmu-VirtualBox:~/Projects/gpdb-archive$ psql
psql (12.12)
Type "help" for help.

gpdb7=# select version();
version
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 12.12 (Greenplum Database 7.0.0-beta.0+482967c1b4 build dev) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0, 64-bit compiled on Nov 8 2024 23:43:47 Bhuvnesh C.
(1 row)

gpdb7=#
gpdb7=# create table tab_ao(i int) with(appendonly=true);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE
gpdb7=#
gpdb7=# select oid, relname, reloptions from pg_class where relname = 'tab_ao';
oid | relname | reloptions
-------+---------+-------------------------------------------------------------------
18326 | tab_ao | {blocksize=32768,compresslevel=0,compresstype=none,checksum=true}
(1 row)

gpdb7=#
gpdb7=# show gp_default_storage_options;
gp_default_storage_options
-------------------------------------------------
blocksize=32768,compresstype=none,checksum=true
(1 row)

gpdb7=#
```

### Expected Behavior

The `reloptions` column in `pg_class` for the `tab_ao` table should contain all the default storage options (`blocksize=32768`, `compresslevel=0`, `compresstype=none`, `checksum=true`), as these are the effective defaults set by `gp_default_storage_options` at the time of creation.

### Actual Behavior

The `reloptions` column in `pg_class` for the `tab_ao` table is `NULL`, indicating that no default storage options were persisted.

### Environment

- **Cloudberry Version:** `PostgreSQL 14.4 (Apache Cloudberry 2.1.0-devel+dev.2019.g1cc76495e18 build dev)`
- **Greenplum Version:** `PostgreSQL 12.12 (Greenplum Database 7.0.0-beta.0+482967c1b4 build dev)`

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the CREATE TABLE and pg_class.reloptions queries from the issue, then trace how gp_default_storage_options is applied during append-only table creation. Compare the resulting metadata with the expected blocksize, compresslevel, compresstype, and checksum values; done when those effective defaults are persisted in reloptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
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.