-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Segfault when updating a row in a hypertable #7497
Comments
Changed UPDATE to INSERT... ON CONFLICT DO UPDATE and the segfault does not happen anymore. |
I have the same problem, and I drop database and recreate database, reinstall timescaledb, the issue still, finally I reinstall operation system and pgsql, timescaledb, the issue does not happen. |
@timopulkkinen I created the following test script in order to try and reproduce the issue: create table aa (id bigint primary key);
create table ab (id int primary key, reference text);
create table ac (id text primary key);
insert into aa values (1);
insert into ab values (1, 'test');
insert into ac values ('1');
create table a (
id bigserial not null,
foreign_key_aa bigint not null references aa,
foreign_key_ab int not null references ab,
foreign_key_ac text not null references ac,
id2 bigint,
reference text not null,
value int,
created_at timestamptz not null default now(),
created_at_date timestamptz not null default date_trunc('day', now() AT TIME ZONE 'UTC'),
updated_at timestamptz not null default now(),
unique(foreign_key_ab, id2, created_at_date),
PRIMARY KEY (id, created_at_date)
);
SELECT create_hypertable('a', 'created_at_date', chunk_time_interval => INTERVAL '1 week');
ALTER TABLE a SET (
timescaledb.compress,
timescaledb.compress_orderby = 'created_at_date, reference, id',
timescaledb.compress_segmentby = 'foreign_key_aa, foreign_key_ab, foreign_key_ac, id2'
);
insert into a (foreign_key_aa, foreign_key_ab, foreign_key_ac, id2, reference, value, created_at, created_at_date, updated_at)
select 1, 1, '1', (random()*50)::int, 'test', (random()*30)::int, t, date_trunc('day', t), t
from generate_series(timestamptz '2024-01-01 00:00:00',
timestamptz '2024-12-31 00:00:00',
interval '1 day') t;
insert into a values (1, 1, 1, '1', 1, 'test', 1, '2024-01-01', '2024-01-01', '2024-01-01');
CREATE INDEX a_foreign_key_aa_idx ON a(foreign_key_aa);
CREATE INDEX a_id2 ON a(id2);
CREATE INDEX a_foreign_key_ab_idx ON ab(id, reference);
--SELECT add_compression_policy('a', INTERVAL '6 months');
select count(compress_chunk(ch)) from show_chunks('a') ch;
update a set value = 0 where id = 1; However, I can't get it to crash. Maybe there is something missing? Can you try the script on your environment or try to provide a test setup that reproduces the crash? |
1.16.1 and 15.9 Postgres:
|
@erimatnor Modified your script a bit and was able to reproduce the issue in our environment. Notably the issue didn't occur with
|
@timopulkkinen I still can't get the script to cause a crash on my local setup. I tried TimescaleDB 2.16.1 on both PG15.0 and PG17.2. I also tried TimescaleDB 2.17.1 on those setups. I tried different IDs in the update. |
My data is from old timescaleDB version update to new version (2.14 to 2.15.3 or 2.15.3 to 2.16, I don't remember), and export dump , import dump to new server. and my system is hyper-v virtual machine, also used export and import to install. |
@erimatnor Tried this with the TimescaleDB Docker image locally and wasn't able to make it crash either, not even when I tried to replicate the config that we have on the actual server. However, with the following Dockerfile and configuration the crash occurs at least for me locally. In the Dockerfile platform is set to amd64. |
@erimatnor I debugged this further - but first, I noticed my Docker package was a bit half-baked. Included a better version. Anyways, I was able to pinpoint the issue to be with 17.0.1 version of Postgres (latest Percona release). When I downgraded to 16.x, the segfault issue disappeared. The same goes for TimescaleDB Docker image, which runs 17.2. I rebuilt our cluster using Postgres maintained packages for 17.2 and ... and as expected, no segfault anymore. |
@timopulkkinen when I ran the script with the Docker package you provided, I got a segfault once, and the following error on multiple other attempts to replicate it:
I'll look into it further. |
What type of bug is this?
Crash
What subsystems and features are affected?
Compression, Query executor
What happened?
Hi,
experiencing a segfault when updating a freshly created row in a hypertable chunked by row creation time (different transactions for create and update). If creation time is set to current time, the crash does not reproduce.
Table schema ( a bit redacted):
Query:
Note: as you know, the update in this form will cause a complete scan of all chunks of the table, but still a segfault shouldn't happen.
There is also a trigger bound to the update event that spawns updates in other tables.
TimescaleDB version affected
2.17.2
PostgreSQL version used
17.0.1 (Percona builds)
What operating system did you use?
Ubuntu 24.04 x64
What installation method did you use?
Deb/Apt
What platform did you run on?
On prem/Self-hosted
Relevant log output and stack trace
Log output:
The text was updated successfully, but these errors were encountered: