From 5562abd5246765c66ae87e44fb8481f24109aeb9 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 28 Feb 2006 05:24:52 +0000 Subject: [PATCH] Job::pop() may occasionally return false when there are actually more jobs remaining, but there is too much contention to efficiently delete one. runJobs can keep trying, as opposed to apache threads which should stop in this case. --- maintenance/archives/patch-profiling.sql | 15 +++++---- maintenance/cleanupSpam.php | 42 +++++++++++++++++++----- maintenance/clear_stats.php | 6 ++++ maintenance/commandLine.inc | 16 +++++---- maintenance/ourusers.php | 3 ++ maintenance/runJobs.php | 14 ++++---- 6 files changed, 68 insertions(+), 28 deletions(-) diff --git a/maintenance/archives/patch-profiling.sql b/maintenance/archives/patch-profiling.sql index 1b22778b5b..2b1f08afdf 100644 --- a/maintenance/archives/patch-profiling.sql +++ b/maintenance/archives/patch-profiling.sql @@ -1,10 +1,11 @@ -- profiling table -- This is optional -CREATE TABLE /*$wgDBprefix*/profiling ( - pf_count integer not null default 0, - pf_time float not null default 0, - pf_name varchar(255) not null default '', - UNIQUE KEY pf_name (pf_name) -); - +CREATE TABLE profiling ( + pf_count int(11) NOT NULL default '0', + pf_time float NOT NULL default '0', + pf_name varchar(255) NOT NULL default '', + pf_server varchar(30) NOT NULL default '', + UNIQUE KEY pf_name_server (pf_name,pf_server) +) TYPE=HEAP; + diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 01b1f631cb..65d6bc4d34 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -53,6 +53,9 @@ function cleanupArticle( $id, $domain ) { } //------------------------------------------------------------------------------ + + + $username = wfMsg( 'spambot_username' ); $fname = $username; $wgUser = User::newFromName( $username ); @@ -74,15 +77,36 @@ if ( !$like ) { $dbr =& wfGetDB( DB_SLAVE ); -$res = $dbr->select( 'externallinks', array( 'el_from' ), - array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname ); -$count = $dbr->numRows( $res ); -print "Found $count articles containing $spec\n"; -while ( $row = $dbr->fetchObject( $res ) ) { - cleanupArticle( $row->el_from, $spec ); -} -if ( $count ) { - print "Done\n"; +if ( $options['all'] ) { + // Clean up spam on all wikis + $dbr =& wfGetDB( DB_SLAVE ); + print "Finding spam on " . count($wgLocalDatabases) . " wikis\n"; + $found = false; + foreach ( $wgLocalDatabases as $db ) { + $count = $dbr->selectField( "`$db`.externallinks", 'COUNT(*)', + array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname ); + if ( $count ) { + $found = true; + passthru( "php cleanupSpam.php $db $spec | sed s/^/$db: /" ); + } + } + if ( $found ) { + print "All done\n"; + } else { + print "None found\n"; + } +} else { + // Clean up spam on this wiki + $res = $dbr->select( 'externallinks', array( 'DISTINCT el_from' ), + array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname ); + $count = $dbr->numRows( $res ); + print "Found $count articles containing $spec\n"; + while ( $row = $dbr->fetchObject( $res ) ) { + cleanupArticle( $row->el_from, $spec ); + } + if ( $count ) { + print "Done\n"; + } } ?> diff --git a/maintenance/clear_stats.php b/maintenance/clear_stats.php index 278c609c86..00cfd0ce2b 100644 --- a/maintenance/clear_stats.php +++ b/maintenance/clear_stats.php @@ -2,13 +2,19 @@ require_once('commandLine.inc'); foreach ( $wgLocalDatabases as $db ) { + noisyDelete("$db:stats:request_with_session"); + noisyDelete("$db:stats:request_without_session"); noisyDelete("$db:stats:pcache_hit"); noisyDelete("$db:stats:pcache_miss_invalid"); noisyDelete("$db:stats:pcache_miss_expired"); noisyDelete("$db:stats:pcache_miss_absent"); + noisyDelete("$db:stats:pcache_miss_stub"); noisyDelete("$db:stats:image_cache_hit"); noisyDelete("$db:stats:image_cache_miss"); noisyDelete("$db:stats:image_cache_update"); + noisyDelete("$db:stats:diff_cache_hit"); + noisyDelete("$db:stats:diff_cache_miss"); + noisyDelete("$db:stats:diff_uncacheable"); } function noisyDelete( $key ) { diff --git a/maintenance/commandLine.inc b/maintenance/commandLine.inc index c213a2edd8..f5b28d64ca 100644 --- a/maintenance/commandLine.inc +++ b/maintenance/commandLine.inc @@ -28,7 +28,7 @@ $optionsWithArgs[] = 'conf'; # For specifying the location of LocalSettings.php $self = array_shift( $argv ); $self = __FILE__; $IP = realpath( dirname( $self ) . '/..' ); -chdir( $IP ); +#chdir( $IP ); $options = array(); $args = array(); @@ -91,10 +91,11 @@ if (!isset( $wgUseNormalUser ) ) { if ( file_exists( '/home/wikipedia/common/langlist' ) ) { $wgWikiFarm = true; - require_once( $IP.'/includes/SiteConfiguration.php' ); + $cluster = trim( file_get_contents( '/etc/cluster' ) ); + require_once( "$IP/includes/SiteConfiguration.php" ); - # Get $conf - require( $IP.'/InitialiseSettings.php' ); + # Get $wgConf + require( "$IP/wgConf.php" ); if ( empty( $wgNoDBParam ) ) { # Check if we were passed a db name @@ -130,15 +131,17 @@ if ( file_exists( '/home/wikipedia/common/langlist' ) ) { $DP = $IP; ini_set( 'include_path', ".:$IP:$IP/includes:$IP/languages:$IP/maintenance" ); + require_once( $IP.'/includes/ProfilerStub.php' ); require_once( $IP.'/includes/Defines.php' ); require_once( $IP.'/CommonSettings.php' ); + $bin = '/home/wikipedia/bin'; if ( $wgUseRootUser ) { $wgDBuser = $wgDBadminuser = 'root'; - $wgDBpassword = $wgDBadminpassword = trim(`mysql_root_pass`); + $wgDBpassword = $wgDBadminpassword = trim(`$bin/mysql_root_pass`); } elseif ( !$wgUseNormalUser ) { $wgDBuser = $wgDBadminuser = 'wikiadmin'; - $wgDBpassword = $wgDBadminpassword = trim(`wikiadmin_pass`); + $wgDBpassword = $wgDBadminpassword = trim(`$bin/wikiadmin_pass`); } } else { $wgWikiFarm = false; @@ -155,6 +158,7 @@ if ( file_exists( '/home/wikipedia/common/langlist' ) ) { } $wgCommandLineMode = true; $DP = $IP; + require_once( $IP.'/includes/ProfilerStub.php' ); require_once( $IP.'/includes/Defines.php' ); require_once( $settingsFile ); ini_set( 'include_path', ".$sep$IP$sep$IP/includes$sep$IP/languages$sep$IP/maintenance" ); diff --git a/maintenance/ourusers.php b/maintenance/ourusers.php index 56464cdd30..241e15334c 100644 --- a/maintenance/ourusers.php +++ b/maintenance/ourusers.php @@ -45,6 +45,7 @@ if ( @$argv[1] == 'yaseo' ) { '207.142.131.197', '207.142.131.198', '207.142.131.199', + '207.142.131.221', '207.142.131.226', '207.142.131.227', '207.142.131.228', @@ -81,6 +82,7 @@ foreach( $hosts as $host ) { print "--\n-- $host\n--\n\n-- wikiuser\n\n"; print "GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n"; print "GRANT ALL PRIVILEGES ON `boardvote`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n"; + print "GRANT ALL PRIVILEGES ON `boardvote2005`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n"; foreach( $databases as $db ) { print "GRANT SELECT, INSERT, UPDATE, DELETE ON `$db`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n"; } @@ -110,6 +112,7 @@ EOS; print "\n-- wikiadmin\n\n"; print "GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'wikiadmin'@'$host' IDENTIFIED BY '$wikiadmin_pass';\n"; print "GRANT ALL PRIVILEGES ON `boardvote`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n"; + print "GRANT ALL PRIVILEGES ON `boardvote2005`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n"; foreach ( $databases as $db ) { print "GRANT ALL PRIVILEGES ON `$db`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n"; } diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index 799b9fac3a..3b63daa1e6 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -7,11 +7,13 @@ require_once( "$IP/includes/FakeTitle.php" ); // Trigger errors on inappropriate use of $wgTitle $wgTitle = new FakeTitle; -while ( false != ($job = Job::pop()) ) { - wfWaitForSlaves( 5 ); - print $job->toString() . "\n"; - if ( !$job->run() ) { - print "Error: {$job->error}\n"; +$dbw =& wfGetDB( DB_MASTER ); +while ( $dbw->selectField( 'job', 'count(*)', '', 'runJobs.php' ) ) { + while ( false != ($job = Job::pop()) ) { + wfWaitForSlaves( 5 ); + print $job->id . " " . $job->toString() . "\n"; + if ( !$job->run() ) { + print "Error: {$job->error}\n"; + } } } - -- 2.20.1