[JobQueue] Fixed de-listing updates to pending job cache.
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 15 Nov 2012 08:49:48 +0000 (00:49 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 15 Nov 2012 08:54:39 +0000 (00:54 -0800)
Change-Id: Ied0f2962fcbcde62a041592933c667c861f54715

maintenance/nextJobDB.php

index 875b93d..d8480f3 100644 (file)
@@ -81,17 +81,19 @@ class nextJobDB extends Maintenance {
                        $candidates = array_values( $candidates );
                        $db = $candidates[ mt_rand( 0, count( $candidates ) - 1 ) ];
                        if ( !$this->checkJob( $type, $db ) ) {
-                               // This job is not available in the current database. Remove it from
-                               // the cache.
                                if ( $type === false ) {
+                                       // There are no jobs available in the current database
                                        foreach ( $pendingDBs as $type2 => $dbs ) {
                                                $pendingDBs[$type2] = array_diff( $pendingDBs[$type2], array( $db ) );
                                        }
                                } else {
+                                       // There are no jobs of this type available in the current database
                                        $pendingDBs[$type] = array_diff( $pendingDBs[$type], array( $db ) );
                                }
-
-                               $wgMemc->set( $memcKey, $pendingDBs, 300 );
+                               // Update the cache to remove the outdated information
+                               $pendingDbInfo['pendingDBs'] = $pendingDBs;
+                               // @TODO: fix race condition with these updates
+                               $wgMemc->set( $memcKey, $pendingDbInfo );
                                $again = true;
                        }
                } while ( $again );