mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 02:53:51 +08:00
A chunk copy/move operation is carried out in stages and it can fail in any of them. We track the last completed stage in the "chunk_copy_operation" catalog table. In case of failure, a "chunk_copy_cleanup" function can be invoked to bring the chunk back to its original state on the source datanode and all transient objects like replication slot, publication, subscription, empty chunk, metadata updates, etc are cleaned up. Includes test case changes for each and every stage induced failure. To avoid confusion between chunk copy activity and chunk copy operation this patch also consistently uses "operation" everywhere now instead of "activity"
23 lines
1.2 KiB
SQL
23 lines
1.2 KiB
SQL
CREATE SCHEMA IF NOT EXISTS timescaledb_experimental;
|
|
GRANT USAGE ON SCHEMA timescaledb_experimental TO PUBLIC;
|
|
DROP FUNCTION IF EXISTS _timescaledb_internal.block_new_chunks;
|
|
DROP FUNCTION IF EXISTS _timescaledb_internal.allow_new_chunks;
|
|
DROP FUNCTION IF EXISTS _timescaledb_internal.refresh_continuous_aggregate;
|
|
DROP FUNCTION IF EXISTS _timescaledb_internal.create_chunk;
|
|
|
|
CREATE SEQUENCE IF NOT EXISTS _timescaledb_catalog.chunk_copy_operation_id_seq MINVALUE 1;
|
|
|
|
CREATE TABLE IF NOT EXISTS _timescaledb_catalog.chunk_copy_operation (
|
|
operation_id name PRIMARY KEY, -- the publisher/subscriber identifier used
|
|
backend_pid integer NOT NULL, -- the pid of the backend running this activity
|
|
completed_stage name NOT NULL, -- the completed stage/step
|
|
time_start timestamptz NOT NULL DEFAULT NOW(), -- start time of the activity
|
|
chunk_id integer NOT NULL REFERENCES _timescaledb_catalog.chunk (id) ON DELETE CASCADE,
|
|
source_node_name name NOT NULL,
|
|
dest_node_name name NOT NULL,
|
|
delete_on_source_node bool NOT NULL -- is a move or copy activity
|
|
);
|
|
|
|
GRANT SELECT ON _timescaledb_catalog.chunk_copy_operation_id_seq TO PUBLIC;
|
|
GRANT SELECT ON _timescaledb_catalog.chunk_copy_operation TO PUBLIC;
|