From 257d9b49fd672e7da434041b229271920b301477 Mon Sep 17 00:00:00 2001 From: Jason Petersen Date: Thu, 1 Dec 2016 12:35:44 -0700 Subject: [PATCH] Add test to verify whether VACUUM runs remotely Fails for now. --- src/test/regress/expected/multi_utilities.out | 34 +++++++++++++++++++ src/test/regress/sql/multi_utilities.sql | 24 +++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/test/regress/expected/multi_utilities.out b/src/test/regress/expected/multi_utilities.out index ec20ec71b..35e0e166d 100644 --- a/src/test/regress/expected/multi_utilities.out +++ b/src/test/regress/expected/multi_utilities.out @@ -66,3 +66,37 @@ SELECT master_apply_delete_command('DELETE FROM sharded_table'); -- drop table DROP TABLE sharded_table; +-- VACUUM tests +-- create a table with a single shard (for convenience) +CREATE TABLE dustbunnies (id integer, name text); +SELECT master_create_distributed_table('dustbunnies', 'id', 'hash'); + master_create_distributed_table +--------------------------------- + +(1 row) + +SELECT master_create_worker_shards('dustbunnies', 1, 2); + master_create_worker_shards +----------------------------- + +(1 row) + +-- add some data to the distributed table +\copy dustbunnies from stdin with csv +-- delete all rows from the shard, then run VACUUM against the table on the master +DELETE FROM dustbunnies; +VACUUM dustbunnies; +-- update statistics, then verify that the four dead rows are gone +\c - - - :worker_1_port +SELECT pg_sleep(.500); + pg_sleep +---------- + +(1 row) + +SELECT pg_stat_get_vacuum_count('dustbunnies_990002'::regclass); + pg_stat_get_vacuum_count +-------------------------- + 1 +(1 row) + diff --git a/src/test/regress/sql/multi_utilities.sql b/src/test/regress/sql/multi_utilities.sql index 15fa16cdc..1f5978c92 100644 --- a/src/test/regress/sql/multi_utilities.sql +++ b/src/test/regress/sql/multi_utilities.sql @@ -40,3 +40,27 @@ SELECT master_apply_delete_command('DELETE FROM sharded_table'); -- drop table DROP TABLE sharded_table; + +-- VACUUM tests + +-- create a table with a single shard (for convenience) +CREATE TABLE dustbunnies (id integer, name text); +SELECT master_create_distributed_table('dustbunnies', 'id', 'hash'); +SELECT master_create_worker_shards('dustbunnies', 1, 2); + +-- add some data to the distributed table +\copy dustbunnies from stdin with csv +1,bugs +2,babs +3,buster +4,roger +\. + +-- delete all rows from the shard, then run VACUUM against the table on the master +DELETE FROM dustbunnies; +VACUUM dustbunnies; + +-- update statistics, then verify that the four dead rows are gone +\c - - - :worker_1_port +SELECT pg_sleep(.500); +SELECT pg_stat_get_vacuum_count('dustbunnies_990002'::regclass);