You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PostgreSQL version (output of SELECT version();): 15.8
TimescaleDB Toolkit version (output of \dx timescaledb_toolkit in psql): 1.18.0
TimescaleDB version: 1.16.1
Installation method: Managed Services for Timescale (MST)
Describe the bug
A 1D stats_agg over a large number of rows (~300K) produces garbage results when executed on a 2CPU Managed Services for Timescale (MST) installation. Preventing the query planner from using parallelism (via SET max_parallel_workers_per_gather = 0;) produces correct results. Incorrect results occur even if a single parallel worker is used (SET max_parallel_workers_per_gather = 1;).
To Reproduce
I have been unable to reproduce using local docker (MacOS, M1) or a small Timescale Cloud instance (0.5CPU), however, I can reproduce on multiple MST instances.
Steps to reproduce the behavior:
Using Managed Service for Timescale, create a dev instance (2CPU/4MB)
Create a table as follows:
CREATETABLEIF NOT EXISTS device_stats
(
ts timestamp with time zone,
device_location_id bigint,
heatsink_temp_c double precision
);
Execute the following query, and note the stats_agg average is incorrect compared to avg
SET max_parallel_workers_per_gather =1;
select
time_bucket('1h', ts) as bucket,
device_location_id,
average(stats_agg(heatsink_temp_c)) as average,
avg(heatsink_temp_c) as avg,
stats_agg(heatsink_temp_c)
from aims_device_stats
group by1, 2
Expected behavior
Correct averages from average(stats_agg()) that are equal to the values returned by avg().
Actual behavior
stats_agg 'average' is null, and the dumped statssummary1d contains zero or near-zero values.
When I compare the statssummary1d dump from correct results to the erroneous results, there are numerous instances where 'version' much higher than 1, n is 0 and the sx values are zero or extremely small fractions.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
This is definitely related to parallelism. Small queries or explicit actions that prevent the planner from choosing parallel execution produce correct results.
The text was updated successfully, but these errors were encountered:
Thank you for the thorough bug report. What you are seeing is indeed a bug which is only triggered when parallel workers are used to process a stats_agg aggregate. PR #828 should fix it.
Relevant system information:
SELECT version();
): 15.8\dx timescaledb_toolkit
inpsql
): 1.18.0Describe the bug
A 1D
stats_agg
over a large number of rows (~300K) produces garbage results when executed on a 2CPU Managed Services for Timescale (MST) installation. Preventing the query planner from using parallelism (viaSET max_parallel_workers_per_gather = 0;
) produces correct results. Incorrect results occur even if a single parallel worker is used (SET max_parallel_workers_per_gather = 1;
).To Reproduce
I have been unable to reproduce using local docker (MacOS, M1) or a small Timescale Cloud instance (0.5CPU), however, I can reproduce on multiple MST instances.
Steps to reproduce the behavior:
Expected behavior
Correct averages from average(stats_agg()) that are equal to the values returned by avg().
Actual behavior
stats_agg 'average' is
null
, and the dumped statssummary1d contains zero or near-zero values.Example incorrect output
When I compare the statssummary1d dump from correct results to the erroneous results, there are numerous instances where 'version' much higher than 1,
n
is 0 and thesx
values are zero or extremely small fractions.Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
This is definitely related to parallelism. Small queries or explicit actions that prevent the planner from choosing parallel execution produce correct results.
The text was updated successfully, but these errors were encountered: