fix the scheduler to prevent starving situation

The situation happens when:
- worker A has a list of high priority jobs that requires resource a
- worker B has a list of low priority jobs that also requires resource a
- total resource for resource a is 2

In previous setup, worker B will never get any jobs done until worker
A finishes all its jobs.