Commit graph

957 commits

Author SHA1 Message Date
jenkins-bot
c968e9425a Merge "jobqueue: combine Logger channels, improve docs, add missing ingroup tags" 2024-04-06 19:06:31 +00:00
Umherirrender
96ecf0f528 Fix use of ReplaceQueryBuilder::rows
Follow-Up: I446f7a09cfc0ee37c2e016052d452751f7333e27
Change-Id: Id8c56b1479860f4d8903e626b337362d10d6a8e0
2024-04-01 23:57:03 +02:00
Giuseppe Lavagetto
cfa7ed13b1 Switch Special:Upload to use async upload-by-url
With this change, when async uploads are enabled, upload-by-url
will spawn a job and a form with a button to check the status of the
process is shown to the user.

In the process, add processing of warnings in the remote jobs spawned by
the API or the Special page. This is done by adding checks to
UploadJobTrait::verifyUpload. In order to manage warnings serialized in
the job status, a method to unserialize the result of
UploadBase::makeWarningsSerializable.

Things that we might want to fix:
* The form's UI is abysmal, we should probably use Codex
* While it's not a huge deal, I'd like to figure out why I need to
purge the page cache if I want the file to show up. And more
interestingly, why this doesn't happen when uploading via the API

Bug: T295007
Bug: T118887
Change-Id: I49181d93901f064815808380285fc4abae755341
2024-03-28 11:01:46 +01:00
Timo Tijhof
ce96bed119 jobqueue: combine Logger channels, improve docs, add missing ingroup tags
* combine `JobQueueFederated` and `JobQueueRedis` into a single
  `JobQueue` channel.

* Remove duplicate descriptions from file blocks in favour of class
  doc blocks. This reduces needless duplication and was often
  incorrect or outdated, and helps (ironically) to make the file header
  more consistently visually ignorable. Various files in this patch
  contained bogus copy-pasta descriptions from unrelated classes,
  and re-defined `defgroup JobQueue` many times, showing exactly
  how this is defacto ignored and counter-productive to maintain
  in two places.

  Remove `ingroup` from file blocks in class files as otherwise
  the file is indexed twice (e.g. in Doxygen) which makes navigation
  on doc.wikimedia.org rather messy for classes in this group.

  Ref <https://gerrit.wikimedia.org/r/q/message:ingroup+is:merged>

Change-Id: I926a3aec2bc98fefa1075c4a794c46108579ae3f
2024-03-25 15:00:38 -07:00
Giuseppe Lavagetto
b5ed16c1e7 Allow async upload by url via the Api
To this end if 'async' is passed with 'url' to the api:
* Avoid downloading the file synchronously, but verify early
  if the upload is allowed by adding a canFetchFile to UploadBase
  overridden in UploadFromUrl
* Spawn an UploadFromUrlJob
* When checking for the status of the job, do it fetching the data in
  the main stash.

Bug: T295007
Change-Id: If95ccf376cfa9fbe9b3cd058e8e334a6bdd2eb44
2024-03-23 11:23:07 +01:00
Giuseppe Lavagetto
c2373af679 Add job for upload from UploadFromUrl
This is the first step to make upload from url work asynchronously

Bug: T295007
Change-Id: I1fb30352849b543c0fb1f27028a34d49dff17797
2024-03-23 11:23:07 +01:00
Umherirrender
f1bc50813e upload: Fix another signature of PublishStashedFileJob for php8.0
Seen in CI for php8 (see T273769 for more information on that test):
PHP Fatal error:  Declaration of
PublishStashedFileJob::logJobParams($status) must be compatible with
UploadJobTrait::logJobParams($status): array in
/workspace/src/includes/jobqueue/jobs/PublishStashedFileJob.php on line
52

Follow-Up: I28d0be0239f3b25efc6ea8bc3d400b9d0f5bc7bf
Change-Id: I5933ad025e29cf289e36d53e20254935641311e5
2024-03-19 21:10:22 +01:00
Umherirrender
22fcf94823 upload: Fix signature of PublishStashedFileJob for php8.0
Seen in CI for php8
PHP Fatal error:  Declaration of PublishStashedFileJob::getUpload() must
be compatible with UploadJobTrait::getUpload(): UploadBase in
/workspace/src/includes/jobqueue/jobs/PublishStashedFileJob.php on line
68

Follow-Up: I28d0be0239f3b25efc6ea8bc3d400b9d0f5bc7bf
Change-Id: Icb516ac1cfffd9589aa047aa8450c49bc1ab2379
2024-03-18 19:47:53 +01:00
Tim Starling
bd6ed0acdf Fix some spelling errors
Change-Id: I3632ce1ae00527f806652deb96cafb473aed3dcf
2024-03-18 20:58:11 +11:00
jenkins-bot
ba2af23eff Merge "RenameUserJob: Migrate from LoadBalancer to IConnectionProvider" 2024-03-15 19:09:59 +00:00
jenkins-bot
1ca627a6f6 Merge "Add comment warning about how allowRetries() ignored during timeout" 2024-03-14 20:21:24 +00:00
Reedy
41602895e5 UploadJobTrait: Fix casing of MediaWiki in import
Change-Id: Ibebb59fdcf38f642e6c76e9a979955da4f721cd9
2024-03-12 15:17:51 +00:00
Brian Wolff
24ba4a0452 Don't include return signature in UploadJobTrait for compat with parent class
Was getting Fatal error: Declaration of Job::setLastError($error) must be
compatible with UploadJobTrait::setLastError($error): void in
includes/jobqueue/jobs/PublishStashedFileJob.php on line 434

Follow-up 61ed857f9e

Change-Id: I455c7c3f1a1e8ac879d517633be0e347c6db9133
2024-03-04 01:42:09 -08:00
jenkins-bot
e78541e80f Merge "upload: switch AssembleUploadChunksJob to GenericParameterJob" 2024-03-03 09:30:51 +00:00
Aaron Schulz
9c14663be9 upload: switch AssembleUploadChunksJob to GenericParameterJob
Change-Id: I75e401c047828abf4b42d519509a1e717509ba2f
2024-03-03 00:02:52 +00:00
jenkins-bot
abaa158dd2 Merge "Refactor PublishStashedFileJob to make the code reusable" 2024-03-02 21:33:27 +00:00
Brian Wolff
16706787f2 Add comment warning about how allowRetries() ignored during timeout
When using WMF style change-propagation, the code processing
allowRetries() may not execute during a timeout resulting in the
job being retried even if it should not be. This is confusing
so add a code comment about it.

Bug: T358939
Change-Id: Iecf7fe452f16413199fee75131274d65a5ccd5e0
2024-03-02 05:07:20 +00:00
Giuseppe Lavagetto
61ed857f9e Refactor PublishStashedFileJob to make the code reusable
To this end, we create a trait to coalesce together all upload methods
common to all upload mechanisms.

Change-Id: I28d0be0239f3b25efc6ea8bc3d400b9d0f5bc7bf
2024-02-28 16:15:15 +01:00
jenkins-bot
845e69cb2e Merge "Namespace includes/cache" 2024-02-28 15:10:38 +00:00
Brian Wolff
4db0b0cb44 Prevent race condition between AssembleUploadChunksJob and transaction
The ChunkedUpload feature stores information about in progress uploads
in the uploadstash table. The AssembleUploadChunksJob reads this data
from the primary DB to prevent race conditions. However the job is
inserted into the job queue before the current transaction commits,
so the race is still present. The job sees the old version, and as
a result drops the final chunk, corrupting the file (Often noticable
by files that have a size which are a multiple of 5mb).

This changes the job push from ->push to ->lazyPush which will make
the job insert happen in a DeferredUpdate after the primary transaction
has commited. Additionally, pass the expected size to the job queue
and assert that UploadStash class has the same filesize as expected.
This will ensure that if this issue happens again, the upload will
abort and it will show up in the logs instead of silently corrupting
files.

Bug: T350917
Change-Id: I37c5c8ffc882026a9fab252b20a10cf4c43d48bc
2024-02-22 20:37:42 -08:00
Brian Wolff
30585aef79 Improve chunked upload jobs and abort assemble job if already in progress
One possible theory for why chunked upload is unreliable is that
there are multiple jobs racing each other. Add some logging warnings
that should detect such a situation, and abort job if it appears the
job is already in progress

Bug: T200820
Change-Id: Ifaf217bc288dfaa1f7f4ca7e58f8210df232db1b
2024-02-21 15:52:31 -08:00
James D. Forrester
35b2542895 Namespace includes/cache
Bug: T353458
Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
2024-02-20 10:28:03 -05:00
James D. Forrester
060a1b1668 Replace last remaining wfGetDB() calls in core, except ResourceLoader
Bug: T330641
Change-Id: I6d30af6ff9f667e367d39befb80c2bb0bf5fb29e
2024-02-14 11:02:01 -05:00
Amir Sarabadani
12000b1a74 RenameUserJob: Migrate from LoadBalancer to IConnectionProvider
Bug: T330641
Change-Id: Ifa57bd868699bef5822d0dd1bcf1ea055bb6e15c
2024-02-13 14:29:43 -05:00
Amir Sarabadani
ea268ddcfd Move away from wfGetDB() calls
If we are serious about getting rid of wfGetDB(), we should start
replcing callers with proper replacement.

