Add $wgCdnReboundPurgeDelay for more consistent CDN purges
Bug: T113192 Change-Id: I89deb4f8143c1cc6154cdd05bcee1f49d3e3a75a
This commit is contained in:
parent
922d05c75c
commit
01c2b0a425
5 changed files with 79 additions and 8 deletions
|
|
@ -97,6 +97,8 @@ production.
|
|||
* $wgMaxUserDBWriteDuration added to limit huge user-generated transactions.
|
||||
Regular web request transactions that takes longer than this are aborted.
|
||||
* Added a new hook, 'TitleMoveCompleting', which runs before a page move is committed.
|
||||
* $wgCdnReboundPurgeDelay was added to provide secondary delayed purges of URLs
|
||||
from CDN to mitigate DB replication lag and WAN cache purge lag.
|
||||
|
||||
=== External library changes in 1.27 ===
|
||||
==== Upgraded external libraries ====
|
||||
|
|
|
|||
|
|
@ -200,6 +200,7 @@ $wgAutoloadLocalClasses = array(
|
|||
'CdbReader' => __DIR__ . '/includes/compat/CdbCompat.php',
|
||||
'CdbWriter' => __DIR__ . '/includes/compat/CdbCompat.php',
|
||||
'CdnCacheUpdate' => __DIR__ . '/includes/deferred/CdnCacheUpdate.php',
|
||||
'CdnPurgeJob' => __DIR__ . '/includes/jobqueue/jobs/CdnPurgeJob.php',
|
||||
'CentralIdLookup' => __DIR__ . '/includes/user/CentralIdLookup.php',
|
||||
'CgzCopyTransaction' => __DIR__ . '/maintenance/storage/recompressTracked.php',
|
||||
'ChangePassword' => __DIR__ . '/maintenance/changePassword.php',
|
||||
|
|
|
|||
|
|
@ -2600,6 +2600,15 @@ $wgSquidMaxage = 18000;
|
|||
*/
|
||||
$wgCdnMaxageLagged = 30;
|
||||
|
||||
/**
|
||||
* If set, any SquidPurge call on a URL or URLs will send a second purge no less than
|
||||
* this many seconds later via the job queue. This requires delayed job support.
|
||||
* This should be safely higher than the 'max lag' value in $wgLBFactoryConf.
|
||||
*
|
||||
* @since 1.27
|
||||
*/
|
||||
$wgCdnReboundPurgeDelay = 0;
|
||||
|
||||
/**
|
||||
* Default maximum age for raw CSS/JS accesses
|
||||
*
|
||||
|
|
@ -6689,10 +6698,11 @@ $wgJobClasses = array(
|
|||
'PublishStashedFile' => 'PublishStashedFileJob',
|
||||
'ThumbnailRender' => 'ThumbnailRenderJob',
|
||||
'recentChangesUpdate' => 'RecentChangesUpdateJob',
|
||||
'refreshLinksPrioritized' => 'RefreshLinksJob', // for cascading protection
|
||||
'refreshLinksDynamic' => 'RefreshLinksJob', // for pages with dynamic content
|
||||
'refreshLinksPrioritized' => 'RefreshLinksJob',
|
||||
'refreshLinksDynamic' => 'RefreshLinksJob',
|
||||
'activityUpdateJob' => 'ActivityUpdateJob',
|
||||
'categoryMembershipChange' => 'CategoryMembershipChangeJob',
|
||||
'cdnPurge' => 'CdnPurgeJob',
|
||||
'enqueue' => 'EnqueueJob', // local queue for multi-DC setups
|
||||
'null' => 'NullJob'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
|
|||
$this->urls = $urlArr;
|
||||
}
|
||||
|
||||
public function merge( MergeableUpdate $update ) {
|
||||
/** @var CdnCacheUpdate $update */
|
||||
Assert::parameterType( __CLASS__, $update, '$update' );
|
||||
|
||||
$this->urls = array_merge( $this->urls, $update->urls );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an update object from an array of Title objects, or a TitleArray object
|
||||
*
|
||||
|
|
@ -67,14 +74,19 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
|
|||
* Purges the list of URLs passed to the constructor.
|
||||
*/
|
||||
public function doUpdate() {
|
||||
global $wgCdnReboundPurgeDelay;
|
||||
|
||||
self::purge( $this->urls );
|
||||
}
|
||||
|
||||
public function merge( MergeableUpdate $update ) {
|
||||
/** @var CdnCacheUpdate $update */
|
||||
Assert::parameterType( __CLASS__, $update, '$update' );
|
||||
|
||||
$this->urls = array_merge( $this->urls, $update->urls );
|
||||
if ( $wgCdnReboundPurgeDelay > 0 ) {
|
||||
JobQueueGroup::singleton()->lazyPush( new CdnPurgeJob(
|
||||
Title::makeTitle( NS_SPECIAL, 'Badtitle/' . __CLASS__ ),
|
||||
array(
|
||||
'urls' => $this->urls,
|
||||
'jobReleaseTimestamp' => time() + $wgCdnReboundPurgeDelay
|
||||
)
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
46
includes/jobqueue/jobs/CdnPurgeJob.php
Normal file
46
includes/jobqueue/jobs/CdnPurgeJob.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* Job to purge a set of URLs from CDN
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* @file
|
||||
* @ingroup JobQueue
|
||||
*/
|
||||
|
||||
/**
|
||||
* Job to purge a set of URLs from CDN
|
||||
*
|
||||
* @ingroup JobQueue
|
||||
* @since 1.27
|
||||
*/
|
||||
class CdnPurgeJob extends Job {
|
||||
/**
|
||||
* @param Title $title
|
||||
* @param array $params Job parameters (urls)
|
||||
*/
|
||||
function __construct( Title $title, array $params ) {
|
||||
parent::__construct( 'cdnPurge', $title, $params );
|
||||
$this->removeDuplicates = false; // delay semantics are critical
|
||||
}
|
||||
|
||||
public function run() {
|
||||
// Use purge() directly to avoid infinite recursion
|
||||
CdnCacheUpdate::purge( $this->params['urls'] );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue