Commit graph

335 commits

Author SHA1 Message Date
jenkins-bot
278cdf9607 Merge "deferred: Log trace as 'exception.trace' instead of 'trace'" 2019-12-19 17:38:33 +00:00
Umherirrender
8acea5491d Handle database error with LinksUpdate and numeric category names
Until I70473280, integer literals were always quoted as strings, because
the databases we support all have no problem with casting
string-literals for comparisons and such.

PHP associative arrays don't preserve
the types of keys, it converts integer-like strings into actual
integers, which can result in errors:

WikiPage::updateCategoryCounts	localhost	1292
Truncated incorrect DOUBLE value: 'A String Category' (localhost)
UPDATE
`category` SET cat_pages = cat_pages - 1 WHERE cat_title IN
(143434343434,'14343434string')
#0 includes\libs\rdbms\database\Database.php(1587):
Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer,
string, string)
#1 includes\libs\rdbms\database\Database.php(1166):
Wikimedia\Rdbms\Database->reportQueryError(string, integer, string,
string, boolean)
#2 includes\libs\rdbms\database\Database.php(2217):
Wikimedia\Rdbms\Database->query(string, string)
#3 includes\libs\rdbms\database\DBConnRef.php(68):
Wikimedia\Rdbms\Database->update(string, array, array, string)
#4 includes\libs\rdbms\database\DBConnRef.php(380):
Wikimedia\Rdbms\DBConnRef->__call(string, array)
#5 includes\page\WikiPage.php(3689):
Wikimedia\Rdbms\DBConnRef->update(string, array, array, string)
#6 includes\deferred\LinksUpdate.php(420):
WikiPage->updateCategoryCounts(array, array, integer)
#7 includes\deferred\LinksUpdate.php(315):
LinksUpdate->updateCategoryCounts(array, array)
#8 includes\deferred\LinksUpdate.php(193):
LinksUpdate->doIncrementalUpdate()
#9 includes\deferred\DeferredUpdates.php(416): LinksUpdate->doUpdate()

Also update some param docs

Change-Id: If77cf924af01a215977bfdc8f085c4e1f4c96cad
2019-12-06 19:17:56 +01:00
jenkins-bot
2b04ef6657 Merge "Set method visibility for various constructors" 2019-12-05 10:23:34 +00:00
Umherirrender
0688dd7c6d Set method visibility for various constructors
Change-Id: Id3c88257e866923b06e878ccdeddded7f08f2c98
2019-12-03 20:17:30 +01:00
Umherirrender
2cc97d844a Use array for 'ORDER BY'
It is converted to a valid sql string from the abstract database layer

Also use array for GROUP BY and column alias

Change-Id: I293a563607d115a42c8456c9b9ac66665d71d943
2019-11-29 23:01:07 +01:00
Umherirrender
c7ad21c25f Improve param docs
Change-Id: I746a69f6ed01c3ff000da125457df62b02d13b34
2019-11-28 19:08:59 +01:00
Timo Tijhof
c643e47248 deferred: Log trace as 'exception.trace' instead of 'trace'
This way most existing Logstash dashboards looking for traces
can pick this up without requiring the filter to be duplicated
or written as a custom Query DSL entry.

Also:

* Fix the broken logger from the jobify() method which did not
  define the "{type}" or "{exception_message}" keys at all.

* Fix the over-normalized logging of all fatal errors from deferred
  updates as "Error from {type}: {exception}" which isn't useful to
  aggregate (we can already get an overall count for
  channel:DeferredUpdates, level:error). The normalized aggregate
  is meant to uniquely identify specific errors that have a common
  cause. For other fatal exceptions we leave the keep the cause
  and exception message in the raw message and only add the request
  context and trace into placeholder fields (MWExceptionHandler.php).
  Apply the same principal here as well.

* Field 'exception.class' will now be available. This was previously
  missing (e.g. what exception is being thrown). It would log
  "The given Title does not belong" instead of
  "InvalidArgumentException: The given Title…".

Bug: T233342
Change-Id: I9b15658c97e3bfcc2ce8b234d1c0d47c9c294fb7
2019-11-26 20:40:08 +00:00
Aaron Schulz
d0b7a1b4f3 Clean up DeferredUpdates transactions and push failed updates as jobs
Bail out in attemptUpdate() if the transaction state is dirty rather
that failing at some later point. Also, flush implicit transaction
rounds before calling DeferrableUpdate::doUpdate() for fresher data.

Note that only instances of EnqueueableDataUpdate can become jobs.
Make handleUpdateQueue() defer throwing the exception until every task
was attempted for the special unit test logic.

Clean up some of the logging from 34427e7d7b.

Bug: T206283
Change-Id: I84ba1f2f8c4bf7c8ef21a907f73ad1065dd8f330
2019-11-14 13:24:53 +00:00
jenkins-bot
78a2b8f485 Merge "Fix new phan errors, part 5" 2019-10-20 01:39:44 +00:00
Daimona Eaytoy
d3252fc870 Fix new phan errors, part 5
Some of the errors are suppressed because they're phan false positives.
The idea behind this is that they'll be fixed in a future version of
phan, and we'll just have to remove the suppressions.

Note: I'm disabling UnusedPluginSuppression so that we can start suppressing
issues even if they're still disabled. The sniff should be re-enabled
as soon as we upgrade phan.

Bug: T231636
Change-Id: I0f7fa06a9e03fbb86c7a5eb6e50a850bb258a7f7
2019-10-18 20:45:53 +00:00
Max Semenik
8a98dd9d59 Convert some private static arrays to constants
Remove @since for some private ones as we don't guarantee anything
about private class members.

Change-Id: Ifb898353c02082e9ef69d67f69339345c6cd154d
2019-10-16 01:30:54 +00:00
Daimona Eaytoy
95dc119527 Fix new phan errors, part 2
Still mostly doc-only.

Bug: T231636
Change-Id: I65cec6c716ce6859e14da00a12ef71e03603e59a
2019-10-12 10:35:09 +00:00
jenkins-bot
643a2e527c Merge "Make CdnCacheUpdate::expand() private and update the sole caller" 2019-09-13 21:25:47 +00:00
jenkins-bot
a2c5e9eadf Merge "Expose LinksUpdate recursive flag with a getter" 2019-09-13 20:04:40 +00:00
Aaron Schulz
fef9ed715a Make CdnCacheUpdate::expand() private and update the sole caller
Change-Id: Id427a1667618b65055be772e9919052e95def1f9
2019-09-13 01:56:23 +00:00
Aaron Schulz
dd99fa6e7f Cleanup LinksUpdate::invalidateProperties() to use JobQueueGroup::lazyPush() in one batch
Change-Id: I7afaf6e6c0692aad83c017660bb8fdbb8a88597a
2019-09-11 15:07:41 -07:00
Aaron Schulz
2adff7579d Cleanup field visibility and comments in CdnCacheUpdate and HTMLCacheUpdate
Change-Id: Ifbdc3e845aee9c6785c7813f6c955da4bfbe2bc8
2019-09-11 15:04:58 -07:00
Derick Alangi
d441507260 deferred: Fix MW version number when hard deprecating to '1.34'
Should be string or bool and not a float. The reason 49bbfc7 was
not triggered is because the deprecated code path is no longer being
executed in production.

Change-Id: Ieeffb8a6cc7177c52b4c54d66152c90ded1dc248
2019-09-11 19:15:43 +01:00
David Causse
b2ac2a41dd Expose LinksUpdate recursive flag with a getter
knowing if recursion is enabled might help extensions implementing
LinksUpdate hooks to take some decisions.
E.g. CirrusSearch would like to know if a particular update needs to go to a
priorized queue or not (template transclusion).

Change-Id: I0a0de0d4621ed302b4fb550a1ddecd4ac8c5775a
2019-09-11 16:55:39 +02:00
Aaron Schulz
a5c7fd0db2 Move callers away from Title::GAID_FOR_UPDATE
These callers just need to load some data from DB_MASTER.
Subsequent code needing that latest title data should also use the
required flags, rather than relying on flakey global cache state.

Change-Id: I53248ea4b5bf1cd953f956c41b8244831ec5ef04
2019-09-09 13:19:08 -07:00
Daimona Eaytoy
e7ee0bc0f5 Better docs to make phan happy
Change-Id: I8a9a6330cf1f889cbb77dfc28c93774204767323
2019-09-07 16:47:18 +00:00
Daimona Eaytoy
c659bc6308 Unsuppress another phan issue (part 7)
Bug: T231636
Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9
Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0
Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
2019-09-03 17:19:21 +00:00
jenkins-bot
0d6ef1c0b2 Merge "deferred: make DeferredUpdates::attemptUpdate() use callback owners for $fnameTrxOwner" 2019-08-21 19:38:13 +00:00
Daniel Kinzler
aa4da3c2e8 Revert "Add small HtmlCacheUpdater service class to normalize purging code"
This reverts commit 35da1bbd7c.

Reason for revert: wrong tab, wrong patch. Ooops.

Change-Id: I5828fff6308d43460a3b2b10f60996409181f8b3
2019-08-07 13:56:30 +00:00
Aaron Schulz
35da1bbd7c Add small HtmlCacheUpdater service class to normalize purging code
The purge() method handles purging of both file cache and CDN, using
a PRESEND deferred update. This avoids code duplication and missing
file cache purge calls.

Also:
* Migrate HTMLCacheUpdate callers to just directly using HTMLCacheUpdateJob
* Add HtmlFileCacheUpdate class and defer such updates just like with CDN
* Simplify HTMLCacheUpdate constructor parameters
* Remove BacklinkCache::clear() calls which do nothing since the backlink
  query does not actually happen until the job runs

Change-Id: Ic453b189a40109a73a9426538608eea87a76befa
2019-08-06 13:45:27 -07:00
jenkins-bot
c698fe313e Merge "Clean up spacing of doc comments" 2019-08-05 22:51:10 +00:00
Umherirrender
2664eeb632 Clean up spacing of doc comments
Align the doc stars and normalize start and end tokens

Change-Id: Ib0d92e128e7b882bb5b838bd00c74fc16ef14303
2019-08-05 22:29:50 +00:00
jenkins-bot
440d00a480 Merge "Make LinksUpdate no longer extend EnqueueableDataUpdate" 2019-08-05 17:36:51 +00:00
Aaron Schulz
29fcd02ef8 Make LinksUpdate no longer extend EnqueueableDataUpdate
LinksUpdate does not match RefreshLinksJob since the former is only a subset
of the later. Also, DeferredUpdates::doUpdates() only runs in "enqueue" mode
for cases in MediaWiki::restInPeace() if there is no post-send support.

In a future commit, the deferred callback in which LinksUpdate runs
currently, will be abstracted into its own deferred update, which
will then bring back EnqueueableDataUpdate for this update.

Bug: T206283
Change-Id: I0680be445e8b8e8d0dba85df135b84640f4fcb81
2019-08-05 17:10:33 +00:00
Aaron Schulz
182256c572 deferred: make DeferredUpdates::attemptUpdate() use callback owners for $fnameTrxOwner
This only applies for instances of DeferrableCallback

Bug: T229694
Change-Id: I57fe351041c87342bd5774e333fcde4ae15059df
2019-08-03 05:48:02 +00:00
David Causse
63e199226d Deprecate SearchEngine:getTextFromContent() and SearchEngine::textAlreadyUpdatedForIndex()
It was just a wrapper to Content::getTextForSearchIndex(), simply use
this method rather than depending on (and sometimes constructing) a
SearchEngine.

Change-Id: I8541248ffdca303f0af3b959cf2f051dcb497925
2019-08-01 17:59:32 +02:00
David Causse
bc0de57e75 Simplify SearchUpdate constructor and hard deprecate some param types
Change-Id: I5677041169402014f1afc1a9012460c760ca24b6
2019-08-01 17:24:42 +02:00
Aaron Schulz
b39f8289ff Clean up DeferredUpdates transaction handling
Bail out in attemptUpdate() if the transaction state is dirty rather
that failing at some later point. Also, flush implicit transaction
rounds before calling DeferrableUpdate::doUpdate() for fresher data.

Bug: T225103
Change-Id: I4f5d2f9814a562069619f05e003663fcedbd3f64
2019-07-18 13:16:28 -07:00
Aaron Schulz
149b5a016c Remove $wgSiteStatsAsyncFactor feature and related $wgMainStash use
Also include ss_row_id = 1 in the UPDATE query to avoid gap locks

Bug: T227376
Change-Id: I7b730bab05e6d8b6799b623e0aff089c1103c3c2
2019-07-13 18:53:51 -07:00
Aaron Schulz
f72ae0f6e6 Switch various LoadBalancer::getConnection() callers to getConnectionRef()
This is the preferred method as it enforces read-only mode for DB_REPLICA
and handles LoadBalancer::reuseConnection() calls automatically.

Change-Id: Iab9439ba8e0810fa14c302661ed7a3534f6bfc0d
2019-07-12 10:56:30 -07:00
jenkins-bot
34427e7d7b Merge "Log errors in DeferredUpdates::handleUpdateQueue()" 2019-07-11 22:50:50 +00:00
Aaron Schulz
d4cb1968c8 Reduce contention of getScopedLockAndFlush() callers by using the DB domain in the key
Change-Id: Ie9fb6a9ff384c72cca559f74d8e409d108207ae3
2019-07-11 22:23:09 +00:00
Aaron Schulz
dce07b4c21 Log errors in DeferredUpdates::handleUpdateQueue()
Other cleanups and fixes:
* Split up handleUpdate() method into run() and jobify()
* Handle Throwable errors
* Use 'cli' in stats keys in CLI mode instead of "get"
* Tweak some code comments

