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

Enabling a persistent schedule multiple times through the config API runs a custom script multiple times

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: OpenIDM 5.5.0, OpenIDM 6.0.0
    • Fix Version/s: OpenIDM 6.0.0
    • Component/s: Module - Scheduler
    • Environment:
      openidm-5.5.0-RC14, openidm-6.0.0-SNAPSHOT (revision: 42f72ee), postcommit-3300

      Description

      A disabled persistent schedule (executing custom script) is enabled multiple times via "openidm/config/scheduler/name_of_scheduler" endpoint by the request below (twice in our case) then the custom script is executed multiple times (twice in our case) and the runs are overlapping.
      If "scheduler/job/name_of_scheduler" endpoint is used to enable the scheduler it works as expected - that is the custom script is run only once at a time. The scheduler has concurrentExecution set to false and misfirePolicy is fireAndProceed.

      Steps to reproduce

      • deploy openidm 6.0.0
      • add attached scheduler to conf folder
      • enable this scheduler two times with this command
        curl -X PUT \
          http://localhost:8080/openidm/config/schedule/persistent-log \
          -H 'cache-control: no-cache' \
          -H 'content-type: application/json' \
          -H 'if-match: *' \
          -H 'postman-token: 14e59300-a9bf-11e5-cfdb-36ec621634b5' \
          -H 'x-openidm-password: openidm-admin' \
          -H 'x-openidm-username: openidm-admin' \
          -d '{    
            "enabled":true,
            "type":"cron",
            "schedule":"0/5 * * * * ?",
            "persisted":true,
            "misfirePolicy":"fireAndProceed",
            "concurrentExecution":false,
            "invokeService":"script",
            "invokeContext": {
                "source" : "import org.slf4j.*;int time = 0;logger = LoggerFactory.getLogger('logger');Date date = new Date();logger.info(String.format('Performing persistent job started at %s', date));while(time < 30){Date date2 = new Date();logger.info(String.format('Performing persistent job %s, started at %s', date2, date));sleep(1000);time += 1}"
                }
            }
        }'
        
      • check idm log with this command
        cat path_to_openidm/logs/openidm0.log.0 | grep "INFO: Performing persistent job"
        
        
        INFO: Performing persistent job started at Fri Oct 20 11:08:26 CEST 2017
        INFO: Performing persistent job Fri Oct 20 11:08:26 CEST 2017, started at Fri Oct 20 11:08:26 CEST 2017
        INFO: Performing persistent job Fri Oct 20 11:08:27 CEST 2017, started at Fri Oct 20 11:08:26 CEST 2017
        INFO: Performing persistent job Fri Oct 20 11:08:28 CEST 2017, started at Fri Oct 20 11:08:26 CEST 2017
        INFO: Performing persistent job Fri Oct 20 11:08:29 CEST 2017, started at Fri Oct 20 11:08:26 CEST 2017
        INFO: Performing persistent job started at Fri Oct 20 11:08:29 CEST 2017
        INFO: Performing persistent job Fri Oct 20 11:08:29 CEST 2017, started at Fri Oct 20 11:08:29 CEST 2017
        INFO: Performing persistent job Fri Oct 20 11:08:30 CEST 2017, started at Fri Oct 20 11:08:26 CEST 2017
        INFO: Performing persistent job Fri Oct 20 11:08:30 CEST 2017, started at Fri Oct 20 11:08:29 CEST 2017
        INFO: Performing persistent job Fri Oct 20 11:08:31 CEST 2017, started at Fri Oct 20 11:08:26 CEST 2017
        INFO: Performing persistent job Fri Oct 20 11:08:31 CEST 2017, started at Fri Oct 20 11:08:29 CEST 2017
        

      As we can see in the log, there are two instances of the same script but it should be run only once because the first script hasn't stopped yet.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cgdrake Chris Drake
                Reporter:
                vojtech.oczka Vojtěch Oczka
                QA Assignee:
                Vojtěch Oczka
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: