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

PG16: Prohibit use of multi-node #6190

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .github/workflows/linux-32bit-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ jobs:
CXX: clang++-14
DEBIAN_FRONTEND: noninteractive
IGNORES: "append-* debug_notice transparent_decompression-*
transparent_decompress_chunk-* pg_dump
transparent_decompress_chunk-* pg_dump partialize_finalize
dist_move_chunk dist_param dist_insert remote_txn telemetry"
SKIPS: chunk_adaptive histogram_test
SKIPS: chunk_adaptive histogram_test-*
strategy:
fail-fast: false
matrix:
pg: ${{ fromJson(needs.config.outputs.pg_latest) }}
build_type: [ Debug ]
include:
- pg: ${{ fromJson(needs.config.outputs.pg15_latest) }}
ignores_version: partialize_finalize

steps:

Expand Down Expand Up @@ -135,8 +132,8 @@ jobs:
set -o pipefail
export LANG=C.UTF-8
# PostgreSQL cannot be run as root. So, switch to postgres user.
sudo -u postgres make -k -C build installcheck IGNORES="${IGNORES} \
${{ matrix.ignores_version }}" SKIPS="${SKIPS}" | tee installcheck.log
sudo -u postgres make -k -C build installcheck IGNORES="${IGNORES}" \
SKIPS="${SKIPS}" | tee installcheck.log

- name: Show regression diffs
if: always()
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/windows-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
os: [ windows-2022 ]
build_type: ${{ fromJson(needs.config.outputs.build_type) }}
ignores: ["chunk_adaptive metadata telemetry"]
tsl_ignores: ["compression_algos remote_connection telemetry_stats-13 telemetry_stats-14 dist_move_chunk dist_param dist_insert dist_backup dist_cagg"]
tsl_ignores: ["compression_algos remote_connection telemetry_stats dist_move_chunk dist_param dist_insert dist_backup dist_cagg partialize_finalize"]
tsl_skips: ["bgw_db_scheduler bgw_db_scheduler_fixed cagg_ddl_dist_ht
data_fetcher dist_compression dist_remote_error remote_txn"]
pg_config: ["-cfsync=off -cstatement_timeout=60s"]
Expand All @@ -72,7 +72,6 @@ jobs:
# pkg_version: ${{ fromJson(needs.config.outputs.pg15_latest) }}
pkg_version: 15.0.1 # hardcoded due to issues with PG15.1 on chocolatey
tsl_skips_version: dist_partial_agg-15 dist_grant-15
tsl_ignores_version: partialize_finalize
env:
# PostgreSQL configuration
PGPORT: 55432
Expand Down
32 changes: 32 additions & 0 deletions sql/updates/pre-update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,35 @@ WHERE
)
;

-- ERROR if trying to update the extension on PG16 using Multi-Node
DO $$
DECLARE
data_nodes TEXT;
dist_hypertables TEXT;
BEGIN
IF current_setting('server_version_num')::int >= 160000 THEN
SELECT string_agg(format('%I.%I', hypertable_schema, hypertable_name), ', ')
INTO dist_hypertables
FROM timescaledb_information.hypertables
WHERE is_distributed IS TRUE;

IF dist_hypertables IS NOT NULL THEN
RAISE USING
ERRCODE = 'feature_not_supported',
MESSAGE = 'cannot upgrade because multi-node is not supported on PostgreSQL >= 16',
DETAIL = 'The following distributed hypertables should be migrated to regular: '||dist_hypertables;
END IF;

SELECT string_agg(format('%I', node_name), ', ')
INTO data_nodes
FROM timescaledb_information.data_nodes;

IF data_nodes IS NOT NULL THEN
RAISE USING
ERRCODE = 'feature_not_supported',
MESSAGE = 'cannot upgrade because multi-node is not supported on PostgreSQL >= 16',
DETAIL = 'The following data nodes should be removed: '||data_nodes;
END IF;
END IF;
END $$;

12 changes: 12 additions & 0 deletions src/hypertable.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include "debug_assert.h"
#include "osm_callbacks.h"
#include "error_utils.h"
#include "compat/compat.h"

Oid
ts_rel_get_owner(Oid relid)
Expand Down Expand Up @@ -2046,6 +2047,17 @@ ts_hypertable_create(PG_FUNCTION_ARGS)
Datum
ts_hypertable_distributed_create(PG_FUNCTION_ARGS)
{
#if PG16_GE
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("distributed hypertable is not supported"),
errdetail("Multi-node is not supported anymore on PostgreSQL >= 16.")));
#else
ereport(WARNING,
(errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
errmsg("distributed hypertable is deprecated"),
errdetail("Multi-node is deprecated and will be removed in future releases.")));
#endif
return ts_hypertable_create_time_prev(fcinfo, true);
}

Expand Down
4 changes: 2 additions & 2 deletions test/expected/cluster-16.out
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ 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: "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 "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_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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ INSERT INTO weather VALUES
('2023-02-10 08:58:59.999999+00','city1',10.3),
('2023-03-23 06:12:02.73765+00 ','city1', 9.7),
('2023-03-23 06:12:06.990998+00','city1',11.7);
-- This will currently generate an error.
-- This will currently generate an error on PG15 and prior versions
\set ON_ERROR_STOP 0
SELECT histogram(temperature, -1.79769e+308, 1.79769e+308,10) FROM weather GROUP BY city;
ERROR: index -2147483648 from "width_bucket" out of range
Expand Down
127 changes: 127 additions & 0 deletions test/expected/histogram_test-14.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
-- 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.
-- table 1
CREATE TABLE "hitest1"(key real, val varchar(40));
-- insertions
INSERT INTO "hitest1" VALUES(0, 'hi');
INSERT INTO "hitest1" VALUES(1, 'sup');
INSERT INTO "hitest1" VALUES(2, 'hello');
INSERT INTO "hitest1" VALUES(3, 'yo');
INSERT INTO "hitest1" VALUES(4, 'howdy');
INSERT INTO "hitest1" VALUES(5, 'hola');
INSERT INTO "hitest1" VALUES(6, 'ya');
INSERT INTO "hitest1" VALUES(1, 'sup');
INSERT INTO "hitest1" VALUES(2, 'hello');
INSERT INTO "hitest1" VALUES(1, 'sup');
-- table 2
CREATE TABLE "hitest2"(name varchar(30), score integer, qualify boolean);
-- insertions
INSERT INTO "hitest2" VALUES('Tom', 6, TRUE);
INSERT INTO "hitest2" VALUES('Mary', 4, FALSE);
INSERT INTO "hitest2" VALUES('Jaq', 3, FALSE);
INSERT INTO "hitest2" VALUES('Jane', 10, TRUE);
-- standard 2 bucket
SELECT histogram(key, 0, 9, 2) FROM hitest1;
histogram
-----------
{0,8,2,0}
(1 row)

-- standard multi-bucket
SELECT histogram(key, 0, 9, 5) FROM hitest1;
histogram
-----------------
{0,4,3,2,1,0,0}
(1 row)

-- standard 3 bucket
SELECT val, histogram(key, 0, 7, 3) FROM hitest1 GROUP BY val ORDER BY val;
val | histogram
-------+-------------
hello | {0,2,0,0,0}
hi | {0,1,0,0,0}
hola | {0,0,0,1,0}
howdy | {0,0,1,0,0}
sup | {0,3,0,0,0}
ya | {0,0,0,1,0}
yo | {0,0,1,0,0}
(7 rows)

-- standard element beneath lb
SELECT histogram(key, 1, 7, 3) FROM hitest1;
histogram
-------------
{1,5,2,2,0}
(1 row)

-- standard element above ub
SELECT histogram(key, 0, 3, 3) FROM hitest1;
histogram
-------------
{0,1,3,2,4}
(1 row)

-- standard element beneath and above lb and ub, respectively
SELECT histogram(key, 1, 3, 2) FROM hitest1;
histogram
-----------
{1,3,2,4}
(1 row)

-- standard 1 bucket
SELECT histogram(key, 1, 3, 1) FROM hitest1;
histogram
-----------
{1,5,4}
(1 row)

-- standard 2 bucket
SELECT qualify, histogram(score, 0, 10, 2) FROM hitest2 GROUP BY qualify ORDER BY qualify;
qualify | histogram
---------+-----------
f | {0,2,0,0}
t | {0,0,1,1}
(2 rows)

-- standard multi-bucket
SELECT qualify, histogram(score, 0, 10, 5) FROM hitest2 GROUP BY qualify ORDER BY qualify;
qualify | histogram
---------+-----------------
f | {0,0,1,1,0,0,0}
t | {0,0,0,0,1,0,1}
(2 rows)

-- check number of buckets is constant
\set ON_ERROR_STOP 0
select histogram(i,10,90,case when i=1 then 1 else 1000000 end) FROM generate_series(1,100) i;
ERROR: number of buckets must not change between calls
\set ON_ERROR_STOP 1
CREATE TABLE weather (
time TIMESTAMPTZ NOT NULL,
city TEXT,
temperature FLOAT,
PRIMARY KEY(time, city)
);
-- There is a bug in width_bucket() causing a NaN as a result, so we
-- check that it is not causing a crash in histogram().
SELECT * FROM create_hypertable('weather', 'time', 'city', 3);
hypertable_id | schema_name | table_name | created
---------------+-------------+------------+---------
1 | public | weather | t
(1 row)

