From a48a4646b037c30d63886b3800c4c5ea6efa4241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Nordstr=C3=B6m?= Date: Tue, 18 Aug 2020 13:08:54 +0200 Subject: [PATCH] Improve the concurrent refresh test This change moves the invalidation threshold in the setup phase of the concurrent refresh test for continuous aggregates in order to generate invalidations. Without any invalidations, the invalidation logs are never really processed and thus not subjected to concurrency. --- .../continuous_aggs_concurrent_refresh.out | 59 ++++++++++++++----- .../continuous_aggs_concurrent_refresh.spec | 31 +++++++++- 2 files changed, 73 insertions(+), 17 deletions(-) diff --git a/tsl/test/isolation/expected/continuous_aggs_concurrent_refresh.out b/tsl/test/isolation/expected/continuous_aggs_concurrent_refresh.out index 94715641e..71b3d27af 100644 --- a/tsl/test/isolation/expected/continuous_aggs_concurrent_refresh.out +++ b/tsl/test/isolation/expected/continuous_aggs_concurrent_refresh.out @@ -17,13 +17,16 @@ step S1_select: bucket avg_temp +0 15.8888888888889 +10 14.2 +20 13.4 30 18.3 -40 15.1 +40 16.0909090909091 50 26.9 60 18.9 cagg_bucket_count -4 +7 hypertable threshold conditions 70 @@ -43,8 +46,11 @@ step S1_select: bucket avg_temp +0 15.8888888888889 +10 14.2 +20 13.4 30 18.3 -40 15.1 +40 16.0909090909091 50 26.9 60 18.9 70 24.6 @@ -52,7 +58,7 @@ bucket avg_temp 90 21.3 cagg_bucket_count -7 +10 hypertable threshold conditions 100 @@ -91,12 +97,15 @@ step S1_select: bucket avg_temp +0 15.8888888888889 +10 14.2 +20 13.4 70 24.6 80 23.6 90 21.3 cagg_bucket_count -3 +6 hypertable threshold conditions 100 @@ -135,8 +144,11 @@ step S1_select: bucket avg_temp +0 15.8888888888889 +10 14.2 +20 13.4 30 18.3 -40 15.1 +40 16.0909090909091 50 26.9 60 18.9 70 24.6 @@ -144,7 +156,7 @@ bucket avg_temp 90 21.3 cagg_bucket_count -7 +10 hypertable threshold conditions 100 @@ -183,8 +195,11 @@ step S1_select: bucket avg_temp +0 15.8888888888889 +10 14.2 +20 13.4 30 18.3 -40 15.1 +40 16.0909090909091 50 26.9 60 18.9 70 24.6 @@ -192,7 +207,7 @@ bucket avg_temp 90 21.3 cagg_bucket_count -7 +10 hypertable threshold conditions 100 @@ -230,13 +245,16 @@ step S1_select: bucket avg_temp +0 15.8888888888889 +10 14.2 +20 13.4 30 18.3 -40 15.1 +40 16.0909090909091 50 26.9 60 18.9 cagg_bucket_count -4 +7 hypertable threshold conditions 70 @@ -278,13 +296,16 @@ step S1_select: bucket avg_temp +0 15.8888888888889 +10 14.2 +20 13.4 30 18.3 -40 15.1 +40 16.0909090909091 50 26.9 60 18.9 cagg_bucket_count -4 +7 hypertable threshold conditions 70 @@ -326,8 +347,11 @@ step S1_select: bucket avg_temp +0 15.8888888888889 +10 14.2 +20 13.4 30 18.3 -40 15.1 +40 16.0909090909091 50 26.9 60 18.9 70 24.6 @@ -335,7 +359,7 @@ bucket avg_temp 90 21.3 cagg_bucket_count -7 +10 hypertable threshold conditions 100 @@ -376,12 +400,15 @@ step S1_select: bucket avg_temp +0 15.8888888888889 +10 14.2 +20 13.4 70 24.6 80 23.6 90 21.3 cagg_bucket_count -3 +6 hypertable threshold conditions 100 diff --git a/tsl/test/isolation/specs/continuous_aggs_concurrent_refresh.spec b/tsl/test/isolation/specs/continuous_aggs_concurrent_refresh.spec index 1d861153f..f9e952500 100644 --- a/tsl/test/isolation/specs/continuous_aggs_concurrent_refresh.spec +++ b/tsl/test/isolation/specs/continuous_aggs_concurrent_refresh.spec @@ -85,6 +85,36 @@ setup END; $$ LANGUAGE plpgsql; } +# Move the invalidation threshold so that we can generate some +# invalidations. This must be done in its own setup block since +# refreshing can't be done in a transaction block. +setup +{ + CALL refresh_continuous_aggregate('cond_10', 0, 30); + +} + +# Generate some invalidations. Must be done in separate transcations +# or otherwise there will be only one invalidation. +setup +{ + BEGIN; + INSERT INTO conditions + SELECT t, abs(timestamp_hash(to_timestamp(t)::timestamp))%40 + FROM generate_series(1, 10, 1) t; + COMMIT; + BEGIN; + INSERT INTO conditions + SELECT t, abs(timestamp_hash(to_timestamp(t)::timestamp))%40 + FROM generate_series(10, 20, 1) t; + COMMIT; + BEGIN; + INSERT INTO conditions + SELECT t, abs(timestamp_hash(to_timestamp(t)::timestamp))%40 + FROM generate_series(15, 40, 1) t; + COMMIT; +} + teardown { DROP TABLE conditions CASCADE; } @@ -203,7 +233,6 @@ step "L3_unlock_cagg_table" ROLLBACK; } - # Session to view the contents of a cagg after materialization. It # also prints the bucket count (number of rows in the materialization # hypertable) and the invalidation threshold. The bucket count should