Merge "Remove removed message keys from maintenance files"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 2 Apr 2013 06:29:05 +0000 (06:29 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 2 Apr 2013 06:29:05 +0000 (06:29 +0000)
includes/User.php
includes/job/JobQueueRedis.php

index dc68502..9427a9e 100644 (file)
@@ -1969,28 +1969,29 @@ class User {
         * for reload on the next hit.
         */
        public function invalidateCache() {
-               if( wfReadOnly() ) {
+               if ( wfReadOnly() ) {
                        return;
                }
                $this->load();
-               if( $this->mId ) {
+               if ( $this->mId ) {
                        $this->mTouched = self::newTouchedTimestamp();
 
                        $dbw = wfGetDB( DB_MASTER );
-
-                       // Prevent contention slams by checking user_touched first
-                       $now = $dbw->timestamp( $this->mTouched );
-                       $needsPurge = $dbw->selectField( 'user', '1',
-                               array( 'user_id' => $this->mId, 'user_touched < ' . $dbw->addQuotes( $now ) )
-                       );
-                       if ( $needsPurge ) {
-                               $dbw->update( 'user',
-                                       array( 'user_touched' => $now ),
-                                       array( 'user_id' => $this->mId, 'user_touched < ' . $dbw->addQuotes( $now ) ),
-                                       __METHOD__
-                               );
-                       }
-
+                       $userid = $this->mId;
+                       $touched = $this->mTouched;
+                       $dbw->onTransactionIdle( function() use ( $dbw, $userid, $touched ) {
+                               // Prevent contention slams by checking user_touched first
+                               $encTouched = $dbw->addQuotes( $dbw->timestamp( $touched ) );
+                               $needsPurge = $dbw->selectField( 'user', '1',
+                                       array( 'user_id' => $userid, 'user_touched < ' . $encTouched ) );
+                               if ( $needsPurge ) {
+                                       $dbw->update( 'user',
+                                               array( 'user_touched' => $dbw->timestamp( $touched ) ),
+                                               array( 'user_id' => $userid, 'user_touched < ' . $encTouched ),
+                                               __METHOD__
+                                       );
+                               }
+                       } );
                        $this->clearSharedCache();
                }
        }
index d0901ef..c57081e 100644 (file)
@@ -615,8 +615,9 @@ LUA;
                        local released,abandoned,pruned = 0,0,0
                        -- Get all non-dead jobs that have an expired claim on them.
                        -- The score for each item is the last claim timestamp (UNIX).
-                       local staleClaims = redis.call('zRangeByScore',KEYS[1],0,ARGV[1],'WITHSCORES')
-                       for id,timestamp in ipairs(staleClaims) do
+                       local staleClaims = redis.call('zRangeByScore',KEYS[1],0,ARGV[1])
+                       for k,id in ipairs(staleClaims) do
+                               local timestamp = redis.call('zScore',KEYS[1],id)
                                local attempts = redis.call('hGet',KEYS[2],id)
                                if attempts < ARGV[3] then
                                        -- Claim expired and retries left: re-enqueue the job
@@ -632,8 +633,8 @@ LUA;
                        end
                        -- Get all of the dead jobs that have been marked as dead for too long.
                        -- The score for each item is the last claim timestamp (UNIX).
-                       local deadClaims = redis.call('zRangeByScore',KEYS[5],0,ARGV[2],'WITHSCORES')
-                       for id,timestamp in ipairs(deadClaims) do
+                       local deadClaims = redis.call('zRangeByScore',KEYS[5],0,ARGV[2])
+                       for k,id in ipairs(deadClaims) do
                                -- Stale and out of retries: remove any traces of the job
                                redis.call('zRem',KEYS[5],id)
                                redis.call('hDel',KEYS[2],id)