Basic question. I have a map-reduced. I'm creating...
# suitescript
s
Basic question. I have a map-reduced. I'm creating Deployments. How many deployments can I create for the script ? Also, when I call the map reduced, do I have to say which deployment to use or Netsuite will do it automatically ?
d
Calling task.create(options) without passing
deploymentId
will mean NS will choose an available deployment for you. Also IIRC, if all deployments are busy when you call
Task.submit()
it will queue your task until there's a free deployment
Not sure what the max deployments is, but in theory you only need one. Use more if you intend to call the M/R again before it finishes (obvs. take this into account in your script logic)
s
Thanks a lot
m
If all deployments are busy it won't queue. It will throw an error.
☝️ 1
👆 1
👍 1
d
The help page seems to say that a M/R can resubmit itself and it will queue
Additionally, note that a map/reduce script can be submitted for processing only if there is no unfinished map/reduce script task for the same script ID and script deployment ID. For this reason, if a map/reduce script resubmits itself, the actual resubmit does not occur until the current execution completes. This delay is necessary to avoid the existence of two unfinished tasks for the same deployment of the same script. Therefore, if a map/reduce script uses the submit() method to resubmit itself, then at runtime, no task ID is returned when the map/reduce script is submitted
I remember a discussion here on slack about being able to submit a task with all deployments busy. Will try to find documentation of this 🤥
m
That's special behavior when a Map/Reduce resubmits itself. To initiate from a different script you need a free deployment
I've heard of people creating deployments on the fly
d
AbsoLUTEly throws an error when you try to
Task.submit()
with no available deployments.
e
If the M/R is running, you'll get a
MAP_REDUCE_ALREADY_RUNNING
error
d
Yeah, the above error is from submitting a scheduled script that was already running