The PeriodGranularity may not calculate the bucketStart correctly when works with timeZone that DST is used.
Here's what in our groupby query:
Check this code:
Left: current, Right: possible fix
Check the output from our test program(attached):
segment min 2022-03-06T02:40:00.000-07:00
DST Transition 2022-03-13T03:00:00.000-06:00
Due to the DST Transition, the result from origin -21D is not the same with -14D then -7D. It should have the same issue with period Week/Month.
In our case, it causes the granulizer selected nothing for the bucketInterval in the following code:
Finally causing a infinite loop in (the selected while loop):
The query thread will take 100% CPU and never exit, after all merge buffers have been taken by these threads, no more groupby queries can be executed on this historical server. We had to kill this process for restarting.