Change-Id: I7749465df2d7b58e66ee5ebdd3c3d25aea52eeb3
2019-07-11 22:04:55 +00:00
jenkins-bot
316509d908 Merge "Various fixes and simplifications to RefreshLinksJob::runTitle()" 2019-07-11 06:19:24 +00:00
Aaron Schulz
f588586e16 Various fixes and simplifications to RefreshLinksJob::runTitle()
* Remove logic for saving slow-to-render parser output. This has
  not worked ever since DerivedPageDataUpdater was introduced.
* Make the logic to use cached output actually work. This was
  also broken since DerivedPageDataUpdater was added. In order
  to pass the output, add a known-revision-output parameter
  to both WikiPage::doSecondaryUpdates() and
  DerivedPageDataUpdater::prepareUpdate().
* Also factored out some helper methods from runForTitle() in
  RefreshLinksJob to make it more readable and avoid the need
  for multiple transaction round commit calls. This makes the
  case of multiple-title jobs less likely to break again.
* Make use of RefreshLinksJob::runForTitle() return value.
* Add unit tests for multiple-title job case.

Change-Id: I0cd13c424a87653b5a7253c42cd48fe43befd692
2019-07-11 06:06:02 +00:00
jenkins-bot
87193d29e9 Merge "Make UserEditCountUpdate::doUpdate avoid comparing IDatabase instances" 2019-07-02 21:57:10 +00:00
Aaron Schulz
08b0462fdc Make UserEditCountUpdate::doUpdate avoid comparing IDatabase instances
Also make User::initEditCountInternal take the specific DB handle that
was waited on for replication. This shouldn't make a difference but makes
things more explicit.

Change-Id: Ibb8e083406eb4f4453afce94a2b33450239fce94
2019-07-02 21:43:00 +00:00
Umherirrender
7016d1bb31 Pass column as string to IDatabase::selectField
To match documentation

Change-Id: I7ee69fcd90ba1cba947ca2ef205f350dc456a2c7
2019-06-30 00:01:21 +02:00
Aaron Schulz
6718d18339 rdbms: rename safeWaitForMasterPos() to waitForMasterPos() in ILoadBalancer
Change-Id: I2ad0c6f369ba992895a5306a57f1af16a772844c
2019-06-22 14:56:35 +00:00
Fomafix
110a5877e9 Use [...] instead of array(...) in PHP comments and documentation
Change-Id: I0c83783051bf35fe785bc01644eeb2946902b6b2
2019-06-17 21:15:09 +02:00
Derick Alangi
21e2d71560 Replace some uses of deprecated wfFindFile() and wfLocalFile()
These global functions were deprecated in 1.34 and services made
available to replace them. See services below;

* wfFindFile() - MediaWikiServices::getInstance()->getRepoGroup()->findFile()
* wfLocalFind() - MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->newFile()

NOTES:

* wfFindFile() and wfLocalFind() usages in tests have been ignored
  in this change per @Timo's comments about state of objects.

* includes/upload/UploadBase.php also maintained for now as it causes
  some failures I don't fully understand, will investigate and handle
  it in a follow up patch.

* Also, includes/MovePage.php

Change-Id: I9437494de003f40fbe591321da7b42d16bb732d6
2019-06-11 13:26:37 +00:00
Umherirrender
5f43b1706c Pass options as array to IDatabase::insert
The documentation only allows arrays there

Change-Id: I00c6e47a817a70bed9a443aebc675ef4c3d6b1e5
2019-06-07 19:12:35 +02:00
Aaron Schulz
3496f0fca3 Make sure that each DataUpdate still has outer transaction scope
Bug: T221577
Change-Id: I620e461d791416ca37fa9ca4fca501e28d778cf5
2019-05-30 20:53:18 +00:00
jenkins-bot
cc74170831 Merge "Introduce TransactionRoundAwareUpdate interface" 2019-05-25 21:37:35 +00:00
Aaron Schulz
ef949d79d2 Introduce TransactionRoundAwareUpdate interface
Refactor the deferred update transaction round handling code to use
a new TransactionRoundAwareUpdate interface. Also, rename a few
DeferredUpdates methods so they do not give the impression that
doUpdates() is always called.

Change-Id: Idc4c6d81c4e2ca0ce41bca1e7800f797fa7e37f6
2019-05-25 02:33:05 +00:00