Skip to content
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]: drop_chunk() fails when there is an FK referencing a hypertable #7181

Open
zilder opened this issue Aug 6, 2024 · 0 comments
Open
Labels

Comments

@zilder
Copy link
Contributor

zilder commented Aug 6, 2024

What type of bug is this?

Unexpected error

What subsystems and features are affected?

Other

What happened?

drop_chunk() fails when there is a regular table referencing a hypertable, see the reproduction script.

TimescaleDB version affected

2.16.0

PostgreSQL version used

15.4

What operating system did you use?

Ubuntu 22.04.2

What installation method did you use?

Source

What platform did you run on?

Not applicable

Relevant log output and stack trace

No response

How can we reproduce the bug?

CREATE TABLE metrics (id int8 PRIMARY KEY,
                      ts timestamptz, 
                      device_id integer,
                      val float);
INSERT INTO metrics VALUES (101, '2024-08-06', 1, 123);
SELECT create_hypertable('metrics', 'id', chunk_time_interval=>100, migrate_data=>true);

CREATE TABLE notes (metrics_id integer REFERENCES metrics(id) ON DELETE CASCADE, msg text);
INSERT INTO notes values (101, 'test');

-- fails here
SELECT _timescaledb_functions.drop_chunk('_timescaledb_internal._hyper_2_7_chunk');

Output:

SELECT _timescaledb_functions.drop_chunk('_timescaledb_internal._hyper_2_7_chunk');
ERROR:  cannot drop constraint 7_6_metrics_pkey on table _timescaledb_internal._hyper_2_7_chunk because other objects depend on it
DETAIL:  constraint notes_metrics_id_fkey on table notes depends on index _timescaledb_internal."7_6_metrics_pkey"
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
@zilder zilder added the bug label Aug 6, 2024
@svenklemm svenklemm removed their assignment Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants