r79021 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79020‎ | r79021 | r79022 >
Date:19:45, 26 December 2010
Author:laner
Status:reverted (Comments)
Tags:
Comment:
Adding maintenance script to purge stale flagged revs entries from memcached (for entries that have rev idsin the key). Should be made more generic.
Modified paths:
  • /trunk/phase3/maintenance/purgeStaleMemcachedFlaggedRevs.php (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/purgeStaleMemcachedFlaggedRevs.php
@@ -0,0 +1,39 @@
 2+<?php
 3+
 4+require_once( dirname( __FILE__ ) . '/commandLine.inc' );
 5+
 6+function purgeStaleMemcachedText() {
 7+ global $wgMemc, $wgDBname;
 8+ $db = wfGetDB( DB_MASTER );
 9+ $maxTextId = $db->selectField( 'text', 'max(old_id)' );
 10+ $latestReplicatedTextId = $db->selectField( array( 'recentchanges', 'revision' ), 'rev_text_id',
 11+ array( 'rev_id = rc_this_oldid', "rc_timestamp < '20101225183000'"), 'purgeStaleMemcachedText',
 12+ array( 'ORDER BY' => 'rc_timestamp DESC' ) );
 13+ $latestReplicatedTextId -= 100; # A bit of paranoia
 14+
 15+ echo "Going to purge text entries from $latestReplicatedTextId to $maxTextId in $wgDBname\n";
 16+
 17+ for ( $i = $latestReplicatedTextId; $i < $maxTextId; $i++ ) {
 18+ $keys = array();
 19+ $keys[] = wfMemcKey( 'flaggedrevs', 'countPending', $i );
 20+ $keys[] = wfMemcKey( 'flaggedrevs', 'includesSynced', $i );
 21+ $keys[] = wfMemcKey( 'flaggedrevs', 'overrideRedirect', $i );
 22+ $keys[] = wfMemcKey( 'unreviewedPages', 'underReview', $i );
 23+
 24+ foreach ( $keys as $key ) {
 25+ while (1) {
 26+ if (! $wgMemc->delete( $key ) ) {
 27+ echo "Memcache delete for $key returned false\n";
 28+ }
 29+ if ( $wgMemc->get( $key ) ) {
 30+ echo "There's still content in $key!\n";
 31+ } else {
 32+ break;
 33+ }
 34+ }
 35+ }
 36+ }
 37+}
 38+
 39+purgeStaleMemcachedText();
 40+

Follow-up revisions

RevisionCommit summaryAuthorDate
r85091This script didn't actually work, and was a live hack. This is a followup to ...laner21:16, 31 March 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   20:43, 26 December 2010

All of these keys actually use page ids here, not rev ids.

#Comment by Ryan lane (talk | contribs)   23:12, 26 December 2010

Oh well. This is why I'd have preferred a developer been around when I was looking at this problem.

#Comment by 😂 (talk | contribs)   22:22, 26 December 2010

More of a nitpick: FlaggedRevs maint script in phase3?

#Comment by Ryan lane (talk | contribs)   23:12, 26 December 2010

Even worse: this is a live hack. I was asked to commit it. I think we should keep live hacks somewhere outside of phase3.

#Comment by 😂 (talk | contribs)   23:14, 26 December 2010

That's what 1.16wmf4 is for ;-)

#Comment by Platonides (talk | contribs)   23:14, 26 December 2010

There's the deployment branch, tools, or extensions/FlaggedRevs ...

Status & tagging log