timescale / timescaledb

An open-source time-series SQL database optimized for fast ingest and complex queries. Packaged as a PostgreSQL extension.
https://www.timescale.com/
Other
17.93k stars 882 forks source link

[Bug]: Segmentation fault while trying to update table on PostgreSQL 16.5 and 17.1 #7478

Closed netrusov closed 14 hours ago

netrusov commented 1 day ago

What type of bug is this?

Crash

What subsystems and features are affected?

Other

What happened?

We've encountered an issue while upgrading our PostgreSQL from 16.4 to 17.1 We are using TimescaleDB extension version 2.17.2

After upgrade, we saw that some queries were causing an "Segmentation fault" exception. I've been experimenting with the data and came up with a reproducible test case, which is failing on PG 16.5 and 17.1, but everything is good on 16.4 and 17.0 Problem occurs when there are multiple chunks being used, I've reflected it in my test case.

Sometimes we see ERROR: targetColnos does not match subplan target list error, but after running query again it will cause segfault.

TimescaleDB version affected

2.17.2

PostgreSQL version used

16.5, 17.1

What operating system did you use?

OEL, Debian/Ubuntu

What installation method did you use?

Deb/Apt, RPM

What platform did you run on?

On prem/Self-hosted

Relevant log output and stack trace

2024-11-21 17:50:47.002 UTC [1] LOG:  server process (PID 1464) was terminated by signal 11: Segmentation fault
2024-11-21 17:50:47.002 UTC [1] DETAIL:  Failed process was running: UPDATE
          t1
        SET
          value = 'bar'
        WHERE
          id = 2;
2024-11-21 17:50:47.002 UTC [1] LOG:  terminating any other active server processes

### How can we reproduce the bug?

DROP TABLE IF EXISTS t1;

CREATE TABLE t1 (
  id bigint,
  value text,
  created_at timestamp
);

SELECT
  *
FROM
  create_hypertable(
    't1',
    'created_at',
    chunk_time_interval => interval '2 days'
  );

INSERT INTO
  t1
VALUES
  (1, 'foo', '2024-11-19 00:00:00.000000');

INSERT INTO
  t1
VALUES
  (2, 'foo', '2024-11-21 00:00:00.000000');

UPDATE
  t1
SET
  value = 'bar'
WHERE
  id = 2;
netrusov commented 1 day ago

I see that 16.6 and 17.2 were released today, I'll wait for the new packages to be available and will test again.

edit: I just saw that there's a warning in the readme that mentions these specific versions of PostgreSQL. Sorry.

jflambert commented 20 hours ago

Don't think you need to be sorry here @netrusov

I also saw the hotfix from postgres today and immediately upgraded even though I didn't have issues with 16.5 like you did.

If anything, timescale probably needs to warn its users not to use pg16.5 and go straight to 16.6 (although it's not their fault in the first place).

mkindahl commented 14 hours ago

I see that 16.6 and 17.2 were released today, I'll wait for the new packages to be available and will test again.

Yes, there were an unfortunate ABI change in the PostgreSQL upstreams package that affected us. You can see the entire thread to understand what happened.

It is possible for us to do some more work to avoid the risk of these kinds of changes affecting us, but this is not where we are right now.

edit: I just saw that there's a warning in the readme that mentions these specific versions of PostgreSQL. Sorry.

No need to be sorry here, it is better to raise one issue to many than one too few.

Worth adding is that because of the nature of the upstreams fix you will have problems upgrading from 17.1 to 17.2 (and similarly for the other versions), so you just skip the intermediate versions entirely.

mkindahl commented 14 hours ago

Closing this as resolved for now. Please reopen if you think there is something more that we need to deal with.