Commit graph

74 commits

Author SHA1 Message Date
Reedy
7bf779524a Remove or replace usages of "sanity"
Bug: T254646
Change-Id: I2b120f0b9c9e1dc1a6c216bfefa3f2463efe1001
2021-11-19 23:19:42 +00:00
Paladox
bc931b1253 JobQueueRedis: Replace deprecated zSize with zCard
https://github.com/phpredis/phpredis/issues/1669

Change-Id: I15f1e398d45d699c3e683164e42ea6c0dc974d96
2021-10-26 01:28:27 +00:00
Amir Sarabadani
419c14b013 jobqueue: Batch jobs that will end up in the default queue
JobQueueGroup::get( $type ) returns a new object for each job type even
if it's the same class (default class). Also it builds different queues
and push them separelty a couple lines lower limiting the ability to
batch push them in the default job queue object.

Given that JobQueue cares about job types being the same as the class
type (which is important for JobQueueDB implementation), adding a config
option called typeAgnostic to ignore type mismatch in JobQueue
implementations that don't care about the type (like JobQueueEventBus)

Bug: T292048
Change-Id: I151f067ca94a985c816446b545921c387b083911
2021-10-04 09:04:11 +02:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Reedy
d53e91d272 Fix more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I94520b10d78a17ea8e965633dd475ea711f25c99
2020-05-15 00:33:32 +01:00
Aaron Schulz
6b12696452 Move UIDGenerator code to a service and put it under /libs
All MediaWiki dependencies have been removed or injected.

Change-Id: I01c9e96edd6b03496c1595670967ffa5a4069c9d
2020-02-18 00:20:40 +00:00
Paladox
fac9054e3f Replace deprecated lSize with lLen
lSize is an alias to lLen according to [1]

[1] 9f4ededa41/README.markdown (L2148)

Bug: T239734
Change-Id: I5b72fbe61e313511b69e8d2e96c2042742370b85
2019-12-03 18:20:15 +00:00
Paladox
afad1a43e4 Avoid using deprecated phpredis::delete() alias
Bug: T227461
Change-Id: I5eb2fa42d61e4757b11b6eb909c04dafb40923a1
2019-12-02 22:56:27 +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
672808c859 Merge "jobqueue: migrate root job deduplication to the WAN cache" 2019-07-13 23:30:56 +00:00
Aaron Schulz
43c78e83d7 jobqueue: migrate root job deduplication to the WAN cache
If the root job timestamp keys are lost or otherwise unknown, they
will now be deductively recached with the best known values as jobs
are popped and executed. This means the running any of many child
jobs of a root job can restore the root timestamp if it was lost.
This does not need to use the main stash given this fact.

Bug: T227376
Change-Id: Iae0f3af15803af048ff49f3bf281b2bde18c87f2
2019-07-13 15:38:17 -07:00
Aaron Schulz
1758a57245 jobqueue: fix IDEA warnings in JobQueueRedis
Change-Id: I7258191cbae22028d76a52c005f44b7347bd86aa
2019-07-11 07:22:32 +00:00
Aaron Schulz
aa4f4d6b53 jobqueue: make JobQueueDB stricter about broken job_params fields
Also rename throwDBException() to getDBException() and make the
callers throw the result to avoid phpstorm warnings. Remove $row
assignment that is always overridden as well.

Change-Id: I84bc4b11f10152eada6dd6f4788c4f79dcb4a2fb
2019-04-27 00:14:12 +00:00
Aaron Schulz
fc5d51f129 jobqueue: add GenericParameterJob and RunnableJob interface
Simplify the code of jobs that do not care about titles and removes
the direct Title dependency from JobQueue. Remove getTitle() from
IJobSpecification itself. Move all the Job::factory calls into a
single JobQueue::factoryJob() method.

Depends-on: Iee78f4baeca0c0b4d6db073f2fbcc56855114ab0
Change-Id: I9c9d0726d4066bb0aa937665847ad6042ade13ec
2019-04-08 11:05:23 -07:00
Aaron Schulz
b48dcf28d6 jobqueue: dependency inject more objects into JobQueue
Also moved some WikiMap/$wgJobClasses checks to JobQueueGroup::pop
which is the method callers are supposed to use.

Change-Id: I2ab82d8adc4ae1f54697d2935afa2053539cf2db
2019-04-04 01:32:59 -07:00
Aaron Schulz
a51ea350be Add Job::getMetadata() and Job::setMetadata() accessors
Change-Id: I3a97008d324f600a1c9f6005673073277ee564fa
2019-04-03 16:34:32 +00:00
Aaron Schulz
5196ac32c6 Rename WikiMap DB domain ID methods to reduce confusion with web domains
Those added in this same release do not need alias methods.

Change-Id: I05feeb9b0b13afe43aea1f95551965489cdbe094
2019-02-06 12:28:45 -08:00
Thiemo Kreuz
734a969d55 Safe replacement of a lot of !count() with === []
This was originally a global search and replace. I manually checked all
replacements and reverted them if (due to the lack of type hints) either
null (that would be 0 when counted) or a Countable object can end in the
variable or property in question.

