Page MenuHomePhabricator

Purge expired throttles
Closed, ResolvedPublic

Description

Need a way (automatically too?) to purge expired throttles

Event Timeline

Reedy created this task.Oct 4 2016, 9:20 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 4 2016, 9:20 PM
bd808 added a subscriber: bd808.Oct 4 2016, 9:25 PM

Maybe as trivially implemented as a differed or job that is posted after a throttle is checked?

Reedy added a comment.Oct 4 2016, 9:29 PM

DeferredUpdates would make sense, yeah. No wheel reinvention needed here

Reedy added a comment.Dec 12 2016, 4:00 PM

Current implementation just deletes that override IF it's no longer valid

		$conds = [
			"thr_range_start <= $quotedIp",
			"thr_range_end >= $quotedIp",
			'thr_type' . $dbr->buildLike( $dbr->anyString(), $action, $dbr->anyString() )
		];

 elseif ( $expiry !== false ) {
			// Expired exemption. Delete it from the DB.
			wfGetDB( DB_MASTER )->delete(
				'throttle_override',
				$conds,
				__METHOD__
			);
		}

Change 326454 had a related patch set uploaded (by Reedy):
Purge all expired Throttles when running pingLimiter

https://gerrit.wikimedia.org/r/326454

Change 326454 abandoned by Reedy:
Purge all expired Throttles when running pingLimiter

https://gerrit.wikimedia.org/r/326454

Reedy closed this task as Declined.Dec 12 2016, 4:10 PM

I just noticed in the List too...

		if ( !wfReadOnly() && !mt_rand( 0, 10 ) ) {
			// Purge expired entries on one in every 10 queries
			$dbw = wfGetDB( DB_MASTER );
			$method = __METHOD__;
			$dbw->onTransactionIdle( function() use ( $dbw, $method ) {
				$dbw->delete(
					'throttle_override',
					[
						$dbw->addIdentifierQuotes( 'thr_expiry' ) .
						' < ' .
						$dbw->addQuotes( $dbw->timestamp() )
					],
					$method
				);
			} );
		}
EddieGP changed the task status from Declined to Resolved.Nov 26 2017, 8:41 PM
EddieGP assigned this task to bd808.
EddieGP added a subscriber: EddieGP.

This was done in https://gerrit.wikimedia.org/r/#/c/392778/, related task is at T181025