Skip to content

[Bug]: merge_chunks segfaults when merging chunks created before and after DROP COLUMNΒ #10665

Closed

Description

@alexeyklyukin

What type of bug is this?

Crash

What subsystems and features are affected?

Partitioning

What happened?

After dropping a hypertable column, merging a chunk created before the change with a chunk created afterward causes a segmentation fault. PostgreSQL terminates the other sessions and enters crash recovery.

The reproduction below crashes TimescaleDB 2.30.1 with only two rows in two uncompressed chunks.

Both merge_chunks and merge_chunks_concurrently also crashed on the same set of chunks in a TimescaleDB 2.29.2 installation.

Expected behavior: the merge completes without crashing and preserves both rows.

Assisted by OpenAI GPT-6 Astra, verified manually.

TimescaleDB version affected

2.30.1; also observed on 2.29.2

PostgreSQL version used

18.6

What operating system did you use?

Ubuntu 24.04, aarch64

What installation method did you use?

Docker

What platform did you run on?

On prem/Self-hosted, Timescale Cloud

Relevant log output and stack trace

LOG: server process (PID 125) was terminated by signal 11: Segmentation fault
DETAIL: Failed process was running:
CALL merge_chunks('{_timescaledb_internal._hyper_1_1_chunk,_timescaledb_internal._hyper_1_2_chunk}'::regclass[]);
LOG: terminating any other active server processes
LOG: all server processes terminated; reinitializing

Shortened backtrace from the original TimescaleDB 2.29.2 /
PostgreSQL 16.15 aarch64 crash, using merge_chunks_concurrently:

#0 heap_compute_data_size         heaptuple.c:236
#1 heap_form_tuple                heaptuple.c:1158
#2 reform_and_rewrite_tuple       heapam_handler.c:2484
#3 heapam_relation_copy_for_cluster
                                 heapam_handler.c:932
#4 table_relation_copy_for_cluster
                                 tableam.h:1691
#5 copy_table_data                tsl/src/chunk_merge.c:652
#6 merge_relinfos                 tsl/src/chunk_merge.c:750
#7 chunk_merge_chunks            tsl/src/chunk_merge.c:1439

How can we reproduce the bug?

\set ON_ERROR_STOP on

CREATE EXTENSION IF NOT EXISTS timescaledb;

SELECT version(), extversion
FROM pg_extension
WHERE extname = 'timescaledb';

CREATE TABLE merge_layout (
    time timestamptz NOT NULL,
    removed text,
    amount numeric,
    count integer
);

SELECT create_hypertable(
    'merge_layout',
    by_range('time', INTERVAL '1 day')
);

INSERT INTO merge_layout
VALUES ('2026-01-01 12:00+00', 'old', 12.5, 0);

ALTER TABLE merge_layout DROP COLUMN removed;

INSERT INTO merge_layout
VALUES ('2026-01-02 12:00+00', 25.5, 0);

SELECT array_agg(c)::text AS chunks
FROM show_chunks('merge_layout') c
\gset

CALL merge_chunks(:'chunks'::regclass[]);

Activity

  1. added
    v2.30.1
    on Sep 25, 2026
  2. added 6 commits that reference this issue on Sep 25, 2026
    fc65466
    9c5c643
    b7fa558
    57fcbdb
    ab9e5f1
    3b8b95e
  3. added a commit that references this issue on Sep 28, 2026
    0d714ab
  4. added a commit that references this issue on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugv2.30.1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions