Index: branches/wmf/1.17wmf1/includes/job/JobQueue.php |
— | — | @@ -63,6 +63,7 @@ |
64 | 64 | /* Ensure we "own" this row */ |
65 | 65 | $dbw->delete( 'job', array( 'job_id' => $row->job_id ), __METHOD__ ); |
66 | 66 | $affected = $dbw->affectedRows(); |
| 67 | + $dbw->commit(); |
67 | 68 | |
68 | 69 | if ( $affected == 0 ) { |
69 | 70 | wfProfileOut( __METHOD__ ); |
— | — | @@ -76,14 +77,8 @@ |
77 | 78 | $job = Job::factory( $row->job_cmd, $title, Job::extractBlob( $row->job_params ), |
78 | 79 | $row->job_id ); |
79 | 80 | |
80 | | - $dbw->delete( 'job', $job->insertFields(), __METHOD__ ); |
81 | | - $affected = $dbw->affectedRows(); |
82 | | - $dbw->commit(); |
| 81 | + $job->removeDuplicates(); |
83 | 82 | |
84 | | - if ( $affected ) { |
85 | | - wfIncrStats( 'job-dup-delete', $affected ); |
86 | | - } |
87 | | - |
88 | 83 | wfProfileOut( __METHOD__ ); |
89 | 84 | return $job; |
90 | 85 | } |
— | — | @@ -171,16 +166,8 @@ |
172 | 167 | $job = Job::factory( $row->job_cmd, $title, Job::extractBlob( $row->job_params ), $row->job_id ); |
173 | 168 | |
174 | 169 | // Remove any duplicates it may have later in the queue |
175 | | - // Deadlock prone section |
176 | | - $dbw->begin(); |
177 | | - $dbw->delete( 'job', $job->insertFields(), __METHOD__ ); |
178 | | - $affected = $dbw->affectedRows(); |
179 | | - $dbw->commit(); |
| 170 | + $job->removeDuplicates(); |
180 | 171 | |
181 | | - if ( $affected ) { |
182 | | - wfIncrStats( 'job-dup-delete', $affected ); |
183 | | - } |
184 | | - |
185 | 172 | wfProfileOut( __METHOD__ ); |
186 | 173 | return $job; |
187 | 174 | } |
— | — | @@ -297,6 +284,27 @@ |
298 | 285 | ); |
299 | 286 | } |
300 | 287 | |
| 288 | + /** |
| 289 | + * Remove jobs in the job queue which are duplicates of this job. |
| 290 | + * This is deadlock-prone and so starts its own transaction. |
| 291 | + */ |
| 292 | + function removeDuplicates() { |
| 293 | + if ( !$this->removeDuplicates ) { |
| 294 | + return; |
| 295 | + } |
| 296 | + |
| 297 | + $fields = $this->insertFields(); |
| 298 | + unset( $fields['job_id'] ); |
| 299 | + $dbw = wfGetDB( DB_MASTER ); |
| 300 | + $dbw->begin(); |
| 301 | + $dbw->delete( 'job', $fields, __METHOD__ ); |
| 302 | + $affected = $dbw->affectedRows(); |
| 303 | + $dbw->commit(); |
| 304 | + if ( $affected ) { |
| 305 | + wfIncrStats( 'job-dup-delete', $affected ); |
| 306 | + } |
| 307 | + } |
| 308 | + |
301 | 309 | function toString() { |
302 | 310 | $paramString = ''; |
303 | 311 | if ( $this->params ) { |
Property changes on: branches/wmf/1.17wmf1/includes/job/JobQueue.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
304 | 312 | Merged /trunk/phase3/includes/job/JobQueue.php:r83645 |