Commit graph

458 commits

Author SHA1 Message Date
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
James D. Forrester
f8ac266287 Job: Remove insert() and batchInsert(), deprecated since 1.21
Bug: T179624
Change-Id: I0d78a926c8c513fd652a424e8a51ded20e524a4a
2018-05-21 20:10:09 +01:00
Aaron Schulz
b6cd5421b9 rdbms: rename onTransactionIdle() to onTransactionCommitOrIdle()
This is clearer and is consistent with onTransactionPreCommitOrIdle()

Change-Id: I3a34a0e9adea69ec55ed6ddfef47703e31e7c3b5
2018-05-09 21:07:06 +00:00
Aaron Schulz
c8085ad43f rdbms: make IDatabase::onTransaction* methods pass the DB handle for convenience
Change-Id: Ia45a26830d62326b103593268fbf34c907783c90
2018-04-24 16:45:11 -07:00
jenkins-bot
7dcf1c6616 Merge "Migrate PurgeJobUtils callback to AutoCommitUpdate" 2018-04-17 23:12:44 +00:00
Aaron Schulz
c6b668c2ec Do not start explicit transaction rounds for RecentChangesUpdateJob
The replaces the hacky use of onTransactionIdle(), which no longer runs
immediately in explicit transaction rounds since d4c31cf841.

Also clarified TransactionRoundDefiningUpdate comment about rounds.

Change-Id: Ie17eacdcaea4e47019cc94e1c7beed9d7fec5cf2
2018-04-17 12:39:05 +00:00
Aaron Schulz
2e3dcdab2b Migrate PurgeJobUtils callback to AutoCommitUpdate
Since it calls LBFactory::commitAndWaitForReplication, blocking for
an unknown amount of time, it is a bit "heavyweight" to be the sort
of quick update that uses onTransactionIdle().

Change-Id: Ic3476de5b61a7cd5f31ba487b186f9605a3b2774
2018-04-16 17:11:48 -07:00
Aaron Schulz
f8c2486d15 rdbms: rename CONN_TRX_AUTO constant to CONN_TRX_AUTOCOMMIT
The "AUTO" means AUTOCOMMIT, not "automatic transactions"/DBO_TRX,
which is basically the opposite concept. The new name does not
suffer from that ambiguity.

Keep the old constant as an alias for backwards compatibility.

Also remove LoadBalancer comment about non-existing field

Change-Id: I63beeb061fc9be73f320308e4d6393b58628b8c8
2018-04-12 13:01:52 -07:00
Aaron Schulz
4f31afd21b Move most User::clearAllNotifications() logic to WatchedItemStore
Change-Id: Ib1b0c40e408f6fad6fc8257c5073fa1c3c264c3a
2018-03-23 10:26:13 +00:00
Aaron Schulz
45a6a7ad67 Set visiblity of some HashRing methods
* getLiveRing() is now protected
* getLocation() is now final

Change-Id: I16002fe7187d8bbb6e36d4dd9a1302ee1d46a4bb
2018-03-17 23:49:03 -07:00
Aaron Schulz
8aeedcbabd Cleanup some comments related to DB replication
Change-Id: Icaaa5144beaedfebb88530480733a1e916c935fb
2018-03-09 23:05:43 +00:00
jenkins-bot
0c2687f44e Merge "Job::insert: Hard deprecate (soft-deprecated in 1.21!)" 2018-03-08 20:28:42 +00:00
Petr Pchelko
813133743d [JobQueueSecondTestQueue] Support read-only mode.
In order to switch non-idempotent jobs without losing the
backlog in redis we should support read-only mode in the queue,
where the messages only gets written into the new queue.

Change-Id: I2e9cb2d9cbbd2d657d042b55d4ea0819d21cdd6f
2018-03-05 16:44:11 -03:00
Brad Jorsch
27c61fb1e9 Add actor table and code to start using it
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.

A subsequent patch will remove the old columns.

Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
2018-02-23 10:06:20 -08:00
Chad
bfbc44648d Revert "JobQueueGroup: Improve failed-to-insert error"
I made a useless commit.

This reverts commit a82cb5aa18.

Change-Id: I70328bcbcf9af5480c7a0b8e297ed41a463fd457
2018-02-23 08:05:13 +00:00
Chad Horohoe
a82cb5aa18 JobQueueGroup: Improve failed-to-insert error
This could possibly use LoggerFactory & friends to use them as
parameters, but either way let's sort the entries so they're
at least remotely capable of self-grouping.

Change-Id: Iaf435093d70add02e2f82e3037c64fec11870979
2018-02-23 01:57:11 +00:00
Timo Tijhof
d6cc261cb2 Use lock(,,0) instead of lockIsFree && lock(,,1) for non-blocking locks
This pattern is already used elsewhere and seems like a more efficient
way to acquire locks in a non-blocking way.

Change-Id: Idb369e7cb03b793d5f8295e956fecd8d1f849e17
2018-02-15 14:30:26 -08:00
Eddie Greiner-Petter
edba39ab60 Be more db-friendly when purging expired userrights
Each expired row has to be fetched from the user_groups table, deleted
from that table and added to the user_former_groups table.  Per Jaimes
request, let's not do this for all rows at once but for smaller chunks
and wait for replication to catch up after each chunk has been
processed. In addition the function to purge the expired rows now sets a
lock so that there won't be multiple concurrent runs.

