citus/src/test/regress/expected/multi_query_directory_clean...

155 lines
4.6 KiB
Plaintext

--
-- MULTI_QUERY_DIRECTORY_CLEANUP
--
-- We execute sub-queries on worker nodes, and copy query results to a directory
-- on the master node for final processing. When the query completes or fails,
-- the resource owner should automatically clean up these intermediate query
-- result files.
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 810000;
ALTER SEQUENCE pg_catalog.pg_dist_jobid_seq RESTART 810000;
BEGIN;
-- pg_ls_dir() displays jobids. We explicitly set the jobId sequence
-- here so that the regression output becomes independent of the
-- number of jobs executed prior to running this test.
ALTER SEQUENCE pg_catalog.pg_dist_jobid_seq RESTART 1250;
SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
revenue
---------------
22770844.7654
(1 row)
SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
revenue
---------------
22770844.7654
(1 row)
SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
revenue
---------------
22770844.7654
(1 row)
SELECT pg_ls_dir('base/pgsql_job_cache');
pg_ls_dir
-----------
(0 rows)
COMMIT;
SELECT pg_ls_dir('base/pgsql_job_cache');
pg_ls_dir
-----------
(0 rows)
BEGIN;
SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
revenue
---------------
22770844.7654
(1 row)
SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
revenue
---------------
22770844.7654
(1 row)
SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
revenue
---------------
22770844.7654
(1 row)
SELECT pg_ls_dir('base/pgsql_job_cache');
pg_ls_dir
-----------
(0 rows)
ROLLBACK;
SELECT pg_ls_dir('base/pgsql_job_cache');
pg_ls_dir
-----------
(0 rows)
-- Test that multiple job directories are all cleaned up correctly,
-- both individually (by closing a cursor) and in bulk when ending a
-- transaction.
BEGIN;
DECLARE c_00 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_01 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_02 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_03 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_04 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_05 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_06 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_07 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_08 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_09 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_10 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_11 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_12 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_13 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_14 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_15 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_16 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_17 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_18 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
DECLARE c_19 CURSOR FOR SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem;
SELECT * FROM pg_ls_dir('base/pgsql_job_cache') f ORDER BY f;
f
-----------------
master_job_1256
master_job_1257
master_job_1258
master_job_1259
master_job_1260
master_job_1261
master_job_1262
master_job_1263
master_job_1264
master_job_1265
master_job_1266
master_job_1267
master_job_1268
master_job_1269
master_job_1270
master_job_1271
master_job_1272
master_job_1273
master_job_1274
master_job_1275
(20 rows)
-- close first, 17th (first after re-alloc) and last cursor.
CLOSE c_00;
CLOSE c_16;
CLOSE c_19;
SELECT * FROM pg_ls_dir('base/pgsql_job_cache') f ORDER BY f;
f
-----------------
master_job_1257
master_job_1258
master_job_1259
master_job_1260
master_job_1261
master_job_1262
master_job_1263
master_job_1264
master_job_1265
master_job_1266
master_job_1267
master_job_1268
master_job_1269
master_job_1270
master_job_1271
master_job_1273
master_job_1274
(17 rows)
ROLLBACK;
SELECT pg_ls_dir('base/pgsql_job_cache');
pg_ls_dir
-----------
(0 rows)