Skip to content

Commit

Permalink
Fix bgw_db_scheduler_fixed flakyness
Browse files Browse the repository at this point in the history
Depending on date boundaries the number of chunks produced for the
cagg hypertable was not constant resulting on flaky tests on certain
days.
  • Loading branch information
svenklemm committed Nov 1, 2022
1 parent 0f4dc61 commit 1420017
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions tsl/test/expected/bgw_db_scheduler_fixed.out
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,12 @@ SELECT time_bucket('1 month', time), avg(a)
FROM test_table_scheduler
GROUP BY time_bucket('1 month', time)
WITH NO DATA;
SELECT set_chunk_time_interval('_timescaledb_internal._materialized_hypertable_2', interval '36500 days');
set_chunk_time_interval
-------------------------

(1 row)

select show_chunks('test_table_scheduler');
show_chunks
----------------------------------------
Expand Down Expand Up @@ -1694,11 +1700,11 @@ select hypertable_schema, hypertable_name, chunk_schema, chunk_name, is_compress
_timescaledb_internal | _materialized_hypertable_2 | _timescaledb_internal | _hyper_2_10_chunk | f
(5 rows)

select avg_a from cagg_scheduler;
select avg_a from cagg_scheduler ORDER BY 1;
avg_a
--------------------
4.0000000000000000
3.0000000000000000
4.0000000000000000
(2 rows)

-- test the API for add_job too
Expand Down
4 changes: 3 additions & 1 deletion tsl/test/sql/bgw_db_scheduler_fixed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,8 @@ FROM test_table_scheduler
GROUP BY time_bucket('1 month', time)
WITH NO DATA;

SELECT set_chunk_time_interval('_timescaledb_internal._materialized_hypertable_2', interval '36500 days');

select show_chunks('test_table_scheduler');

alter table test_table_scheduler set (timescaledb.compress, timescaledb.compress_orderby = 'time DESC');
Expand All @@ -717,7 +719,7 @@ SELECT * from _timescaledb_internal.bgw_job_stat;

SELECT show_chunks('test_table_scheduler');
select hypertable_schema, hypertable_name, chunk_schema, chunk_name, is_compressed from timescaledb_information.chunks ;
select avg_a from cagg_scheduler;
select avg_a from cagg_scheduler ORDER BY 1;
-- test the API for add_job too
create or replace procedure job_test_fixed(jobid int, config jsonb) language plpgsql as $$
begin
Expand Down

0 comments on commit 1420017

Please sign in to comment.