Also, cleaning this table up isn't urgent and thus should be done in a
job and not a deferred update, so let's move it there.

Bug: T176754
Change-Id: I671d4b9d09677a2f474477ba7fea33a44d6318aa
2018-02-14 09:02:33 +00:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
Thiemo Mättig
409da2d8b3 Remove leading backslashes from "use \…" tags
Change-Id: I494b029de089a07e3b946ee78293a12d5036f63e
2017-12-28 16:30:05 +01:00
Aaron Schulz
78204090ba Change EnqueueJob docs to discourage obsolete use-cases
Bug: T181216
Change-Id: I9332d26ae9a74c3721cff9c497d5356f05efb428
2017-12-14 03:15:29 +00:00
Tim Starling
dc2948d76d A few doc comment fixups
* Remove some creation dates, they are not protected by GPL
* Remove duplicate @defgroup API
* Remove @ingroup from some @file doc comments on class files. It is not
  useful to list class files alongside classes in the doxygen module menu.
  Add @ingroup to some more class files that had @ingroup on their file,
  that was probably the author's intent.
* In PackedOverlayImageGallery, use the file comment as a class comment
* Don't put @defgroup and @file in the same comment. @defgroup makes the
  whole doc comment describe the group.
* Instead of putting AnsiTermColorer in two groups, use hierarchical
  groups.

Change-Id: If54f6e0b2bc1ea6de42045885cf836ee67b8e961
2017-12-04 11:11:52 +11:00
Timo Tijhof
9a65a14da6 jobs: Remove ClearUserWatchlistJob 'batchSize' option
Use $wgUpdateRowsPerQuery instead, and use its value at run-time
instead of inside the job parameters. Also helps with deduplication
if batchSize is changed.

Change-Id: Ifef25a3ae5ae2418359a41eba05778613fbb548f
2017-11-30 12:36:36 -08:00
jenkins-bot
5dad90f357 Merge "Introduce ClearUserWatchlistJob" 2017-11-28 18:31:52 +00:00
addshore
989ba87562 Introduce ClearUserWatchlistJob
Change-Id: Icea573a10078ea3f09dc2e4e9fdc737bf639935d
2017-11-28 17:11:40 +00:00
jenkins-bot
2289ab396a Merge "Reduce lag waiting time in CategoryMembershipUpdateJob critical section" 2017-11-21 19:13:34 +00:00
Aaron Schulz
b212286144 Reduce lag waiting time in CategoryMembershipUpdateJob critical section
Bug: T180793
Change-Id: Icfe8dd16f4194c5d4f88d7547f732acae8b1cfe2
2017-11-21 04:08:43 +00:00
Aaron Schulz
7ec76945e3 Make CategoryMembershipChangeJob query more readable
Previously, the INNER JOIN had "rc_timestamp >= rev_timestamp" which
complicates query planning. Even with "equals" it still was techinally
ambiguous. Instead, just use EXISTS and an exact equality operator.

Bug: T180793
Change-Id: I1e9ae7c2ce0f95484e09e867550283d816d151f0
2017-11-21 04:08:12 +00:00
jenkins-bot
b5370206ff Merge "Add action/user tracking to html cache purge jobs" 2017-11-09 22:33:48 +00:00
James D. Forrester
970557f89d Job::insert: Hard deprecate (soft-deprecated in 1.21!)
Change-Id: I5b653a3dacd6dc73a80b6bbcc282fdd5dad6e49a
2017-11-02 15:07:39 -07:00
Brad Jorsch
3488f49532 Replace selectFields() methods with getQueryInfo()
Several classes have a "selectFields()" static method to tell callers
which fields to select from the database. With the recent comment table
change and the upcoming actor table change, this pattern has become too
simplistic as a SELECT will need to join several tables to be able to
retrieve all the needed fields.

Thus, we deprecate the selectFields() methods in favor of getQueryInfo()
methods that return tables and join conditions in addition to the
fields.

Change-Id: Idcfd15568489d9f03a7ba4460e96610d33bc4089
2017-10-30 22:57:33 +00:00
Aaron Schulz
3247bae0e7 Add action/user tracking to html cache purge jobs
Change-Id: Ic7155a7303debfaf26b13cb836497ccbc89ea238
2017-10-30 10:47:30 -07:00
Aaron Schulz
8f829de5f0 Add action/user tracking to link refresh jobs
Change-Id: Ie7261eacddb869988b005ba2f17968df88c7003e
2017-10-23 11:06:16 -07:00
Aaron Schulz
2cb965c5a5 Set getDeduplicationInfo() for HTMLCacheUpdateJob
This allows de-duplication of single page jobs for the
same page due to edits to different templates. This is
the same logic that RefreshLinksJob already has.

Also fix a bug in that method in RefreshLinksJob.

Change-Id: I2f79031c945eb3d195f9dbda949077bbc3e67918
2017-10-19 22:38:58 -07:00
Aaron Schulz
7f571f9bca Remove useless commit calls in JobRunner
These were meant as sanity checks, but would fail in those
unusual cases anyway with exceptions. Instead, have an
early check to make sure no explicit transaction rounds
are active when JobRunner:run is called.

Change-Id: I723c77c8d3ef7ec4dcf09ce6d549b4fd57bdf1c2
2017-10-12 12:00:07 -07:00
Aaron Schulz
ed20c833bf Avoid per-title page_lang DB queries HTMLCacheUpdateJob
Change-Id: Ie2fa64400f05d90e615bd8ff26225e197605d244
2017-09-20 16:48:42 +00:00
Aaron Schulz
d0c373fdf2 De-duplicate HTMLCacheUpdate jobs with a page array of size 1
BacklinkJobUtils consistently uses the "pages" field in leaf
jobs, even when there is only one page per leaf job.

RefreshLinksJob already has this logic for de-duplication.

Change-Id: Ia189bbc9df44f2161cfed4192c23b2ac3cfa65ce
2017-09-14 11:34:24 +02:00
Brad Jorsch
3e9fdfbda5 JobQueueMemory: Actually return values in MappedIterator callback
Change-Id: Ie489d43ba3e9f4a10580716f38ec0f123d9ab5bb
2017-09-12 11:51:47 -04:00
jenkins-bot
45a6ddfcd0 Merge "Improve some parameter docs" 2017-09-10 22:57:48 +00:00
Umherirrender
f739a8f368 Improve some parameter docs
Add missing @return and @param to function docs and fixed some @param

Change-Id: I810727961057cfdcc274428b239af5975c57468d
2017-09-10 20:32:31 +02:00
Kunal Mehta
1fd095ec1c Avoid using the deprecated ParserCache::singleton()
Change-Id: I0da6d9cbfad26c89bf5dab564071ef97acaf44f9
2017-09-09 14:20:10 -07:00
Brad Jorsch
01a10dba5a Remove reference to deprecated IDatabase->nextSequenceValue()
The method was deprecated and made unnecessary in Ib308190c.

Change-Id: I1729ac0b3a88270a4c2f064187a2472112aaeb1e
2017-09-01 12:28:39 -04:00
Aaron Schulz
cb7c910ba7 Fix old regression in HTMLCacheUpdate de-duplication
* The condition timestamp should be the root job timestamp,
  as the comments imply, though that was not the case. Only
  the SET timestamp should be the current timestamp. As it
  was, jobs effectively did not "see" each other since each
  one would be expecting newer than the ones that ran prior.
  The page_touched condition for the UPDATE query was mostly
  useless, since it was always the current timestamp.
* This problem was a regression from f598ca81e3.

Change-Id: I1398366e87c959be1c98e4db959c41309b0ac1b8
2017-08-25 15:49:49 -07:00
Aaron Schulz
6898d06f8f Disable rebound CDN purges for backlinks in HTMLCacheUpdateJob
These are there to handle regeneration race conditions due to
replication lag. If there happens to already be a huge amount
of purges, the cost of this can be too high. Also, if the queue
is backlogged, then it is already delayed, so extra delayed jobs
do not help and just add to the backlog in that scenario.

Bug: T173710
Change-Id: Ida0bf44233072e1356a9fe63866d522e4bb2d0ca
2017-08-24 15:10:21 -07:00
Aaron Schulz
70d1bc0091 Make workItemCount() smarter for htmlCacheUpdate/refreshLinks
Do not count jobs that just make subdivide as having any
"work items". This makes $wgJobBackoffThrottling less
overzealous when used to limit these type of jobs.

The main reason to limit htmlCacheUpdate would be for
CDN purge rate limiting. For refreshLinks, it would
mostly be lag, though that is already handled for
leaf jobs and JobRunner itself.

Bug: T173710
Change-Id: Ide831b555e51e3111410929a598efb6c0afc0989
2017-08-23 10:35:34 -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
99c80a8fc7 rdbms: Support secondary autocommit connections in LoadBalancer
This is useful for things like SqlBagOStuff and JobQueueDB
being able to write in auto-commit mode while the main
transaction round still goes on.

SqlBagOStuff already had this sort of logic.

JobQueueDB now also takes this approach so it does not have to
defer insertion except for sqlite. This makes callers more likely
to know when insertion failed or not.

Make sure LoadBalancer sets "master"/"replica" LB info itself;
this fixes a bug found in the new tests.

Bug: T140338
Bug: T42451
Change-Id: I4199a9598d7afbf976a6efa8ed84b85b56da02bd
2017-08-18 01:28:34 +00:00
Aaron Schulz
a549313076 Avoid lock acquisition errors for multi-title refreshlinks jobs
Bug: T173462
Change-Id: I9dab9b4e5c4cae7306dc29bad9e62287d54b2281
2017-08-17 09:36:56 -07:00
Aaron Schulz
df7ec19a12 Disallow job pushes from JobQueueGroup to bogus wikis
Bug: T171371
Change-Id: I03a5dbd18cf6b5bcacb3ec07cef9e0b051bc147c
2017-08-11 14:56:47 -07:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00