Page MenuHomePhabricator

Purge expired throttles
Closed, ResolvedPublic

Description

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

Event Timeline

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

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

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

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 subscribed.

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