Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-10055

Calculation of history cleanup batch window does not respect daylight saving time changes

    Details

    • Type: Bug Report
    • Status: Ready
    • Priority: L3 - Default
    • Resolution: Unresolved
    • Affects Version/s: 7.7.0, 7.8.0, 7.9.0, 7.10.0, 7.11.0
    • Fix Version/s: None
    • Component/s: engine
    • Labels:
      None

      Description

      Scenario:

      • The day of daylight saving time change (example 01.04.2019)
      • History cleanup has a batch window configure to 23:00 - 01:00
      • The job will be scheduled and executed but after the time change it will be scheduled for the next day so it will not run as it is planned

      Test case:

        @Test
        public void testLessThanThresholdWithinBatchWindowAfterMidnight() {
          //given
          prepareData(5);
      
          //we're within batch window, but batch window passes midnight
          Date date = new Date(1554117839291l);// 01.04.2019
          ClockUtil.setCurrentTime(DateUtils.setMinutes(DateUtils.setHours(date, 0), 10));  //00:10
          processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00");
          processEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00");
          processEngineConfiguration.initHistoryCleanup();
      
          //when
          runHistoryCleanup(false);
      
          //then
          final List<Job> historyCleanupJobs = historyService.findHistoryCleanupJobs();
          for (Job job : historyCleanupJobs) {
            JobEntity jobEntity = (JobEntity) job;
            HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity);
      
            //job rescheduled till current time + delay
            Date nextRun = getNextRunWithDelay(ClockUtil.getCurrentTime(), 0);
            assertTrue(jobEntity.getDuedate().equals(nextRun) || jobEntity.getDuedate().after(nextRun));
            Date nextRunMax = DateUtils.addSeconds(ClockUtil.getCurrentTime(), HistoryCleanupJobHandlerConfiguration.MAX_DELAY);
            assertTrue(jobEntity.getDuedate().before(nextRunMax));
      
            //countEmptyRuns incremented
            assertEquals(1, configuration.getCountEmptyRuns());
          }
      
          //data is still removed
          assertResult(0);
        }
      

      Hints:
      DefaultBatchWindowManager#addDays() [1] method does not respect the change of timezone offset related with daylight saving time.
      [1]: https://github.com/camunda/camunda-bpm-platform/blob/2917d85a15a0b44c5a88e640a20a8c3f0f9da758/engine/src/main/java/org/camunda/bpm/engine/impl/jobexecutor/historycleanup/DefaultBatchWindowManager.java#L122-L127

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              yana.vasileva Yana Vasileva
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Development