Now this patch only touches places where I'm sure nothing can break.

For the sanity of the honorable reviewers this patch is exclusively touching
negated counts. You should not find a single `!== []` in this patch, that
would be a mistake.

Change-Id: I5eafd4d8fccdb53a668be8e6f25a566f9c3a0a95
2019-01-15 17:28:49 +01:00
Aaron Schulz
51945dbca3 Use DB domain in JobQueueGroup and make WikiMap domain ID methods stricter
Using domains means thats JobQueueDB has the right value to use for calls
like LoadBalancer::getConnection(). The full domain includes the schema in
the case of Postgres. This makes calls to getConnection() less awkward by
not relying on the fallback logic in reallyOpenConnection() for null schemas.

Make getWikiIdFromDomain/isCurrentWikiDomain account for the schema if it
is both defined and is not simply the generic "mediawiki" schema MediaWiki
uses by default. If all wikis use the default schema, the wiki IDs can get
by with DB/prefix alone, which various config and methods may be built around.
Otherwise, the config callbacks must account for schema and the config must
include it in various wiki domain ID lists to properly disambiguate wikis.

Also, clean up SiteConfiguration::siteFromDB() since it is not meant
to handle schemas unless the callback method was taylored to do so.

Finally, add more comments to DefaultSettings.php about already existing
limitations of wiki domain IDs and their components.

Change-Id: I8d94a650e5c99a19ee50551c5be9544318eb05b1
2018-11-07 04:46:56 +00:00
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
Aaron Schulz
82e2c924e4 Remove "@author Aaron Schulz" annotations
Bug: T139301
Change-Id: Ib5248e8e27d60611c7373bce4b29dd5e85aa3489
2017-06-27 15:24:14 -07:00
Aaron Schulz
0b58cdc7f2 Lower the amount of jobs pushed into redis at once
This further limits how long the server can be tied up by push().

Change-Id: I02d242578dadc19912c9fccfdcf5e15c5eb78e9e
2017-04-19 15:38:32 -07:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
Aaron Schulz
3740e4eed2 Use @lang tags for Lua scripts
Change-Id: Ifdbff687539078b375330ebe3a1493b281e5c518
2016-09-25 11:50:16 -07:00
Aaron Schulz
10593ffaab Move RedisConnectionPool to /libs/redis
Change-Id: Ied4a85d7172ab76b90f6d9ce4d47a83c3fd7d111
2016-09-23 00:20:19 -07:00
Aaron Schulz
387a21c748 Remove unused JobQueueRedis vars
Change-Id: I953df3daa2ec6b667971a8acd69ff59259d7ab55
2016-04-21 16:34:27 +00:00
Aaron Schulz
efd8f86283 Avoid ack() race condition in JobQueueRedis
The race would cause jobs to be be unclaimed but have
no actual job data, causing pop() to return false for
them.

Bug: T133089
Change-Id: Icc60388d4431ab7fa2ca2e46bbb0d212b2b94201
2016-04-20 16:35:30 +00: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
Ricordisamoa
7a97368c35 Stop doing $that = $this in includes/jobqueue
Closures support $this as of PHP 5.4

Change-Id: Icf4eb9ffeab410c01c68a031ec6704cd83c2681e
2016-02-10 17:51:47 +00:00
Thiemo Mättig
d22a146393 Fix mistakes in JobQueue type documentations
The missing "bool" should be obvious.

I'm also changing type hints from the implementation to the interface.
All public methods from the JobSpecification class are also in the
interface, except for two: toSerializableArray and newFromArray.
These two are not used here.

Change-Id: I36867cdfdf012a4f3233ac4730ab46dac1edc0ab
2016-01-16 00:46:58 +00:00
Aaron Schulz
2878c6443a Make redis JobQueueConnectionError mention the host
Change-Id: I00a43265a65de9c9fa58b7046770d754b7d27815
2015-12-11 21:39:02 +00:00
Aaron Schulz
d54591216e Remove wfForeignMemcKey() usage from JobQueueRedis::getQueueKey()
This class should manage the escaping it uses, rather than use some
random BagOStuff that has nothing to do with the job queue.

Change-Id: Ie716dc4a3429754a99c5f0670555e5e049b61aa1
2015-12-10 17:34:22 -08:00
Aaron Schulz
ec351986e5 Remove JobQueue::setTestingPrefix() hack
The tests are only run on dev install and only touch the
null queue anyway.

Change-Id: I441a2a4605a9e2984142485b022dd524ff819360
2015-12-10 17:20:10 -08:00
Aaron Schulz
afb86872c0 Fix bad regex in 6fe2f48df
Change-Id: I51d136a491111b7c980ddb13fff74bf4a63b15ad
2015-12-10 16:35:02 -08:00
Aaron Schulz
6fe2f48df7 Add per-partition JobQueueRedis aggregation
* Track queues with non-abandoned jobs per partition server.
  The s-queuesWithJobs key can easily be queried to see which
  queues need to have periodic tasks run (or for debugging).
