Commit graph

58 commits

Author SHA1 Message Date
jenkins-bot
4ddc1da854 Merge "Make MergeableUpdate jobs avoid the sub-queue so they can always merge" 2018-10-12 01:13:29 +00:00
Aaron Schulz
f61868f13d Make MergeableUpdate jobs avoid the sub-queue so they can always merge
Change-Id: I5b100fae29b785ab4524d165dad2e8ee46406b0c
2018-10-12 00:36:39 +00:00
Aaron Schulz
9fb67b9a41 Make merged MergeableUpdate items always go to the end of the queue
Change-Id: I2e8aa28f7426470d9b8b9e11b902deea793069b3
2018-10-11 14:51:36 -07:00
James D. Forrester
054d5ff1a1 Drop DeferredUpdates::setImmediateMode(), deprecated since 1.29
Change-Id: I8ae7dedf956034981081d2bcec630d6724921269
2018-10-10 15:30:00 -07:00
Aaron Schulz
a79b9737f1 Make DeferredUpdates avoid running during LBFactory::commitMasterChanges
Bug: T193668
Change-Id: I50890ef17ea72481a14c4abcd93ae58b93f15d28
2018-05-03 15:11:38 -07:00
daniel
a430307fad Make DeferredUpdates re-throw exceptions during testing.
This is a stop-gap solution for the problem described in T190178.
A better solution would probably include changing the behavior
of LegacyLogger.

Bug: T190178
Change-Id: I433be04b8ee725becd174e567270aa674d2661df
2018-05-02 21:16:05 +00:00
Stephane Bisson
b5ea51dce6 Fix typehint for multiple dbs in addCallableUpdate
Change-Id: Ic4fe6c529d9394cfd0c8c8652a28f47973342096
Follow-up: I0371ecd20101c5e622497e5912676300b040865e
2018-02-13 15:50:49 -05:00
Timo Tijhof
6b2f8639b6 deferred: Introduce TransactionRoundDefiningUpdate
This allows scheduling of updates that need to start their own
transaction round. Specifically for cases where the ability to
commit early is not enough (which is already possible via LBFactory
getEmptyTransactionTicket and commitAndWaitForReplication).

Change-Id: I0910587b61c8ddf825f91e92c2f93582cc7ebd80
2017-10-13 21:24:11 +00:00
Kunal Mehta
0cb2a09b6d Always put type information before variable name for @var tags
Like other tags, @var should have the type information before the
variable name.

<https://docs.phpdoc.org/references/phpdoc/tags/var.html>

Change-Id: I9eca6957b1990fa8cc687103dc02ee38af5f9086
2017-09-04 11:06:51 -07:00
Umherirrender
3f1a52805e Use short type bool/int in param documentation
Enable the phpcs sniffs for this and used phpcbf

Change-Id: Iaa36687154ddd2bf663b9dd519f5c99409d37925
2017-08-20 13:20:59 +02:00
Aaron Schulz
3daad1264b Push all DeferredUpdates to POSTSEND queue when running that queue
This avoids putting updates in the PRESEND queue at a point where they
may never get run later in the request. The peculiarity lead to a
regression in 24842cfac.

Move "enqueue" logic to runUpdate() to simplify execute(). If job
insertion batching is strongly desired for a class, then it can use
MergeableUpdate.

Removed unused "update" field in $executeContext.

Bug: T168723
Change-Id: I40d16f6cd0adc8583797b99d859b76a836d362a8
2017-07-06 14:10:17 -07:00
Aaron Schulz
95fdff36c2 Make DeferredUpdates detect LBFactory transaction rounds
Previously, tryOpportunisticExecute() tried to nest transaction rounds,
which would fail. Added LBFactory::hasTransactionRound() as needed.

Also cleaned up some unqualified class names in callbacks and set the
PRESEND flag for the JobQueueDB AutoCommitUpdate callback. Use the
proper getMasterDB() method while at it. These follow up 24842cfac.

Bug: T154425
Change-Id: Ib1d38f68bd217903d1a7d46fb15b7d7d9620daa6
2017-06-10 15:22:32 +00:00
Aaron Schulz
c769e3f3e4 Add missing return value to getPendingUpdates() docs
Change-Id: I917a2eb97e6e99ccc895245b84717ba40b0c88f6
2017-06-01 21:10:44 -07:00
Seb35
d80fca05e1 Better handling of jobs execution in post-connection shutdown
In the postprocessing, some jobs can be executed but given the deferred
updates were already "closed", any new DeferredUpdate were directly called
(as explained by Krinkle on T165714), and the transactions opened by
classical jobs are badly mixed with transactions (directly) executed by
DeferredUpdates jobs, issuing a DBError, avoiding the job, which stays
in a 'claimed' status even if failed.

