-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch stores the current catalog version in an internal table to allow us to verify catalog and code version match. When doing dump/restore people occasionally report very unusual errors and during investigation it is discovered that they loaded a dump from an older version and run it with a later code version. This allows to detect mismatches between installed code version and loaded dump version. The version number in the metadata table will be kept updated in upgrade and downgrade scripts.
- Loading branch information
Showing
8 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Implements: #6185 Keep track of catalog version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,17 @@ CREATE OR REPLACE FUNCTION @[email protected]_post_restore() RETURNS BOOL A | |
$BODY$ | ||
DECLARE | ||
db text; | ||
catalog_version text; | ||
BEGIN | ||
SELECT m.value INTO catalog_version FROM pg_extension x | ||
JOIN _timescaledb_catalog.metadata m ON m.key='timescaledb_version' | ||
WHERE x.extname='timescaledb' AND x.extversion <> m.value; | ||
|
||
-- check that a loaded dump is compatible with the currently running code | ||
IF FOUND THEN | ||
RAISE EXCEPTION 'catalog version mismatch, expected "%" seen "%"', '@PROJECT_VERSION_MOD@', catalog_version; | ||
END IF; | ||
|
||
SELECT current_database() INTO db; | ||
EXECUTE format($$ALTER DATABASE %I RESET timescaledb.restoring $$, db); | ||
-- we cannot use reset here because the reset_val might not be off | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- This file and its contents are licensed under the Apache License 2.0. | ||
-- Please see the included NOTICE for copyright information and | ||
-- LICENSE-APACHE for a copy of the license. | ||
|
||
DO $$ | ||
DECLARE | ||
catalog_version TEXT; | ||
BEGIN | ||
SELECT value INTO catalog_version FROM _timescaledb_catalog.metadata WHERE key='timescaledb_version' AND value <> '@START_VERSION@'; | ||
IF FOUND THEN | ||
RAISE EXCEPTION 'catalog version mismatch, expected "%" seen "%"', '@START_VERSION@', catalog_version; | ||
END IF; | ||
END$$; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters