eaolson
eaolson

Reputation: 15094

What is the time limit for a scheduled task?

I'm working on what will eventually be a scheduled task and may be a fairly long-running one. I'm testing it by calling xdmp.spawn() in Query Console, and have had to increase the default timeLimit parameter. As I understand it, xdmp.spawn() will use the default time limit set for the app server and you can specify a different timeLimit up to the app server's max time limit parameter.

But what is the time limit for a scheduled task? I'm not even clear what app server they run on. There doesn't seem to be any way to specify a different time limit, so will it be using the default or max time limit?

Upvotes: 3

Views: 2304

Answers (2)

Mads Hansen
Mads Hansen

Reputation: 66783

Scheduled tasks are executed either on the assigned host or all hosts if no host is specified for the task host.

https://docs.marklogic.com/guide/admin/scheduling_tasks#chapter

  1. In the Task User and Task Host fields, specify the user with permission to invoke the task and the host computer on which the task is to be invoked. If no host is specified, then the task runs on all hosts.

The default task server time limits are similar to any other application server:

  • The default time limit is 600 seconds
  • The max time limit is 3600 seconds

You can verify (and adjust) this in the Admin UI by going to: Configure -> Groups -> Default (or whichever group your server is in) -> Task Server

https://docs.marklogic.com/admin-help/task-server

  • max time limit specifies the upper bound for any request's time limit. No request may set its time limit (for example with xdmp:set-request-time-limit) higher than this number. The time limit, in turn, is the maximum number of seconds allowed for servicing a query request. The App Server gives up on queries which take longer, and returns an error.
  • default time limit specifies the default value for any request's time limit, when otherwise unspecified. A request can change its time limit using xdmp:set-request-time-limit. The time limit is the default number of seconds allowed for servicing a query request.

Upvotes: 2

ehennum
ehennum

Reputation: 7335

The commonly accepted best practice is to run long tasks outside of the server and to issue requests to the server to iterate on the work for the task (potentially concurrent requests if the work can be partitioned in some way).

The task server is designed to react to events within the server instead of running long processes.

If the task is dependent on server state, an external process can poll the server to see if work needs to be done.

Or, the task executing on the task server can use the xdmp.http*() builtins to notify the external process that it needs to run.

Hoping that's useful,

Upvotes: 2

Related Questions