Quite similarly, some DeferredUpdates callables use JobQueueGroup::lazyPush
so it is needed to really push the generated jobs.

This change removes the run-immediately-deferred-updates behaviour even
in the post-connection shutdown, and given there is a call to
DeferredUpdates::doUpdates in JobRunner::execute it is not necessary to
add another one and hence execution of Web jobs is more similar to execution
of CLI jobs. In the same spirit to reconcile Web jobs and CLI jobs, the
call to JobQueueGroup::pushLazyJobs is done in JobRunner::execute.

Bug: T165714
Bug: T100085
Change-Id: I721e7167eca5b0b6227234fe516005243ab22388
2017-06-01 13:16:08 +02:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
Antoine Musso
8357fe9e98 Add accessor to DeferredUpdates
Updates are stored in private variables which is not convenient when
testing deferred updates.  Add a getPendingUpdates() accessor. The stage
can be specified to only retrieve PRE or POST ones.

Change-Id: I1af730ec5e48bc0be555a8db4611a76eb9332444
2017-03-03 13:32:05 +00:00
Aaron Schulz
64df456b39 Move remaining LoadBalancer classes to Rdbms
The old names are left as aliases.

Change-Id: I52a327f2463a2ba7437324047b5b00d28cd1d758
2017-02-23 20:38:31 -08:00
Aaron Schulz
4a177b34ef Move LBFactory to Rdbms namespace
Change-Id: I5ae10783228d0252284807c9562bc8e328d4becb
2017-02-03 17:24:03 -08:00
Aaron Schulz
4a2085523f Make SessionBackend::save() update the user post-send
Bug: T92357
Change-Id: Id4f4991aca1ceeb74b59e980f09863041246a4fc
2016-10-12 11:14:45 -07:00
Aaron Schulz
c5cba0ea15 Call setTransactionTicket() on DeferredUpdates sub-queue items too
This should lower the rate of "does not have outer scope" log
warnings in DBPerformance.

Also add traces to such logs.

Change-Id: I7d21ea745cae07e0fbbe4cd8de82e93f1d10e0a5
2016-09-22 17:03:56 -07:00
Aaron Schulz
d1e15787bd Make DeferredUpdates call setTransactionTicket() on all DataUpdate tasks
This assues that things like LinksUpdate/LinksDeletionUpdate will
have a proper ticket for commitAndWaitForReplication()

Change-Id: I8234510efb706394c39c4027ddf54ace76983aa9
2016-09-12 21:48:51 -07:00
Aaron Schulz
148f7bf0d1 Make DeferredUpdates::execute() protected
Update the only caller, which is a deprecated wrapper method.
Locking down this internal method makes it secure against
misuse with regards to recursion checks.

Change-Id: I3ed52dbe4c0ad52c7b5de92e81bfdc98a1737bcf
2016-09-13 04:11:24 +00:00
jenkins-bot
f9676b1950 Merge "Clarify and update DeferredUpdates docs" 2016-09-07 06:56:40 +00:00
Aaron Schulz
3642142dd0 Clarify and update DeferredUpdates docs
Follows-up dc0cdc8a4d

Change-Id: Ib70585d9d10f6f6493a625697243e0a67796c272
2016-09-07 06:48:49 +00:00
Aaron Schulz
b8b4f12663 Make deferred updates fully own their transaction rounds
This will matter when commitMasterChanges() enforcement is tighter.
For now, any thing can still call that method anytime.

Change-Id: I0b08e9e9118a6c6118c117e3856d0a8e0ca3d457
2016-09-03 06:44:31 -07:00
Aaron Schulz
dc0cdc8a4d Make DeferredUpdates able to run DataUpdates
* Also make ErrorPageError exceptions display themselves
  in PRESEND mode. Before they were always suppressed.
* Make DataUpdate::runUpdates() simply wrap
  DeferredUpdates::execute().
* Remove unused installDBListener() method, which was
  basically moved to Maintenance.