INSERT INTO weather VALUES
('2023-02-10 09:16:51.133584+00','city1',10.4),
('2023-02-10 11:16:51.611618+00','city1',10.3),
('2023-02-10 06:58:59.999999+00','city1',10.3),
('2023-02-10 01:58:59.999999+00','city1',10.3),
('2023-02-09 01:58:59.999999+00','city1',10.3),
('2023-02-10 08:58:59.999999+00','city1',10.3),
('2023-03-23 06:12:02.73765+00 ','city1', 9.7),
('2023-03-23 06:12:06.990998+00','city1',11.7);
-- This will currently generate an error on PG15 and prior versions
\set ON_ERROR_STOP 0
SELECT histogram(temperature, -1.79769e+308, 1.79769e+308,10) FROM weather GROUP BY city;
ERROR: index -2147483648 from "width_bucket" out of range
\set ON_ERROR_STOP 1
127 changes: 127 additions & 0 deletions test/expected/histogram_test-15.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
-- 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.
-- table 1
CREATE TABLE "hitest1"(key real, val varchar(40));
-- insertions
INSERT INTO "hitest1" VALUES(0, 'hi');
INSERT INTO "hitest1" VALUES(1, 'sup');
INSERT INTO "hitest1" VALUES(2, 'hello');
INSERT INTO "hitest1" VALUES(3, 'yo');
INSERT INTO "hitest1" VALUES(4, 'howdy');
INSERT INTO "hitest1" VALUES(5, 'hola');
INSERT INTO "hitest1" VALUES(6, 'ya');
INSERT INTO "hitest1" VALUES(1, 'sup');
INSERT INTO "hitest1" VALUES(2, 'hello');
INSERT INTO "hitest1" VALUES(1, 'sup');
-- table 2
CREATE TABLE "hitest2"(name varchar(30), score integer, qualify boolean);
-- insertions
INSERT INTO "hitest2" VALUES('Tom', 6, TRUE);
INSERT INTO "hitest2" VALUES('Mary', 4, FALSE);
INSERT INTO "hitest2" VALUES('Jaq', 3, FALSE);
INSERT INTO "hitest2" VALUES('Jane', 10, TRUE);
-- standard 2 bucket
SELECT histogram(key, 0, 9, 2) FROM hitest1;
histogram
-----------
{0,8,2,0}
(1 row)

-- standard multi-bucket
SELECT histogram(key, 0, 9, 5) FROM hitest1;
histogram
-----------------
{0,4,3,2,1,0,0}
(1 row)

-- standard 3 bucket
SELECT val, histogram(key, 0, 7, 3) FROM hitest1 GROUP BY val ORDER BY val;
val | histogram
-------+-------------
hello | {0,2,0,0,0}
hi | {0,1,0,0,0}
hola | {0,0,0,1,0}
howdy | {0,0,1,0,0}
sup | {0,3,0,0,0}
ya | {0,0,0,1,0}
yo | {0,0,1,0,0}
(7 rows)

-- standard element beneath lb
SELECT histogram(key, 1, 7, 3) FROM hitest1;
histogram
-------------
{1,5,2,2,0}
(1 row)

-- standard element above ub
SELECT histogram(key, 0, 3, 3) FROM hitest1;
histogram
-------------
{0,1,3,2,4}
(1 row)

-- standard element beneath and above lb and ub, respectively
SELECT histogram(key, 1, 3, 2) FROM hitest1;
histogram
-----------
{1,3,2,4}
(1 row)

-- standard 1 bucket
SELECT histogram(key, 1, 3, 1) FROM hitest1;
histogram
-----------
{1,5,4}
(1 row)

-- standard 2 bucket
SELECT qualify, histogram(score, 0, 10, 2) FROM hitest2 GROUP BY qualify ORDER BY qualify;
qualify | histogram
---------+-----------
f | {0,2,0,0}
t | {0,0,1,1}
(2 rows)

-- standard multi-bucket
SELECT qualify, histogram(score, 0, 10, 5) FROM hitest2 GROUP BY qualify ORDER BY qualify;
qualify | histogram
---------+-----------------
f | {0,0,1,1,0,0,0}
t | {0,0,0,0,1,0,1}
(2 rows)

-- check number of buckets is constant
\set ON_ERROR_STOP 0
select histogram(i,10,90,case when i=1 then 1 else 1000000 end) FROM generate_series(1,100) i;
ERROR: number of buckets must not change between calls
\set ON_ERROR_STOP 1
CREATE TABLE weather (
time TIMESTAMPTZ NOT NULL,
city TEXT,
temperature FLOAT,
PRIMARY KEY(time, city)
);
-- There is a bug in width_bucket() causing a NaN as a result, so we
-- check that it is not causing a crash in histogram().
SELECT * FROM create_hypertable('weather', 'time', 'city', 3);
hypertable_id | schema_name | table_name | created
---------------+-------------+------------+---------
1 | public | weather | t
(1 row)

INSERT INTO weather VALUES
('2023-02-10 09:16:51.133584+00','city1',10.4),
('2023-02-10 11:16:51.611618+00','city1',10.3),
('2023-02-10 06:58:59.999999+00','city1',10.3),
('2023-02-10 01:58:59.999999+00','city1',10.3),
('2023-02-09 01:58:59.999999+00','city1',10.3),
('2023-02-10 08:58:59.999999+00','city1',10.3),
('2023-03-23 06:12:02.73765+00 ','city1', 9.7),
('2023-03-23 06:12:06.990998+00','city1',11.7);
-- This will currently generate an error on PG15 and prior versions
\set ON_ERROR_STOP 0
SELECT histogram(temperature, -1.79769e+308, 1.79769e+308,10) FROM weather GROUP BY city;
ERROR: index -2147483648 from "width_bucket" out of range
\set ON_ERROR_STOP 1
Loading