* This is requirement for the redis jobchron service to be able to
  avoid hitting N=(no. types X no. wikis) queues for periodic tasks
  when only a tiny fraction of those actually have any jobs. For WMF,
  there are over 30K queues, most of them empty, so doing that can help
  lower redis-server CPU (or at least make jobchron more responsive).
* This also allows for jobchron to manage the aggregator by taking the
  per-server aggregator sets and merging them. This scales much better
  as there are only a modest number of these daemons (18 for WMF) but
  vastly more web thread pushing jobs. This cuts down on the connections
  to the active aggregator server (the one with the hash table).
* Use Lua unpack() more for stylistic consistency.

Change-Id: I1549f0edc78cc4004dd887b475dec4c0ebd306c6
2015-12-10 23:59:59 +00:00
Reedy
00c426e3c2 Replace wfBaseConvert with Wikimedia\base_convert
Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68
2015-11-24 22:51:42 +00:00
Timo Tijhof
f4801e7f14 jobqueue: Pass count value delta instead of $type for the inserts_actual metric
Follows-up 4844595. Which wrongly passed the delta as $type parameter.
This resulted in the creation of "jobqueue.inserts_actual.50" and other
random buckets.

The "all" key also got incremented with 1, but doesn't reflect the actual
value in any meaningful way (besides the number of data points pushed
to statsd).

Change-Id: Ic93e06946ce3fcf0c21d2b7504fb10b3711c6e2b
2015-10-30 06:08:37 +00:00
Ori Livneh
666407c3ab JobQueueRedis::doBatchPush(): report metrics even when failures occur
The way the method is currently written, no stats are reported at all when
failures occur.

Change-Id: I627e8f6ce3a59098bc8949da7ed22f5c924177fc
2015-10-21 23:45:55 -07:00
Ori Livneh
4844595add jobqueue: track real job inserts as 'inserts_actual'
The `inserts` metric includes dupes. `inserts_actual` will track the rate at
which the job queue is actually growing.

Change-Id: Ie7c544fc8e59180a204d1d149b6a23ac48b8abab
2015-10-21 23:45:55 -07:00
Aaron Schulz
5652ff7867 Make JobQueueRedis stat calls match the DB one
It looks like someone just forgot to update these to
the newer style (e.g. sans "job-").

Change-Id: Idf953bb73ad31425c5c366d4b2169a42bd5e022d
2015-10-20 14:24:09 -07:00
Aaron Schulz
a45c118e4c Include job attempt count for redis in showJobs.php
Change-Id: I791f1520c6d8aed6f8c4c4f09c5f72b130a00a4d
2015-08-21 13:09:14 -07:00
jenkins-bot
30f8876b8b Merge "Fixed IDE warning in doIsRootJobOldDuplicate()" 2015-08-17 22:36:41 +00:00
Aaron Schulz
c551797819 Include job UUID in doAck() error message
Change-Id: Ib84a55bd92802684b98cc1cf06e5414bd1bd9fd6
2015-08-14 16:47:55 -07:00
Aaron Schulz
9bc4258ab5 Fixed IDE warning in doIsRootJobOldDuplicate()
Change-Id: I95110dff0755336d9bb245503e4ae856171064fc
2015-08-14 16:32:04 -07:00
Ori Livneh
427bdb6dbd jobqueue: use more sensible metric key names
* Since JobQueue metrics are qualified with 'jobqueue.', don't add a 'job-'
  prefix to each metric.
* Separate the key from the job type with a dot rather than a dash.
* To avoid having a Graphite node that is both a "directory" and a metric, use
  '.all' as a suffix for aggregates.

Change-Id: I2ac604d3c042dbfb0b3a27759800f435ec22041e
2015-06-14 22:38:02 -07:00
Kunal Mehta
f138447de1 jobqueue: Record stats on how long it takes before a job is run
Bug: T101054
Change-Id: I5dc13d79a5ec2e8cb6679e3ff2535b5cb031ca30
2015-06-03 12:54:27 -07:00
jenkins-bot
c3f5ee0973 Merge "Let deduplicateRootJob() accept JobSpecification for consistency" 2015-06-03 17:38:35 +00:00
Aaron Schulz
22734b3c0f Let deduplicateRootJob() accept JobSpecification for consistency
Change-Id: I872c2af40028e918fe6d9a8cd32ac97c70bffdae
2015-05-23 12:49:44 -07:00
Aaron Schulz
6c3b99de08 Cleaned up JobQueueRedis exceptions
Change-Id: Ic6908a759a66ef578593d50c622aca6cb92fb01f
2015-05-23 12:22:18 -07:00
Aaron Schulz
e5ff2d681f Send job ACKs to statsd
Change-Id: Idf6dcd6baf39484ac6fcf14465e13ae12405dd3a
2015-05-11 16:55:42 -07:00