Uploaded image for project: 'OpenIDM'
  1. OpenIDM
  2. OPENIDM-15082

TaskScanner recovery time interval uses 2 different timezones

    Details

    • Target Version/s:
    • Verified Version/s:
    • Story Points:
      1
    • Sprint:
      2020.09 - IDM

      Description

      When the task scanner tries to decide if it needs to skip over an entry due to it being within the recovery time interval, the interval compares with 2 different timezones making the recovery time interval inaccurate. This can be seen by running the setting the recovery time to `5s` in the sunset task scanner sample and changing the script to always return false. The problem code is here in TaskScannerJob.java

          private void performTaskOverSet(JsonValue results)
                          throws ExecutionException {
              for (JsonValue input : results) {
                  if (taskScannerContext.isCanceled()) {
                      logger.info("Task '" + taskScannerContext.getTaskScanID() + "' cancelled. Terminating execution.");
                      // Jump out quick since we've cancelled the job
                      break;
                  }
                  // Check if this object has a STARTED time already
                  JsonValue startTime = input.get(taskScannerContext.getStartField());
                  String startTimeString = null;
                  if (startTime != null && !startTime.isNull()) {
                      startTimeString = startTime.asString();
                      LocalDateTime startedTime = LocalDateTime.parse(startTimeString);
      
                      // Skip if the startTime + interval has not been passed
                      TemporalAmount period = taskScannerContext.getRecoveryTimeout();
                      LocalDateTime expirationDate = startedTime.plus(period);
                      if (expirationDate.isAfter(LocalDateTime.now())) {
                          logger.debug(
                                  "Object already started and has not expired. Started at: {}. Timeout: {}. Expires at: {}",
                                  DATE_UTIL.formatDateTime(startedTime),
                                  period,
                                  DATE_UTIL.formatDateTime(expirationDate));
                          continue;
                      }
                  }
      
                  try {
                      claimAndExecScript(input, startTimeString);
                  } catch (ResourceException e) {
                      throw new ExecutionException("Error during claim and execution phase", e);
                  }
              }
          }
      

      When calculating and comparing the expiration date 2 timezones are used.

                      TemporalAmount period = taskScannerContext.getRecoveryTimeout();
                      LocalDateTime expirationDate = startedTime.plus(period);
                      if (expirationDate.isAfter(LocalDateTime.now())) {
      

      startedTime always uses the UTC timezone since it is set using the DATE_UTIL instance in that class, and LocalDateTime.now() uses the jvm's local timezone. If the jvm is not running in the UTC timezone then 2 different timezones are being used in the expirationDate comparison causing the comparison to be inaccurate.

        Attachments

          Activity

            People

            • Assignee:
              cgdrake Chris Drake
              Reporter:
              jason Jason Lemay
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: