File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -23,11 +23,28 @@ CREATE OR REPLACE FUNCTION pg_temp.check_catalog_corruption() RETURNS void LANGU
2323$$
2424DECLARE
2525 v_count int8;
26+ v_rels regclass[];
2627BEGIN
28+ -- corrupt _timescaledb_catalog.chunk_column_stats entries
2729 SELECT count (* ) INTO v_count FROM _timescaledb_catalog .chunk_column_stats WHERE range_start > range_end;
2830 IF v_count >= 1 THEN
2931 RAISE WARNING ' Found %s entries in _timescaledb_catalog.chunk_column_stats with range_start > range_end' , v_count;
3032 END IF;
33+ -- orphaned chunks
34+ SELECT count (* ), array_agg(oid ::regclass) INTO v_count, v_rels
35+ FROM pg_class
36+ WHERE
37+ relnamespace= ' _timescaledb_internal' ::regnamespace AND
38+ relkind= ' r' AND
39+ relname LIKE ' %_chunk' AND
40+ NOT EXISTS(SELECT FROM _timescaledb_catalog .chunk where schema_name= ' _timescaledb_internal' and table_name = relname);
41+ IF v_count > 0 THEN
42+ IF v_count < 20 THEN
43+ RAISE WARNING ' Found % orphaned chunk relations: %' , v_count, v_rels;
44+ ELSE
45+ RAISE WARNING ' Found % orphaned chunk relations' , v_count;
46+ END IF;
47+ END IF;
3148END
3249$$ SET search_path = pg_catalog, pg_temp;
3350
@@ -206,6 +223,7 @@ CREATE OR REPLACE FUNCTION pg_temp.run_checks() RETURNS void LANGUAGE plpgsql AS
206223$$
207224BEGIN
208225 PERFORM pg_temp .check_deprecated_features ();
226+ PERFORM pg_temp .check_catalog_corruption ();
209227 PERFORM pg_temp .check_scheduler_present ();
210228 PERFORM pg_temp .check_job_failures ();
211229 PERFORM pg_temp .check_compressed_chunk_batch_sizes ();
You can’t perform that action at this time.
0 commit comments