benhopp opened a new pull request, #19382:
URL: https://github.com/apache/druid/pull/19382

   Fixes a bug where timestamp_floor with compound time-only periods falls back 
to an infinite loop when the timezone has daylight saving time.
   
   ### Description
   The issue is caused by how Druid's PeriodGranularity attempts to bucket 
timestamps when timezones and daylight saving time (DST) are involved. 
   
   When trying to bucket timestamps using a compound period like PT1M1S, Druid 
first tries a fast-path (`truncateMillisPeriod`). It checks if the timezone has 
precise days and hours. Because timezones with DST (like `America/New_York`) 
observe daylight saving time, Druid incorrectly flags the timezone as imprecise 
for all period durations. It then falls back to a slow-path 
(`truncateCompoundPeriod`), which literally runs a while loop, adding the 
period duration starting from January 1st, 1970, until it reaches the target 
timestamp. This means it loops over 28 million times for every single row in 
the query, causing it to hang.
   
   This PR updates the `truncateMillisPeriod` logic to check if the period 
contains any inherently imprecise components like years, months, weeks, or 
days. If the period only contains hours, minutes, seconds, or milliseconds, it 
will safely convert the period to milliseconds and use the fast-path modulo 
math, avoiding the infinite while loop completely.
   
   A regression test `PeriodGranularityBugTest.java` is included to validate 
this fix.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to