MediaWiki
1.34.0
|
Class for managing the deferred updates. More...
Static Public Member Functions | |
static | addCallableUpdate ( $callable, $stage=self::POSTSEND, $dbw=null) |
Add a callable update. More... | |
static | addUpdate (DeferrableUpdate $update, $stage=self::POSTSEND) |
Add an update to the deferred list to be run later by execute() More... | |
static | attemptUpdate (DeferrableUpdate $update, ILBFactory $lbFactory) |
Attempt to run an update with the appropriate transaction round state it expects. More... | |
static | clearPendingUpdates () |
Clear all pending updates without performing them. More... | |
static | doUpdates ( $mode='run', $stage=self::ALL) |
Do any deferred updates and clear the list. More... | |
static | getPendingUpdates ( $stage=self::ALL) |
static | pendingUpdatesCount () |
static | tryOpportunisticExecute ( $mode='run') |
Run all deferred updates immediately if there are no DB writes active. More... | |
Public Attributes | |
const | ALL = 0 |
const | BIG_QUEUE_SIZE = 100 |
const | POSTSEND = 2 |
const | PRESEND = 1 |
Static Protected Member Functions | |
static | handleUpdateQueue (array &$queue, $mode, $stage) |
Immediately run or enqueue a list of updates. More... | |
Static Private Member Functions | |
static | areDatabaseTransactionsActive () |
static | enqueueUpdates (array $updates) |
Enqueue a job for each EnqueueableDataUpdate item and return the other items. More... | |
static | jobify (EnqueueableDataUpdate $update, LBFactory $lbFactory, LoggerInterface $logger, StatsdDataFactoryInterface $stats, $httpMethod) |
Push a task into the job queue system and catch/log any exceptions. More... | |
static | push (array &$queue, DeferrableUpdate $update) |
static | run (DeferrableUpdate $update, LBFactory $lbFactory, LoggerInterface $logger, StatsdDataFactoryInterface $stats, $httpMethod) |
Run a task and catch/log any exceptions. More... | |
Static Private Attributes | |
static array null | $executeContext |
Information about the current execute() call or null if not running. More... | |
static DeferrableUpdate[] | $postSendUpdates = [] |
Updates to be deferred until after request end. More... | |
static DeferrableUpdate[] | $preSendUpdates = [] |
Updates to be deferred until before request end. More... | |
Class for managing the deferred updates.
In web request mode, deferred updates can be run at the end of the request, either before or after the HTTP response has been sent. In either case, they run after the DB commit step. If an update runs after the response is sent, it will not block clients. If sent before, it will run synchronously. These two modes are defined via PRESEND and POSTSEND constants, the latter being the default for addUpdate() and addCallableUpdate().
Updates that work through this system will be more likely to complete by the time the client makes their next request after this one than with the JobQueue system.
In CLI mode, deferred updates will run:
When updates are deferred, they go into one two FIFO "top-queues" (one for pre-send and one for post-send). Updates enqueued during doUpdate() of a "top" update go into the "sub-queue" for that update. After that method finishes, the sub-queue is run until drained. This continues for each top-queue job until the entire top queue is drained. This happens for the pre-send top-queue, and later on, the post-send top-queue, in execute().
Definition at line 62 of file DeferredUpdates.php.
|
static |
Add a callable update.
In a lot of cases, we just need a callback/closure, defining a new DeferrableUpdate object is not necessary
callable | $callable | |
int | $stage | DeferredUpdates constant (PRESEND or POSTSEND) (since 1.27) |
IDatabase | IDatabase[] | null | $dbw | Abort if this DB is rolled back optional |
Definition at line 124 of file DeferredUpdates.php.
References addUpdate(), and wfGetCaller().
Referenced by MediaWiki\Auth\AuthManager\autoCreateUser(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider\beginPrimaryAuthentication(), SpecialEditWatchlist\cleanupWatchlist(), User\clearNotification(), FileBackendMultiWrite\doDirectoryOp(), LinksDeletionUpdate\doIncrementalUpdate(), FileBackendMultiWrite\doOperationsInternal(), FileBackendMultiWrite\doQuickOperationsInternal(), MediaWiki\Storage\DerivedPageDataUpdater\doUpdates(), WikiPage\doViewUpdates(), EditPage\edit(), RollbackAction\enableTransactionalTimelimit(), ApiRollback\execute(), MovePageForm\execute(), MediaWiki\Logger\Monolog\BufferHandler\handle(), Category\initialize(), UserGroupMembership\insert(), WikiPage\insertRedirect(), LocalFile\maybeUpgradeRow(), RecentChange\notifyEdit(), RecentChange\notifyNew(), WikiPage\onArticleEdit(), ManualLogEntry\publish(), WikiPage\purgeInterwikiCheckKey(), MediaWiki\Session\SessionBackend\save(), SpecialSearch\saveNamespaces(), MediaWiki\Storage\PageUpdater\saveRevision(), Pingback\schedulePingback(), RevDelList\setVisibility(), MediaWiki\Block\BlockManager\trackBlockWithCookie(), WikiPage\updateCategoryCounts(), WatchedItemStore\updateNotificationTimestamp(), and EditPage\updateWatchlist().
|
static |
Add an update to the deferred list to be run later by execute()
In CLI mode, callback magic will also be used to run updates when safe
DeferrableUpdate | $update | Some object that implements doUpdate() |
int | $stage | DeferredUpdates constant (PRESEND or POSTSEND) (since 1.27) |
Definition at line 85 of file DeferredUpdates.php.
References $wgCommandLineMode, push(), and tryOpportunisticExecute().
Referenced by addCallableUpdate(), MediaWiki\Auth\AuthManager\autoCreateUser(), MediaWiki\Auth\AuthManager\continueAccountCreation(), LocalFile\delete(), LocalFile\deleteOld(), MediaWiki\Storage\PageUpdater\doCreate(), WikiPage\doDeleteUpdates(), MediaWiki\Storage\PageUpdater\doModify(), RevDelFileList\doPostCommitUpdates(), WikiPage\doPurge(), MediaWiki\Storage\DerivedPageDataUpdater\doSecondaryDataUpdates(), LinksUpdate\doUpdate(), MediaWiki\Storage\DerivedPageDataUpdater\doUpdates(), SpecialRunJobs\execute(), LocalFileRestoreBatch\execute(), ChangesListSpecialPage\execute(), WikiImporter\finishImportPage(), User\incEditCount(), Title\invalidateCache(), PurgeJobUtils\invalidatePages(), JobQueueGroup\lazyPush(), NamespaceDupes\mergePage(), LocalFile\move(), MovePage\moveUnsafe(), LocalFile\purgeCache(), MediaWiki\Block\DatabaseBlock\purgeExpired(), Title\purgeExpiredRestrictions(), LocalFile\purgeOldThumbnails(), Title\purgeSquid(), LocalFile\purgeThumbnails(), LocalFile\recordUpload2(), and MessageCache\replace().
|
staticprivate |
Definition at line 479 of file DeferredUpdates.php.
References Wikimedia\Rdbms\IDatabase\explicitTrxActive(), Wikimedia\Rdbms\LoadBalancer\forEachOpenMasterConnection(), and Wikimedia\Rdbms\IDatabase\writesOrCallbacksPending().
|
static |
Attempt to run an update with the appropriate transaction round state it expects.
DeferredUpdate classes that wrap the execution of bundles of other DeferredUpdate instances can use this method to run the updates. Any such wrapper class should always use TRX_ROUND_ABSENT itself.
DeferrableUpdate | $update | |
ILBFactory | $lbFactory |
Definition at line 356 of file DeferredUpdates.php.
References Wikimedia\Rdbms\ILBFactory\beginMasterChanges(), Wikimedia\Rdbms\ILBFactory\commitMasterChanges(), DeferrableUpdate\doUpdate(), Wikimedia\Rdbms\ILBFactory\getEmptyTransactionTicket(), and Wikimedia\Rdbms\ILBFactory\hasTransactionRound().
Referenced by MediaWiki\Storage\DerivedPageDataUpdater\doSecondaryDataUpdates(), and run().
|
static |
Clear all pending updates without performing them.
Generally, you don't want or need to call this. Unit tests need it though.
Definition at line 471 of file DeferredUpdates.php.
|
static |
Do any deferred updates and clear the list.
If $stage is self::ALL then the queue of PRESEND updates will be resolved, followed by the queue of POSTSEND updates
string | $mode | Use "enqueue" to use the job queue when possible [Default: "run"] |
int | $stage | DeferredUpdates constant (PRESEND, POSTSEND, or ALL) (since 1.27) |
Definition at line 139 of file DeferredUpdates.php.
References ALL, and handleUpdateQueue().
Referenced by JobRunner\executeJob(), RefreshLinks\fixLinksFromArticle(), NamespaceDupes\mergePage(), MediaWiki\preOutputCommit(), MediaWiki\restInPeace(), and tryOpportunisticExecute().
|
staticprivate |
Enqueue a job for each EnqueueableDataUpdate item and return the other items.
DeferrableUpdate[] | $updates | A list of deferred update instances |
Definition at line 427 of file DeferredUpdates.php.
References JobQueueGroup\singleton().
Referenced by tryOpportunisticExecute().
|
static |
int | $stage | DeferredUpdates constant (PRESEND, POSTSEND, or ALL) |
Definition at line 456 of file DeferredUpdates.php.
|
staticprotected |
Immediately run or enqueue a list of updates.
DeferrableUpdate[] | &$queue | List of DeferrableUpdate objects |
string | $mode | Either "run" or "enqueue" (to use the job queue when possible) |
int | $stage | Class constant (PRESEND, POSTSEND) (since 1.28) |
ErrorPageError | Happens on top-level calls |
Exception | Happens on second-level calls |
Definition at line 187 of file DeferredUpdates.php.
References $queue, RequestContext\getMain(), jobify(), and run().
Referenced by doUpdates().
|
staticprivate |
Push a task into the job queue system and catch/log any exceptions.
EnqueueableDataUpdate | $update | |
LBFactory | $lbFactory | |
LoggerInterface | $logger | |
StatsdDataFactoryInterface | $stats | |
string | $httpMethod |
Definition at line 315 of file DeferredUpdates.php.
References EnqueueableDataUpdate\getAsJobSpecification(), Wikimedia\Rdbms\LBFactory\rollbackMasterChanges(), and JobQueueGroup\singleton().
Referenced by handleUpdateQueue().
|
static |
Definition at line 447 of file DeferredUpdates.php.
Referenced by tryOpportunisticExecute().
|
staticprivate |
DeferrableUpdate[] | $queue | |
DeferrableUpdate | $update |
Definition at line 158 of file DeferredUpdates.php.
References $queue.
Referenced by addUpdate().
|
staticprivate |
Run a task and catch/log any exceptions.
DeferrableUpdate | $update | |
LBFactory | $lbFactory | |
LoggerInterface | $logger | |
StatsdDataFactoryInterface | $stats | |
string | $httpMethod |
Definition at line 268 of file DeferredUpdates.php.
References attemptUpdate(), and Wikimedia\Rdbms\LBFactory\rollbackMasterChanges().
Referenced by handleUpdateQueue().
|
static |
Run all deferred updates immediately if there are no DB writes active.
If there are many deferred updates pending, $mode is 'run', and there are still busy LBFactory database handles, then any EnqueueableDataUpdate tasks might be enqueued as jobs to be executed later.
string | $mode | Use "enqueue" to use the job queue when possible |
Definition at line 399 of file DeferredUpdates.php.
References doUpdates(), enqueueUpdates(), and pendingUpdatesCount().
Referenced by addUpdate(), and Maintenance\setLBFactoryTriggers().
|
staticprivate |
Information about the current execute() call or null if not running.
Definition at line 75 of file DeferredUpdates.php.
|
staticprivate |
Updates to be deferred until after request end.
Definition at line 66 of file DeferredUpdates.php.
|
staticprivate |
Updates to be deferred until before request end.
Definition at line 64 of file DeferredUpdates.php.
const DeferredUpdates::ALL = 0 |
Definition at line 68 of file DeferredUpdates.php.
Referenced by doUpdates().
const DeferredUpdates::BIG_QUEUE_SIZE = 100 |
Definition at line 72 of file DeferredUpdates.php.
const DeferredUpdates::POSTSEND = 2 |
Definition at line 70 of file DeferredUpdates.php.
Referenced by MediaWiki\Storage\DerivedPageDataUpdater\doSecondaryDataUpdates(), SpecialRunJobs\execute(), RefreshLinks\fixLinksFromArticle(), User\incEditCount(), WikiPage\insertRedirect(), RecentChange\notifyEdit(), RecentChange\notifyNew(), ManualLogEntry\publish(), and WatchedItemStore\updateNotificationTimestamp().
const DeferredUpdates::PRESEND = 1 |
Definition at line 69 of file DeferredUpdates.php.
Referenced by LocalFile\delete(), LocalFile\deleteOld(), MediaWiki\Storage\PageUpdater\doCreate(), MediaWiki\Storage\PageUpdater\doModify(), RevDelFileList\doPostCommitUpdates(), WikiPage\doPurge(), MediaWiki\Storage\DerivedPageDataUpdater\doSecondaryDataUpdates(), WikiPage\doViewUpdates(), ApiPurge\execute(), Title\invalidateCache(), LocalFile\move(), MediaWiki\preOutputCommit(), LocalFile\purgeCache(), LocalFile\purgeOldThumbnails(), Title\purgeSquid(), LocalFile\purgeThumbnails(), LocalFile\recordUpload2(), MessageCache\replace(), RevDelList\setVisibility(), and MediaWiki\Block\BlockManager\trackBlockWithCookie().