[JobQueue] Do not count claimed jobs in isEmpty().
[lhc/web/wiklou.git] / includes / job / JobQueueDB.php
index 2f483ed..4d0f294 100644 (file)
@@ -49,15 +49,19 @@ class JobQueueDB extends JobQueue {
                        return false;
                }
 
-               $found = $this->getSlaveDB()->selectField(
-                       'job', '1', array( 'job_cmd' => $this->type ), __METHOD__
+               $found = $this->getSlaveDB()->selectField( // unclaimed job
+                       'job', '1', array( 'job_cmd' => $this->type, 'job_token' => '' ), __METHOD__
                );
 
                $wgMemc->add( $key, $found ? 'false' : 'true', self::CACHE_TTL );
+               return (bool)$found;
        }
 
        /**
         * @see JobQueue::doBatchPush()
+        * @param array $jobs
+        * @param $flags
+        * @throws DBError|Exception
         * @return bool
         */
        protected function doBatchPush( array $jobs, $flags ) {
@@ -366,6 +370,8 @@ class JobQueueDB extends JobQueue {
 
        /**
         * @see JobQueue::doAck()
+        * @param Job $job
+        * @throws MWException
         * @return Job|bool
         */
        protected function doAck( Job $job ) {
@@ -377,13 +383,16 @@ class JobQueueDB extends JobQueue {
                $dbw->commit( __METHOD__, 'flush' ); // flush existing transaction
 
                // Delete a row with a single DELETE without holding row locks over RTTs...
-               $dbw->delete( 'job', array( 'job_cmd' => $this->type, 'job_id' => $job->getId() ) );
+               $dbw->delete( 'job',
+                       array( 'job_cmd' => $this->type, 'job_id' => $job->getId() ), __METHOD__ );
 
                return true;
        }
 
        /**
         * @see JobQueue::doDeduplicateRootJob()
+        * @param Job $job
+        * @throws MWException
         * @return bool
         */
        protected function doDeduplicateRootJob( Job $job ) {