Option A: Before submitting a task into the queue, run a Saved Scheduled Script Instance Search to check if there are any in-progress jobs with the same script deployment internal ID:
- Create a Saved Search on the UI:
- Navigate to Reports > Saved Searches > All Saved Searches > New
- Select Scheduled Script Instance
- Mark the Public checkbox
- Add the following Filters under the Criteria subtab:
- Script Deployment: Internal ID – any of – Internal ID of the Script Deployment record for Map/Reduce script
- Status – none of – ‘Complete’, ‘Canceled’, ‘Failed’
- Run the Saved Search before submitting a task into the queue:
- Before submitting the task into the queue, run the search created. If the search returns result(s), the script will not submit an instance of the Map/Reduce script since there’s still one that is in progress.
Option B: Create multiple Script Deployment records for the Map/Reduce script and reference a unique script deployment using the deploymentId property when creating a task.