From 12f262c050ce54dc23e3334b07330c2f98db1aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADzio=20de=20Royes=20Mello?= Date: Fri, 13 Dec 2024 19:27:09 -0300 Subject: [PATCH] Fix flaky reorder regression test take 2 In #7509 we added manual VACUUM in all involved relations to avoid flaky output tests. But looks like it is not working very well specially on Windows builds, so now we're removing the output `found 0 removable, 0 nonremovable row versions in 0 pages` to have a more predictable output test. https://github.com/timescale/timescaledb/actions/runs/12322325859/job/34395659212?pr=7533#step:17:24 --- test/expected/cluster-15.out | 168 ------------------ test/expected/cluster-16.out | 168 ------------------ test/expected/cluster-17.out | 168 ------------------ test/expected/{cluster-14.out => cluster.out} | 16 -- test/runner_cleanup_output.sh | 3 +- test/sql/CMakeLists.txt | 2 +- test/sql/{cluster.sql.in => cluster.sql} | 0 tsl/test/expected/move.out | 10 +- tsl/test/expected/reorder.out | 9 - tsl/test/sql/move.sql | 2 +- 10 files changed, 8 insertions(+), 538 deletions(-) delete mode 100644 test/expected/cluster-15.out delete mode 100644 test/expected/cluster-16.out delete mode 100644 test/expected/cluster-17.out rename test/expected/{cluster-14.out => cluster.out} (84%) rename test/sql/{cluster.sql.in => cluster.sql} (100%) diff --git a/test/expected/cluster-15.out b/test/expected/cluster-15.out deleted file mode 100644 index 9c1305ffc55..00000000000 --- a/test/expected/cluster-15.out +++ /dev/null @@ -1,168 +0,0 @@ --- 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. -CREATE TABLE cluster_test(time timestamptz, temp float, location int); -SELECT create_hypertable('cluster_test', 'time', chunk_time_interval => interval '1 day'); -NOTICE: adding not-null constraint to column "time" - create_hypertable ---------------------------- - (1,public,cluster_test,t) -(1 row) - --- Show default indexes -SELECT * FROM test.show_indexes('cluster_test'); - Index | Columns | Expr | Unique | Primary | Exclusion | Tablespace ------------------------+---------+------+--------+---------+-----------+------------ - cluster_test_time_idx | {time} | | f | f | f | -(1 row) - --- Create two chunks -INSERT INTO cluster_test VALUES ('2017-01-20T09:00:01', 23.4, 1), - ('2017-01-21T09:00:01', 21.3, 2); --- Run cluster -CLUSTER VERBOSE cluster_test USING cluster_test_time_idx; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using index scan on "_hyper_1_1_chunk_cluster_test_time_idx" -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using index scan on "_hyper_1_2_chunk_cluster_test_time_idx" -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Create a third chunk -INSERT INTO cluster_test VALUES ('2017-01-22T09:00:01', 19.5, 3); --- Show clustered indexes -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true ORDER BY 1; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - cluster_test_time_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx | t -(3 rows) - --- Reorder just our table -CLUSTER VERBOSE cluster_test; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using index scan on "_hyper_1_3_chunk_cluster_test_time_idx" -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Show clustered indexes, including new chunk -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true ORDER BY 1; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - cluster_test_time_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_3_chunk_cluster_test_time_idx | t -(4 rows) - --- Reorder all tables (although will only be our test table) -CLUSTER VERBOSE; -INFO: clustering "public.cluster_test" using sequential scan and sort -INFO: "public.cluster_test": found 0 removable, 0 nonremovable row versions in 0 pages -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Change the clustered index -CREATE INDEX ON cluster_test (time, location); -CLUSTER VERBOSE cluster_test using cluster_test_time_location_idx; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Show updated clustered indexes -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true ORDER BY 1; - indexrelid | indisclustered ------------------------------------------------------------------------+---------------- - cluster_test_time_location_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_location_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_location_idx | t - _timescaledb_internal._hyper_1_3_chunk_cluster_test_time_location_idx | t -(4 rows) - ---check the setting of cluster indexes on hypertables and chunks -ALTER TABLE cluster_test CLUSTER ON cluster_test_time_idx; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - cluster_test_time_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_3_chunk_cluster_test_time_idx | t -(4 rows) - -CLUSTER VERBOSE cluster_test; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -ALTER TABLE cluster_test SET WITHOUT CLUSTER; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered -------------+---------------- -(0 rows) - -\set ON_ERROR_STOP 0 -CLUSTER VERBOSE cluster_test; -ERROR: there is no previously clustered index for table "cluster_test" -\set ON_ERROR_STOP 1 -ALTER TABLE _timescaledb_internal._hyper_1_1_chunk CLUSTER ON _hyper_1_1_chunk_cluster_test_time_idx; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t -(1 row) - -CLUSTER VERBOSE _timescaledb_internal._hyper_1_1_chunk; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -ALTER TABLE _timescaledb_internal._hyper_1_1_chunk SET WITHOUT CLUSTER; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered -------------+---------------- -(0 rows) - -\set ON_ERROR_STOP 0 -CLUSTER VERBOSE _timescaledb_internal._hyper_1_1_chunk; -ERROR: there is no previously clustered index for table "_hyper_1_1_chunk" -\set ON_ERROR_STOP 1 --- test alter column type on hypertable with clustering -CREATE TABLE cluster_alter(time timestamp, id text, val int); -CREATE INDEX idstuff ON cluster_alter USING btree (id ASC NULLS LAST, time); -SELECT table_name FROM create_hypertable('cluster_alter', 'time'); -WARNING: column type "timestamp without time zone" used for "time" does not follow best practices -NOTICE: adding not-null constraint to column "time" - table_name ---------------- - cluster_alter -(1 row) - -INSERT INTO cluster_alter VALUES('2020-01-01', '123', 1); -CLUSTER cluster_alter using idstuff; ---attempt the alter table -ALTER TABLE cluster_alter ALTER COLUMN id TYPE int USING id::int; -CLUSTER cluster_alter; -CLUSTER cluster_alter using idstuff; diff --git a/test/expected/cluster-16.out b/test/expected/cluster-16.out deleted file mode 100644 index 9c1305ffc55..00000000000 --- a/test/expected/cluster-16.out +++ /dev/null @@ -1,168 +0,0 @@ --- 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. -CREATE TABLE cluster_test(time timestamptz, temp float, location int); -SELECT create_hypertable('cluster_test', 'time', chunk_time_interval => interval '1 day'); -NOTICE: adding not-null constraint to column "time" - create_hypertable ---------------------------- - (1,public,cluster_test,t) -(1 row) - --- Show default indexes -SELECT * FROM test.show_indexes('cluster_test'); - Index | Columns | Expr | Unique | Primary | Exclusion | Tablespace ------------------------+---------+------+--------+---------+-----------+------------ - cluster_test_time_idx | {time} | | f | f | f | -(1 row) - --- Create two chunks -INSERT INTO cluster_test VALUES ('2017-01-20T09:00:01', 23.4, 1), - ('2017-01-21T09:00:01', 21.3, 2); --- Run cluster -CLUSTER VERBOSE cluster_test USING cluster_test_time_idx; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using index scan on "_hyper_1_1_chunk_cluster_test_time_idx" -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using index scan on "_hyper_1_2_chunk_cluster_test_time_idx" -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Create a third chunk -INSERT INTO cluster_test VALUES ('2017-01-22T09:00:01', 19.5, 3); --- Show clustered indexes -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true ORDER BY 1; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - cluster_test_time_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx | t -(3 rows) - --- Reorder just our table -CLUSTER VERBOSE cluster_test; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using index scan on "_hyper_1_3_chunk_cluster_test_time_idx" -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Show clustered indexes, including new chunk -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true ORDER BY 1; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - cluster_test_time_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_3_chunk_cluster_test_time_idx | t -(4 rows) - --- Reorder all tables (although will only be our test table) -CLUSTER VERBOSE; -INFO: clustering "public.cluster_test" using sequential scan and sort -INFO: "public.cluster_test": found 0 removable, 0 nonremovable row versions in 0 pages -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Change the clustered index -CREATE INDEX ON cluster_test (time, location); -CLUSTER VERBOSE cluster_test using cluster_test_time_location_idx; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Show updated clustered indexes -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true ORDER BY 1; - indexrelid | indisclustered ------------------------------------------------------------------------+---------------- - cluster_test_time_location_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_location_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_location_idx | t - _timescaledb_internal._hyper_1_3_chunk_cluster_test_time_location_idx | t -(4 rows) - ---check the setting of cluster indexes on hypertables and chunks -ALTER TABLE cluster_test CLUSTER ON cluster_test_time_idx; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - cluster_test_time_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_3_chunk_cluster_test_time_idx | t -(4 rows) - -CLUSTER VERBOSE cluster_test; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -ALTER TABLE cluster_test SET WITHOUT CLUSTER; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered -------------+---------------- -(0 rows) - -\set ON_ERROR_STOP 0 -CLUSTER VERBOSE cluster_test; -ERROR: there is no previously clustered index for table "cluster_test" -\set ON_ERROR_STOP 1 -ALTER TABLE _timescaledb_internal._hyper_1_1_chunk CLUSTER ON _hyper_1_1_chunk_cluster_test_time_idx; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t -(1 row) - -CLUSTER VERBOSE _timescaledb_internal._hyper_1_1_chunk; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -ALTER TABLE _timescaledb_internal._hyper_1_1_chunk SET WITHOUT CLUSTER; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered -------------+---------------- -(0 rows) - -\set ON_ERROR_STOP 0 -CLUSTER VERBOSE _timescaledb_internal._hyper_1_1_chunk; -ERROR: there is no previously clustered index for table "_hyper_1_1_chunk" -\set ON_ERROR_STOP 1 --- test alter column type on hypertable with clustering -CREATE TABLE cluster_alter(time timestamp, id text, val int); -CREATE INDEX idstuff ON cluster_alter USING btree (id ASC NULLS LAST, time); -SELECT table_name FROM create_hypertable('cluster_alter', 'time'); -WARNING: column type "timestamp without time zone" used for "time" does not follow best practices -NOTICE: adding not-null constraint to column "time" - table_name ---------------- - cluster_alter -(1 row) - -INSERT INTO cluster_alter VALUES('2020-01-01', '123', 1); -CLUSTER cluster_alter using idstuff; ---attempt the alter table -ALTER TABLE cluster_alter ALTER COLUMN id TYPE int USING id::int; -CLUSTER cluster_alter; -CLUSTER cluster_alter using idstuff; diff --git a/test/expected/cluster-17.out b/test/expected/cluster-17.out deleted file mode 100644 index 9c1305ffc55..00000000000 --- a/test/expected/cluster-17.out +++ /dev/null @@ -1,168 +0,0 @@ --- 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. -CREATE TABLE cluster_test(time timestamptz, temp float, location int); -SELECT create_hypertable('cluster_test', 'time', chunk_time_interval => interval '1 day'); -NOTICE: adding not-null constraint to column "time" - create_hypertable ---------------------------- - (1,public,cluster_test,t) -(1 row) - --- Show default indexes -SELECT * FROM test.show_indexes('cluster_test'); - Index | Columns | Expr | Unique | Primary | Exclusion | Tablespace ------------------------+---------+------+--------+---------+-----------+------------ - cluster_test_time_idx | {time} | | f | f | f | -(1 row) - --- Create two chunks -INSERT INTO cluster_test VALUES ('2017-01-20T09:00:01', 23.4, 1), - ('2017-01-21T09:00:01', 21.3, 2); --- Run cluster -CLUSTER VERBOSE cluster_test USING cluster_test_time_idx; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using index scan on "_hyper_1_1_chunk_cluster_test_time_idx" -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using index scan on "_hyper_1_2_chunk_cluster_test_time_idx" -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Create a third chunk -INSERT INTO cluster_test VALUES ('2017-01-22T09:00:01', 19.5, 3); --- Show clustered indexes -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true ORDER BY 1; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - cluster_test_time_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx | t -(3 rows) - --- Reorder just our table -CLUSTER VERBOSE cluster_test; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using index scan on "_hyper_1_3_chunk_cluster_test_time_idx" -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Show clustered indexes, including new chunk -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true ORDER BY 1; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - cluster_test_time_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_3_chunk_cluster_test_time_idx | t -(4 rows) - --- Reorder all tables (although will only be our test table) -CLUSTER VERBOSE; -INFO: clustering "public.cluster_test" using sequential scan and sort -INFO: "public.cluster_test": found 0 removable, 0 nonremovable row versions in 0 pages -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Change the clustered index -CREATE INDEX ON cluster_test (time, location); -CLUSTER VERBOSE cluster_test using cluster_test_time_location_idx; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages --- Show updated clustered indexes -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true ORDER BY 1; - indexrelid | indisclustered ------------------------------------------------------------------------+---------------- - cluster_test_time_location_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_location_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_location_idx | t - _timescaledb_internal._hyper_1_3_chunk_cluster_test_time_location_idx | t -(4 rows) - ---check the setting of cluster indexes on hypertables and chunks -ALTER TABLE cluster_test CLUSTER ON cluster_test_time_idx; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - cluster_test_time_idx | t - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx | t - _timescaledb_internal._hyper_1_3_chunk_cluster_test_time_idx | t -(4 rows) - -CLUSTER VERBOSE cluster_test; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -ALTER TABLE cluster_test SET WITHOUT CLUSTER; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered -------------+---------------- -(0 rows) - -\set ON_ERROR_STOP 0 -CLUSTER VERBOSE cluster_test; -ERROR: there is no previously clustered index for table "cluster_test" -\set ON_ERROR_STOP 1 -ALTER TABLE _timescaledb_internal._hyper_1_1_chunk CLUSTER ON _hyper_1_1_chunk_cluster_test_time_idx; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered ---------------------------------------------------------------+---------------- - _timescaledb_internal._hyper_1_1_chunk_cluster_test_time_idx | t -(1 row) - -CLUSTER VERBOSE _timescaledb_internal._hyper_1_1_chunk; -INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_timescaledb_internal._hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -ALTER TABLE _timescaledb_internal._hyper_1_1_chunk SET WITHOUT CLUSTER; -SELECT indexrelid::regclass, indisclustered -FROM pg_index -WHERE indisclustered = true -ORDER BY 1,2; - indexrelid | indisclustered -------------+---------------- -(0 rows) - -\set ON_ERROR_STOP 0 -CLUSTER VERBOSE _timescaledb_internal._hyper_1_1_chunk; -ERROR: there is no previously clustered index for table "_hyper_1_1_chunk" -\set ON_ERROR_STOP 1 --- test alter column type on hypertable with clustering -CREATE TABLE cluster_alter(time timestamp, id text, val int); -CREATE INDEX idstuff ON cluster_alter USING btree (id ASC NULLS LAST, time); -SELECT table_name FROM create_hypertable('cluster_alter', 'time'); -WARNING: column type "timestamp without time zone" used for "time" does not follow best practices -NOTICE: adding not-null constraint to column "time" - table_name ---------------- - cluster_alter -(1 row) - -INSERT INTO cluster_alter VALUES('2020-01-01', '123', 1); -CLUSTER cluster_alter using idstuff; ---attempt the alter table -ALTER TABLE cluster_alter ALTER COLUMN id TYPE int USING id::int; -CLUSTER cluster_alter; -CLUSTER cluster_alter using idstuff; diff --git a/test/expected/cluster-14.out b/test/expected/cluster.out similarity index 84% rename from test/expected/cluster-14.out rename to test/expected/cluster.out index 8a9b3524396..f0cd3392f89 100644 --- a/test/expected/cluster-14.out +++ b/test/expected/cluster.out @@ -22,9 +22,7 @@ INSERT INTO cluster_test VALUES ('2017-01-20T09:00:01', 23.4, 1), -- Run cluster CLUSTER VERBOSE cluster_test USING cluster_test_time_idx; INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using index scan on "_hyper_1_1_chunk_cluster_test_time_idx" -INFO: "_hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using index scan on "_hyper_1_2_chunk_cluster_test_time_idx" -INFO: "_hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -- Create a third chunk INSERT INTO cluster_test VALUES ('2017-01-22T09:00:01', 19.5, 3); -- Show clustered indexes @@ -41,11 +39,8 @@ WHERE indisclustered = true ORDER BY 1; -- Reorder just our table CLUSTER VERBOSE cluster_test; INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using index scan on "_hyper_1_3_chunk_cluster_test_time_idx" -INFO: "_hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -- Show clustered indexes, including new chunk SELECT indexrelid::regclass, indisclustered FROM pg_index @@ -61,22 +56,15 @@ WHERE indisclustered = true ORDER BY 1; -- Reorder all tables (although will only be our test table) CLUSTER VERBOSE; INFO: clustering "public.cluster_test" using sequential scan and sort -INFO: "cluster_test": found 0 removable, 0 nonremovable row versions in 0 pages INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -- Change the clustered index CREATE INDEX ON cluster_test (time, location); CLUSTER VERBOSE cluster_test using cluster_test_time_location_idx; INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages -- Show updated clustered indexes SELECT indexrelid::regclass, indisclustered FROM pg_index @@ -105,11 +93,8 @@ ORDER BY 1,2; CLUSTER VERBOSE cluster_test; INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages INFO: clustering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 1 nonremovable row versions in 1 pages INFO: clustering "_timescaledb_internal._hyper_1_3_chunk" using sequential scan and sort -INFO: "_hyper_1_3_chunk": found 0 removable, 1 nonremovable row versions in 1 pages ALTER TABLE cluster_test SET WITHOUT CLUSTER; SELECT indexrelid::regclass, indisclustered FROM pg_index @@ -135,7 +120,6 @@ ORDER BY 1,2; CLUSTER VERBOSE _timescaledb_internal._hyper_1_1_chunk; INFO: clustering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_hyper_1_1_chunk": found 0 removable, 1 nonremovable row versions in 1 pages ALTER TABLE _timescaledb_internal._hyper_1_1_chunk SET WITHOUT CLUSTER; SELECT indexrelid::regclass, indisclustered FROM pg_index diff --git a/test/runner_cleanup_output.sh b/test/runner_cleanup_output.sh index 21fdb29a2a0..0c76ff9efdd 100755 --- a/test/runner_cleanup_output.sh +++ b/test/runner_cleanup_output.sh @@ -9,7 +9,8 @@ sed -e '//,/<\/exclude_from_test>/d' \ -e 's! Memory: [0-9]\{1,\}kB!!' \ -e 's! Memory Usage: [0-9]\{1,\}kB!!' \ -e 's! Average Peak Memory: [0-9]\{1,\}kB!!' \ - -e '/Heap Fetches: [0-9]\{1,\}/d' | \ + -e '/Heap Fetches: [0-9]\{1,\}/d' \ + -e '/found [0-9]\{1,\} removable, [0-9]\{1,\} nonremovable row versions in [0-9]\{1,\} pages/d' | \ grep -v 'DEBUG: rehashing catalog cache id' | \ grep -v 'DEBUG: compacted fsync request queue from' | \ grep -v 'DEBUG: creating and filling new WAL file' | \ diff --git a/test/sql/CMakeLists.txt b/test/sql/CMakeLists.txt index 5ed75b5307f..5cf9eae00a2 100644 --- a/test/sql/CMakeLists.txt +++ b/test/sql/CMakeLists.txt @@ -8,6 +8,7 @@ set(TEST_FILES chunks.sql chunk_adaptive.sql chunk_utils.sql + cluster.sql create_chunks.sql create_hypertable.sql create_table.sql @@ -61,7 +62,6 @@ set(TEST_FILES set(TEST_TEMPLATES agg_bookends.sql.in append.sql.in - cluster.sql.in drop_owned.sql.in grant_hypertable.sql.in histogram_test.sql.in diff --git a/test/sql/cluster.sql.in b/test/sql/cluster.sql similarity index 100% rename from test/sql/cluster.sql.in rename to test/sql/cluster.sql diff --git a/tsl/test/expected/move.out b/tsl/test/expected/move.out index 50e5eea690c..2ac1408a777 100644 --- a/tsl/test/expected/move.out +++ b/tsl/test/expected/move.out @@ -253,9 +253,10 @@ GRANT CREATE ON TABLESPACE tablespace2 TO :ROLE_DEFAULT_PERM_USER; RESET client_min_messages; \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER -- move with chunk index for reorder -SELECT true INTO move_chunk_result FROM move_chunk(chunk=>'_timescaledb_internal._hyper_1_2_chunk', destination_tablespace=>'tablespace1', index_destination_tablespace=>'tablespace1', reorder_index=>'_timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx', verbose=>TRUE); -INFO: reordering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 5 nonremovable row versions in 1 pages +SELECT FROM move_chunk(chunk=>'_timescaledb_internal._hyper_1_2_chunk', destination_tablespace=>'tablespace1', index_destination_tablespace=>'tablespace1', reorder_index=>'_timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx'); +-- +(1 row) + SELECT * FROM test.show_subtables('cluster_test'); Child | Tablespace ----------------------------------------+------------- @@ -383,7 +384,6 @@ FROM _timescaledb_internal._hyper_1_2_chunk ORDER BY ctid; -- move back to pg_default SELECT move_chunk(chunk=>'_timescaledb_internal._hyper_1_2_chunk', destination_tablespace=>'pg_default', index_destination_tablespace=>'pg_default', reorder_index=>'_timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx', verbose=>TRUE); INFO: reordering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 5 nonremovable row versions in 1 pages move_chunk ------------ @@ -408,7 +408,6 @@ SELECT * FROM test.show_indexesp('_timescaledb_internal._hyper%_chunk'); -- move chunk and indexes to different tablespaces SELECT move_chunk(chunk=>'_timescaledb_internal._hyper_1_2_chunk', destination_tablespace=>'tablespace1', index_destination_tablespace=>'tablespace2', reorder_index=>'_timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx', verbose=>TRUE); INFO: reordering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 5 nonremovable row versions in 1 pages move_chunk ------------ @@ -433,7 +432,6 @@ SELECT * FROM test.show_indexesp('_timescaledb_internal._hyper%_chunk'); -- keep chunk in same space and move index tablespace SELECT move_chunk(chunk=>'_timescaledb_internal._hyper_1_2_chunk', destination_tablespace=>'pg_default', index_destination_tablespace=>'tablespace2', reorder_index=>'_timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx', verbose=>TRUE); INFO: reordering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 5 nonremovable row versions in 1 pages move_chunk ------------ diff --git a/tsl/test/expected/reorder.out b/tsl/test/expected/reorder.out index 6b7257125ad..4e36f623e17 100644 --- a/tsl/test/expected/reorder.out +++ b/tsl/test/expected/reorder.out @@ -289,7 +289,6 @@ COMMIT; -- reorder a chunk directly with an chunk index SELECT reorder_chunk('_timescaledb_internal._hyper_1_2_chunk', '_timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx', TRUE); INFO: reordering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 5 nonremovable row versions in 1 pages reorder_chunk --------------- @@ -380,7 +379,6 @@ COMMIT; -- reorder a chunk without an index SELECT reorder_chunk('_timescaledb_internal._hyper_1_2_chunk', verbose => TRUE); INFO: reordering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 5 nonremovable row versions in 1 pages reorder_chunk --------------- @@ -471,7 +469,6 @@ COMMIT; -- reorder a chunk directly with a hypertable index SELECT reorder_chunk('_timescaledb_internal._hyper_1_2_chunk', 'cluster_test_time_idx', TRUE); INFO: reordering "_timescaledb_internal._hyper_1_2_chunk" using sequential scan and sort -INFO: "_hyper_1_2_chunk": found 0 removable, 5 nonremovable row versions in 1 pages reorder_chunk --------------- @@ -686,7 +683,6 @@ FROM _timescaledb_internal._hyper_1_2_chunk ORDER BY ctid; -- can perform first reorder using a hypertable index (also test non-toast) SELECT reorder_chunk('_timescaledb_internal._hyper_1_1_chunk', 'cluster_test_time_idx', verbose => TRUE); INFO: reordering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_hyper_1_1_chunk": found 0 removable, 5 nonremovable row versions in 1 pages reorder_chunk --------------- @@ -777,7 +773,6 @@ COMMIT; -- and this sets the clustered index correctly SELECT reorder_chunk('_timescaledb_internal._hyper_1_1_chunk', verbose => TRUE); INFO: reordering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_hyper_1_1_chunk": found 0 removable, 5 nonremovable row versions in 1 pages reorder_chunk --------------- @@ -1000,7 +995,6 @@ SELECT * FROM ensure_scans_work_no_val('cluster_test', should_output => 'expecte COMMIT; SELECT reorder_chunk('_timescaledb_internal._hyper_1_1_chunk', verbose => TRUE); INFO: reordering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_hyper_1_1_chunk": found 0 removable, 5 nonremovable row versions in 1 pages reorder_chunk --------------- @@ -1111,7 +1105,6 @@ SET enable_indexscan=true; SET enable_bitmapscan=false; SELECT reorder_chunk('_timescaledb_internal._hyper_1_1_chunk', verbose => TRUE); INFO: reordering "_timescaledb_internal._hyper_1_1_chunk" using sequential scan and sort -INFO: "_hyper_1_1_chunk": found 0 removable, 5 nonremovable row versions in 1 pages reorder_chunk --------------- @@ -1256,7 +1249,6 @@ ERROR: "_hyper_1_2_chunk_cluster_test_time_idx" is not a valid clustering index CLUSTER ct2 USING ct2_time_idx; SELECT reorder_chunk('_timescaledb_internal._hyper_2_3_chunk', verbose => TRUE); INFO: reordering "_timescaledb_internal._hyper_2_3_chunk" using sequential scan and sort -INFO: "_hyper_2_3_chunk": found 0 removable, 5 nonremovable row versions in 1 pages reorder_chunk --------------- @@ -1276,7 +1268,6 @@ DELETE FROM ct2 where time < 2 OR val < 2; VACUUM ct2; SELECT reorder_chunk('_timescaledb_internal._hyper_2_3_chunk', verbose => TRUE); INFO: reordering "_timescaledb_internal._hyper_2_3_chunk" using sequential scan and sort -INFO: "_hyper_2_3_chunk": found 0 removable, 3 nonremovable row versions in 1 pages reorder_chunk --------------- diff --git a/tsl/test/sql/move.sql b/tsl/test/sql/move.sql index 7db1da595ee..7f16e23bdd9 100644 --- a/tsl/test/sql/move.sql +++ b/tsl/test/sql/move.sql @@ -66,7 +66,7 @@ RESET client_min_messages; \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER -- move with chunk index for reorder -SELECT true INTO move_chunk_result FROM move_chunk(chunk=>'_timescaledb_internal._hyper_1_2_chunk', destination_tablespace=>'tablespace1', index_destination_tablespace=>'tablespace1', reorder_index=>'_timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx', verbose=>TRUE); +SELECT FROM move_chunk(chunk=>'_timescaledb_internal._hyper_1_2_chunk', destination_tablespace=>'tablespace1', index_destination_tablespace=>'tablespace1', reorder_index=>'_timescaledb_internal._hyper_1_2_chunk_cluster_test_time_idx'); SELECT * FROM test.show_subtables('cluster_test'); SELECT * FROM test.show_indexesp('_timescaledb_internal._hyper%_chunk'); BEGIN;