* Enable DBO_TRX for DeferredUpdates::execute() in CLI mode
* Also perform sub-DeferrableUpdate jobs right after their
  parent for better transaction locality.
* Made rollbackMasterChangesAndLog() clear all master
  transactions/rounds, even if there are no changes yet.
  This keeps the state cleaner for continuing.
* For sanity, avoid calling acquirePageLock() in link updates
  unless the transaction ticket is set. These locks are
  already redundant and weaker in range than the locks the
  Job classes that run them get. This helps guard against
  DBTransactionError.
* Renamed $type to $stage to be more clear about the order.

Change-Id: I1e90b56cc80041d70fb9158ac4f027285ad0f2c9
2016-09-02 04:12:50 +00:00
Aaron Schulz
ce504f2d19 Move run-on-add logic in DeferredUpdates to addUpdate()
Change-Id: I1b3ec21e07549f7250fa497f352fe1c131ddc88a
2016-09-02 00:02:53 +00:00
Aaron Schulz
c1ebcb0ee2 Remove $recursionGuard var from tryOpportunisticExecute()
Aside from there being no idle callback setting here, the
old addUpdate() code that runs updates allows nesting updates.
Make this support that for a few transitional commits. It will
be changed later to simply order the sub-updates after their
parent updates, keeping both outer scope for all updates and
locality of related updates.

Change-Id: I0ad4e9713a7893b981b7bb013e9db803eed663b2
2016-09-01 22:56:45 +00:00
Aaron Schulz
44f486ffac Use transaction listener to run DeferredUpdates in CLI mode
This sets triggers on master position waits typically called
after commitMasterChanges() or in commitAndWaitForReplication().

Change-Id: I127a8fe3cfc319abfa84fcd221ee2dae191c6d3b
2016-09-01 03:30:00 +00:00
Aaron Schulz
32a8eb1822 Make various MWCallableUpdate usages rollback-safe
Support for this added to MWCallableUpdate and its helper method
in DeferredUpdates.

Bug: T141988
Change-Id: Ief150ea655036e2708557dd8ae847379edf21933
2016-08-15 00:47:42 -07:00
Aaron Schulz
16ad2a779e Make statsd counts for MWCallableUpdate actually useful
Include the method that made the callback in the key.

Change-Id: Ifc7c486ee5c8d57b2516456569bb724cf7dc2b99
2016-07-21 23:52:09 -07:00
Aaron Schulz
67f74dcdb2 Add statsd logging of DeferredUpdates
Bug: T137326
Change-Id: Icce439210c6412c1824d8d5c411880825bb05643
2016-06-18 11:24:01 -07:00
Aaron Schulz
8d84be66f6 Do not let DataUpdate exceptions block other deferred updates
Change-Id: Ida563b29b5450c44358155fc937cd7eeb87090c2
2016-04-26 14:06:51 -07:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Aaron Schulz
58cffd04b8 Pass __METHOD__ to load balancer commit/rollback methods
Change-Id: I3fd87908c2a493fae49de6a29efe79f8d433c112
2015-12-22 18:30:20 -08:00
Aaron Schulz
d2c33200f7 Remove DeferredUpdates::forceDeferral() testing hack
Change-Id: I7f2ad8190e1a746b6c39190b86fa9c83c5b921fe
2015-12-04 21:18:29 +00:00
Aaron Schulz
99610822d8 Add mergeable update support DeferredUpdates
* DeferrableUpdate classes can implement MergeableUpdate.
  Duplicate updates will be merged via the merge() method.
* Make SquidUpdate support merge() so that duplicate URL
  purges are now caught accross the entire pre-send request
  execution.

Change-Id: Idffdd3e71d89e4a0f28281e65a881113caae497c
2015-12-04 19:08:51 +00:00
Aaron Schulz
34dd248e28 Add pre-send update support to DeferredUpdates
* PRESEND/POSTSEND constants can now be used in addUpdate()
  and addCallableUpdate() to control when the update runs.
  This is useful for updates that may report errors the client
  should see or to just get a head start on queued or pubsub
  based updates like CDN purges. The OutputPage::output() method
  can easily take a few 100ms.
* Removed some argument b/c code from doUpdates().
* Also moved DeferrableUpdate to a separate file.

Change-Id: I9831fe890f9f68f9ad8c4f4bba6921a8f29ba666
2015-12-04 19:08:27 +00:00
Aaron Schulz
9bb575be70 Make DeferredUpdates exception handling more robust
Change-Id: Ica2b8dce0978818a2f51684b97c93a3ba845d81a
2015-11-03 13:05:41 -08:00
Aaron Schulz
a8590172c8 Make DeferredUpdates::doUpdates always commit per task
* All callers are either using commit already or would be fine
  using it (e.g. Maintenance scripts and JobRunner that have
  no real transaction open).

Change-Id: I9f54b27619da6dac2cb63d255995aabc4ee78002
2015-10-22 01:27:08 +00:00
jenkins-bot
0e1c391d97 Merge "Change 1.26 to 1.27, mostly in doc comments" 2015-10-10 17:01:23 +00:00
Aaron Schulz
1846e2dc15 Made LinksUpdate on edit use the job queue
* LinksUpdate is now an EnqueueableDataUpdate
  and can yeild a prioritzed refreshLinks job.
* DeferredUpdates::runUpdates() now takes an enqueue
  flag to try to use jobs. This is set in restInPeace().
  Updates that change many links will be less likely to
  increase lag, as the runners are more strict about that.
* Also made the LinksDeletionUpdate job enqueue happen
  post-send on page deletion for consistency

Bug: T95501
Change-Id: I8863caef9c8f03234699d33e4d47d2310a0c8446
2015-10-08 01:02:03 -07:00
Aaron Schulz
ccab8f10f6 Make DeferredUpdates::doUpdates use DataUpdate::runUpdates
All DataUpdate objects will be managed by runUpdates() while
the other DeferrableUpdate objects will still be run here.
This respects the transaction sematics of DataUpdate a bit more.

Change-Id: Ia0d2dd26a38b0e8911589407b533b58d04d2b084
2015-10-08 07:21:47 +00:00
Kevin Israel
b52502eec5 Change 1.26 to 1.27, mostly in doc comments
Using the following command line, I have found doc comments (and
a wfDeprecated() call) mentioning "1.26" when they should mention
"1.27" instead, which I have fixed manually:

git diff -M REL1_26 | grep --color=always -C 10 -iP \
'^\+.*\D1\.26(\D|$)' | aha > oldver.html

Follows-up these commits:
* 047b60b96d
* 169b7b98b5
* 25a44aa3e4
* 2fb2a3f14b
* 3f1e9fa268 [1]
* 8c84af70b6
* c0cb80beac
* d04a92a551
* d3b85592ea

[1] Release notes moved in I195dd1cf.

Because a release note stating that the UserRights hook is deprecated
was added in 37062a0c0d (before the branch cut), this commit does not
change the Hooks::run call that had been changed in 21206c8fbe.

Change-Id: I5a427f003e7e3b4559fe377bcdfdca466a570708
2015-10-07 01:41:41 -04:00
Aaron Schulz
169b7b98b5 Added replication=async option to FileBackendMultiWrite
* This will defer writes to non-master backends till the
  end up the web request. This is useful for multi-DC setups.

Bug: T112708
Change-Id: I118c07764dd4a4f4f2590d4548238df12860e750
2015-10-01 23:30:41 +00:00
Aaron Schulz
d3f5c943ea Removed DeferredUpdates::addHTMLCacheUpdate()
* That method does not belong in DeferredUpdates
  as this class should agnostic to the work done

Change-Id: I8098ffb82bf9c33ccb48a31aa9dbad514e8724a8
2015-09-21 18:08:14 -07:00
Aaron Schulz
cc4ca3e86d Removed deprecated $wgDeferredUpdateList
Change-Id: I7072ad3b34dd9a0726df6d1c044616c3b4bcd79f
2015-09-21 16:30:16 -07:00
Aaron Schulz
8dbfe9d339 DeferredUpdates doc comment tweak
Change-Id: Ib58bcb065ef7fac58c3c579eb0ca45e51ccdae11
2015-05-30 17:18:12 +00:00
Aaron Schulz
99b05dcc6d Make sure $dbw is an object in DeferredUpdates::addUpdate()
Change-Id: Ib52574bc7f2e13bf06f595e349a7b3ccea425056
2015-05-20 23:06:05 -07:00
Aaron Schulz
04d11e6590 Make JobRunner flush DeferredUpdates after each job
Change-Id: Iff6625ddc04a15751d2bb07dc6558145e7ceb14a
2015-05-18 18:52:34 -07:00