These classes don't have any injection so it doesn't make sense to
introduce it for this specific usecase.

Bug: T330641
Change-Id: I645f67324d441288c63787c7e42390b59106c585
2024-02-12 21:23:38 +01:00
James D. Forrester
102a4f8a35 build: Upgrade mediawiki/mediawiki-phan-config from 0.13.0 to 0.14.0 manually
* Switch out raw Exceptions, mostly for InvalidArgumentExceptions.
  * Fake exceptions triggered to give Monolog a backtrace are for
    some reason "traditionally" RuntimeExceptions, instead, so we
    continue to use that pattern in remaining locations.
* Just entirely give up on PostgresResultWrapper's resource vs. object mess.
* Drop now-unneeded false positive hits.

Change-Id: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0
2024-02-10 02:22:41 +00:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
jenkins-bot
8f8e1d6f85 Merge "Change more uses of getDBLoadBalancerFactory() to getConnectionProvider()" 2024-01-23 17:59:21 +00:00
Bartosz Dziewoński
4aebcfe097 Change more uses of getDBLoadBalancerFactory() to getConnectionProvider()
Some less trivial cases. Also update variable names.

This doesn't really change anything, but I hope it helps promote
getConnectionProvider() as the common way to do this.

Follow-up to 8604c384f6.

Change-Id: I6657d783375fac5c7fa856b884ff1fb09285e94c
2024-01-23 16:34:45 +01:00
jenkins-bot
144203093a Merge "Remove more indirect calls to IDBAccessObject::READ_* constants" 2024-01-23 15:07:51 +00:00
Amir Sarabadani
014bc61006 Remove more indirect calls to IDBAccessObject::READ_* constants
Found via (?<!IDBAccessObject)::READ_

We are planning to deprecate and remove implementing IDBAccessObject
interface just to use the constants.

Bug: T354194
Change-Id: I89d442fa493b8e5332ce118e5bf13f13b8dd3477
2024-01-23 15:42:38 +01:00
Derick Alangi
4e468b49e0 title: Make TitleArrayFromResult via TitleFactory service
The TitleFactory should really be where TitleArrayFromResult should
live as it's a place where Title objects are created based on certain
specifications.

This patch tries to consolidate the creation of TitleArrayFromResult
via the TitleFactory services and in the future, we will consolidate
more of the logic and kill TitleArrayFromResult.

Follow up on: a99ec1b and e54665d.

Change-Id: I98215af3252d756de4435b77d1280dacda8e85dc
2024-01-23 14:07:07 +00:00
Bartosz Dziewoński
e4c7272976 Change uses of getDBLoadBalancerFactory() to getConnectionProvider()
Update cases where one of the IConnectionProvider methods is called
immediately.

This doesn't really change anything, but I hope it helps promote
getConnectionProvider() as the common way to do this.

Follow-up to 8604c384f6.

Change-Id: Id0e7d02bab0c570343c2b1f03c70b44ee39db112
2024-01-22 22:27:45 +01:00
Daimona Eaytoy
1d6776fdbc Replace deprecated MWException
Also remove some unchecked exception from doc comments.

Bug: T328220
Bug: T240672
Change-Id: I88b1e948ce5da77d9c4862a2b98793d6ba00cf8b
2024-01-19 21:58:42 +00:00
Bartosz Dziewoński
dba4096276 Reparent trivial subclasses of MWException
Bug: T328220
Change-Id: If10bdd89859a273817ab471458ca787319c77f7b
2024-01-17 04:32:33 +01:00
jenkins-bot
e8fe9b6a66 Merge "Replace deprecated MWException" 2024-01-16 20:33:13 +00:00
Daimona Eaytoy
caef81d37a Replace deprecated MWException
Bug: T328220
Change-Id: Ic45438d9e6bbf127f1415add81ab902044765840
2024-01-16 21:04:33 +01:00
Timo Tijhof
937847b26a Replace various magic numbers with easy-to-verify expressions
Follows-up I8518e0488 (9c02258a04).

Instead of documenting how to compute the number to manually verify
it, use the expression directly. This should make it significantly
easier to understand, verify, and modify.

Noteworthy:

* Language.php, I kept 31_556_952 as-is because the
  calculation would otherwise involve a float. It also has the benefit
  of allowing the long durations to build upon that as a given number.

* SqlBlobStore.php, remove this irrelevant default value as it is
  unreachable. The only call to new SqlBlobStore is BlobStoreFactory,
  which always calls setCacheExpiry. For back-compat and to keep
  tests as-is, move to re-used constant between class and config.

Change-Id: I86b034883bd7efdf93b8365b43178af826f1c703
2024-01-11 15:12:24 +11:00
jenkins-bot
ef29325971 Merge "Migrate remaining Database::insert calls to InsertQueryBuilder" 2023-12-22 14:19:25 +00:00
Amir Sarabadani
72a7b74ea9 Migrate remaining Database::insert calls to InsertQueryBuilder
Tests are not checked.

There is nothing left as far I can check.

Bug: T353219
Change-Id: I1d58397118c7ab1110b9d7cf400c59c4bff7378c
2023-12-22 14:53:17 +01:00
Gergő Tisza
8996117e6f
Document RefreshLinksJob parameters
Also, simplify parameter handling when RefreshSecondaryDataUpdate
generates a RefreshLinksJob specification as there is no way for
the user/revision to be null.

Change-Id: I9ede49123e253dbf190b1a08a3ebb317dbabd17d
2023-12-20 15:00:37 -08:00
jenkins-bot
11701c34d3 Merge "layering: UploadBase should not depend on API modules." 2023-12-16 01:52:44 +00:00
daniel
2cb8d6fbde layering: UploadBase should not depend on API modules.
API modules are high level request handler, lower level code should not
depend on them.

This patch solves the problem only partially, since it leaves references
to ApiUpload in AssembleUploadChunksJob and PublishStashedFileJob. These
jobs were already accessing ApiMain, so while this does not fully resolve
the problem, it reduces it.

Change-Id: I39c9e30cfb2860c573eed8a791f1a292a83cbd76
2023-12-16 01:29:45 +00:00
jenkins-bot
a88416f074 Merge "Namespace ParserOutput" 2023-12-15 16:17:07 +00:00
James D. Forrester
9bfb75ff90 Namespace ParserOutput
Most used non-namespaced class!

Bug: T353458
Change-Id: I4c2cbb0a808b3881a4d6ca489eee5d8c8ebf26cf
2023-12-14 14:57:34 -05:00
Giuseppe Lavagetto
f7393a3255 Convert PublishStashedFileJob to GenericParameterJob
Change-Id: If7166b813589413b575f8b458a65370ece6c2338
2023-12-13 09:07:20 +01:00
Tim Starling
9c02258a04 Use thousands separators in selected integer literals
For readability. Allowed since PHP 7.4.

I searched for integer literals of 6 or more digits, and also changed
some nearby smaller numbers for consistency.

Bug: T353205
Change-Id: I8518e04889ba8fd52e0f9476a74f8e3e1454b678
2023-12-12 09:22:45 +11:00
Gergő Tisza
6114f847e7 JobSpecification: Inherit request ID
Make JobSpecification inherit the request ID of the queuing
request just like Job does. This makes it easier to find log
events for actions that are triggered by a web request but happen
via jobs. Especially useful for enqueueable updates which might
or might not happen via jobs depending on the load of the system
at the moment.

Bug: T351729
Change-Id: I965ee211b00b2b33970651368930b5c59704a827
Depends-On: Iccf0f3bf666b9a77fbbd5874fe2f56bfffc9bd4c
Depends-On: I9613c8c293ac3fb4b1ac25c229bb4dc83e2f34fa
2023-11-30 19:37:52 +00:00
James D. Forrester
67217d08df Namespace remaining files under includes/deferred
Bug: T166010
Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
2023-11-22 10:08:53 -05:00
Amir Sarabadani
5b0b7640a6 jobqueue: Remove $wgJobSerialCommitThreshold
This config has been set to false in production since 2018 (Ie4ea1dc0d3927).

This doesn't provide much benefit and its impact yet to be proven and
it's blocking removal of ILoadBalancer::getAnyOpenConnection()

That removal makes $dbwSerial unconditionally false which turned the
whole method into a one-liner and since it was used only once,
we just replaced that.

Bug: T325389
Depends-On: I24f33a15d214d49bfb6c6013e7fd64c7d0eb0086
Change-Id: I19043e775fce9f7ddded128cb2c9395b46dd19a3
2023-11-15 19:23:14 +00:00