# Scheduler and jobs that Can Never Run

**URL:** <https://community.openpbs.org/t/scheduler-and-jobs-that-can-never-run/213>\
**Category:** Users/Site Administrators\
**Created:** [August 12, 2016, 11:40am UTC](https://community.openpbs.org/t/scheduler-and-jobs-that-can-never-run/213 "2016-08-12T11:40:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![buchmann](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/buchmann/32/31_2.png) [@buchmann](https://community.openpbs.org/u/buchmann)\
**Post date:** [August 12, 2016, 11:40am UTC](https://community.openpbs.org/t/scheduler-and-jobs-that-can-never-run/213/1 "2016-08-12T11:40:23Z")

</div>

Dear Wizards,

In certain cases the scheduler may see that a job will _never_ run. If too many resources are requested, like asking for ncpus per node \> than what is available on any node in the system, or more nodes than is available etc. The number of nodes in a placement set (pcat, aka node group) may also be the cause of this.

In these cases, the scheduler sets the job comment to include something along the lines of:

> comment = Can Never Run: can’t fit in the largest placement set, and can’t span psets

or

> comment = Not Running: Insufficient amount of resource:

but the job itself just hangs around in the queue indefinitely.

On the other hand, if I impose a hard max on, say, the number of nodes (server or queue side) with e.g.

> qmgr -c “set server resources\_max.nodect = 3”

then qsub will fail (upon job submission) and the job will never enter the queue.

I assume that this is by design. Obviously, a very optimistic user could hope that somebody will install more nodes - or more cores per node etc. But in our case I might as well have the job be deleted (with some comment and/or log message) automagically.

I have not found a setting to do this, i.e. have the scheduler deem that this job will not ever run unless more resources are defined. The AdminGuide only states that " the job stays queued" (AG-124 §4.6.2), but does not say if something could be done about it.  
Does anybody know if that is possible (or that it for sure is not?).

If it is not possible, then I’ll find a way around it - to look at the comments of queued jobs and explicitly fail jobs which have such comments. But it might be better, if a server/scheduler setting could fix it.

---

<div class="post-metadata">

**Author:** ![dilip-krishnan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/dilip-krishnan/32/75_2.png) [@dilip-krishnan](https://community.openpbs.org/u/dilip-krishnan)\
**Post date:** [August 12, 2016, 1:02pm UTC](https://community.openpbs.org/t/scheduler-and-jobs-that-can-never-run/213/2 "2016-08-12T13:02:25Z")

</div>

Hi Bjarne,  
AFAIK there doesn’t exist any such feature, where server will cleanup the queues based on some criteria. But you can always write a hook for queuejob event, and reject any job while submission which request resource more than available in the complex.

But writing such hook could be a very tedious task since there are many resources that needs to be accounted for.

I think your idea of writing a script and removing jobs periodically, based on the set comment is best.

---

<div class="post-metadata">

**Author:** ![mkaro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/mkaro/32/85_2.png) [@mkaro](https://community.openpbs.org/u/mkaro)\
**Post date:** [August 12, 2016, 4:03pm UTC](https://community.openpbs.org/t/scheduler-and-jobs-that-can-never-run/213/3 "2016-08-12T16:03:49Z")

</div>

> [@buchmann](#):
>
> I assume that this is by design. Obviously, a very optimistic user could hope that somebody will install more nodes - or more cores per node etc. But in our case I might as well have the job be deleted (with some comment and/or log message) automagically.

Your assumption is spot on in this case. PBS Pro will not delete the job if there is the slightest possibility it could run at some point in the future. As @dilip-krishnan indicated, you could write a hook to address this. The goal should be to reject jobs at submission time if they don’t request a sane amount of resources. That way the user receives immediate feedback as opposed to having their job accepted, only to be deleted minutes later.

---

<div class="post-metadata">

**Author:** ![buchmann](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/buchmann/32/31_2.png) [@buchmann](https://community.openpbs.org/u/buchmann)\
**Post date:** [August 15, 2016, 6:06am UTC](https://community.openpbs.org/t/scheduler-and-jobs-that-can-never-run/213/4 "2016-08-15T06:06:04Z")

</div>

Thank you for the input.

> [@dilip-krishnan](#):
>
> writing such hook could be a very tedious task since there are many resources that needs to be accounted for.

That sounds like a lot of fun. Hopefully, I could write a hook, which do not take into account everything at one. I’ll have to read up on hooks before going down that path.

> [@dilip-krishnan](#):
>
> I think your idea of writing a script and removing jobs periodically, based on the set comment is best.

Could be. However, that will mean to implement a system-type daemon (or at the very least a cron-based script) to do it. This is also not trivial - especially for other/future admins to figure out why the heck jobs are being removed… I’ll give it careful thoughts.

On hooks:

> [@mkaro](#):
>
> user receives immediate feedback as opposed to having their job accepted, only to be deleted minutes later.

That would be a definite advantage, except that we do not have “traditional lusers” on our cluster. Rather, we run “operational” jobs, and we would much rather have a job fail (to try again later) than be stuck in the queue. If the job fails on submission or a few mins later is not a really big thing. As long as it fails.

Once again, your input is much appreciated. Thanks,

/Bjarne

---

<div class="post-metadata">

**Author:** ![buchmann](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/buchmann/32/31_2.png) [@buchmann](https://community.openpbs.org/u/buchmann)\
**Post date:** [August 15, 2016, 9:30am UTC](https://community.openpbs.org/t/scheduler-and-jobs-that-can-never-run/213/5 "2016-08-15T09:30:14Z")

</div>

Update,

> [@dilip-krishnan](#):
>
> I think your idea of writing a script and removing jobs periodically, based on the set comment is best.

After some testing, it appears that the comment may not be very well suited for this. Using the comment I cannot differentiate between jobs, which will run later (when resources are freed by presently running jobs), and jobs, which just ask for more resources, than what is available on any present node.  
In both cases, the comment will look like:

> Not Running: Insufficient amount of resource:

If I clearly request too many nodes (more than what is available totally), the comment becomes:

> Can Never Run: Not enough total nodes available

where it is clearly feasible to delete the job.

Thus, I wonder about alternative ways to do this (still without actually writing a HOOK to run at submission):  
As we run a small cluster with a very limited number of jobs in the queue at any time, I could estimate the job start time (set server est\_start\_time\_freq) often (eg every scheduling cycle), and then purge jobs, which do not have a set estimated start time?

Any ideas?

Thanks,

/Bjarne

PS: Presently, there seems to be an issue with estimating the start times, see [Qmgr -c 'set server est\_start\_time\_freq ...' fails](http://community.openpbs.org/t/qmgr-c-set-server-est-start-time-freq-fails/218) but hopefully that can be resolved.
