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]: Wrong check constraint on continuous_agg_migrate_plan_step.type for instances upgrading from 2.7.2 to 2.8.0 #4727

Closed
iroussos opened this issue Sep 19, 2022 · 1 comment · Fixed by #4739

Comments

@iroussos
Copy link

What type of bug is this?

Incorrect result

What subsystems and features are affected?

Continuous aggregate

What happened?

Instances upgrading from 2.7.2 to 2.8.0 are missing the OVERRIDE CAGG and DROP OLD CAGG values for the CHECK CONSTRAINT on continuous_agg_migrate_plan_step.type:

- CONSTRAINT continuous_agg_migrate_plan_step_check2 CHECK (type IN ('CREATE NEW CAGG', 'DISABLE POLICIES', 'COPY POLICIES', 'ENABLE POLICIES', 'SAVE WATERMARK', 'REFRESH NEW CAGG', 'COPY DATA'))
+ CONSTRAINT continuous_agg_migrate_plan_step_check2 CHECK (type IN ('CREATE NEW CAGG', 'DISABLE POLICIES', 'COPY POLICIES', 'ENABLE POLICIES', 'SAVE WATERMARK', 'REFRESH NEW CAGG', 'COPY DATA', 'OVERRIDE CAGG', 'DROP OLD CAGG'))

This will happen in updated instances. New instances directly installed in 2.8 will not have this problem.

Quick reference:

Related slack discussion (internal only)

Reported by @carobme

Additionally, we should check why this was not caught in our upgrade/downgrade tests (no error raised) in our CI and fix the tests.

TimescaleDB version affected

2.8.0 (upgrade from 2.7.2 only)

PostgreSQL version used

Not applicable

What operating system did you use?

Not applicable

What installation method did you use?

Not applicable

What platform did you run on?

Managed Service for TimescaleDB (MST/Aiven)

Relevant log output and stack trace

defaultdb=> CALL cagg_migrate('sensor_summary_hourly');
ERROR:  23514: new row for relation "continuous_agg_migrate_plan_step" violates check constraint "continuous_agg_migrate_plan_step_check2"
DETAIL:  Failing row contains (2, 20, NOT STARTED, null, null, OVERRIDE CAGG, {"drop_old": false, "override": false, "cagg_name_new": "sensor_...).
CONTEXT:  SQL statement "INSERT INTO
        _timescaledb_catalog.continuous_agg_migrate_plan_step (mat_hypertable_id, type, config)
    VALUES
        (_cagg_data.mat_hypertable_id, 'OVERRIDE CAGG', jsonb_build_object('cagg_name_new', _cagg_name_new, 'override', _override, 'drop_old', _drop_old)),
        (_cagg_data.mat_hypertable_id, 'DROP OLD CAGG', jsonb_build_object('cagg_name_new', _cagg_name_new, 'override', _override, 'drop_old', _drop_old)),
        (_cagg_data.mat_hypertable_id, 'COPY POLICIES', _policies || jsonb_build_object('cagg_name_new', _cagg_name_new)),
        (_cagg_data.mat_hypertable_id, 'ENABLE POLICIES', NULL)"
PL/pgSQL function _timescaledb_internal.cagg_migrate_create_plan(_timescaledb_catalog.continuous_agg,text,boolean,boolean) line 101 at SQL statement
SQL statement "CALL _timescaledb_internal.cagg_migrate_create_plan(_cagg_data, _cagg_name_new, _override, _drop_old)"
PL/pgSQL function cagg_migrate(regclass,boolean,boolean) line 21 at CALL

How can we reproduce the bug?

defaultdb=> CALL cagg_migrate('any existing cagg after upgrade to 2.8.0');
@iroussos
Copy link
Author

@fabriziomello I created a bug report for the issue discussed on Slack.

/cc @horzsolt

fabriziomello added a commit to fabriziomello/timescaledb that referenced this issue Sep 21, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix timescale#4727
fabriziomello added a commit to fabriziomello/timescaledb that referenced this issue Sep 21, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix timescale#4727
fabriziomello added a commit to fabriziomello/timescaledb that referenced this issue Sep 22, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix timescale#4727
fabriziomello added a commit to fabriziomello/timescaledb that referenced this issue Sep 22, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix timescale#4727
fabriziomello added a commit that referenced this issue Sep 22, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix #4727
jnidzwetzki pushed a commit to jnidzwetzki/timescaledb that referenced this issue Sep 29, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix timescale#4727
jnidzwetzki pushed a commit to jnidzwetzki/timescaledb that referenced this issue Sep 30, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix timescale#4727
jnidzwetzki pushed a commit to jnidzwetzki/timescaledb that referenced this issue Sep 30, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix timescale#4727
jnidzwetzki pushed a commit to jnidzwetzki/timescaledb that referenced this issue Sep 30, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix timescale#4727
jnidzwetzki pushed a commit to jnidzwetzki/timescaledb that referenced this issue Oct 4, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix timescale#4727
jnidzwetzki pushed a commit that referenced this issue Oct 6, 2022
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix #4727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants