[JobQueue] Reduced deadlocks in claim() function.
* Split claim() into claimRandom() and claimOldest().
* Added a new SELECT+UPDATE method that will automatically be used if there are slaves.
This is what claimRandom() uses, which is the claim function used for random queues.
This can handle torture testing with dozens of processes using NullJob without deadlocks.
* Made claimOldest() work using the same method as the old claim() method. Doing SELECT
first won't really work that well in this case. The useless "job_random > 0" is now gone
from the query, which actually alleviates deadlock problems too. This method is used for
"timestamp" ordered queues.
Change-Id: Iaea96ff8eba2c918376f9465b54e9bbc3124f473