Commit graph

56 commits

Author SHA1 Message Date
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
Aaron Schulz
87d1cbc074 Reduce chunk size in doBatchPush for redis
Change-Id: I2c66b6b69535ce2089c1fab2df962f4ebca9f62f
2015-05-06 18:24:34 -07:00
Aaron Schulz
9d759043d2 Removed useless doGetPeriodicTasks() override
Change-Id: I70b33ad746c5f31bba5b83e249f8c22faf316cf4
2015-05-06 17:49:40 -07:00
Ori.livneh
787f2dfc36 Revert "Added per-wiki queue stats information"
Creates too many metrics.
This reverts commit 340220080e.

Task: T95913
Change-Id: Ifa478996febcdd6b3687c4cb64b215495514a899
2015-04-20 19:31:03 +00:00
Aaron Schulz
6c9e517a70 Made showJobs.php show claimed jobs too
Change-Id: Ifc5eeff10fdcdbbe4ade7b32e5388fee4eb94bcf
2015-04-17 12:35:39 -07:00
Aaron Schulz
f7f49dfb00 Made job factory() callers use Title::makeTitle
* The titles are not from user input and this simplifies the code

Change-Id: I067049cca5661b387076f0c28bc0b71d22162a0f
2015-04-13 21:31:29 +00:00
Aaron Schulz
9720c6c410 Made showJobs.php include abandoned jobs in --list
Change-Id: I7ae8dd2470d5e15fd66c6c06f3feb6d70527daa3
2015-03-26 12:17:10 -07:00
Aaron Schulz
b480ec3353 Made JobQueueFederated no longer need "checkDelay" for delaying
This reverts commit b9fd0f311c.

Change-Id: Ibff28591c268689d593cb56a58e0b33c22292eba
2015-03-11 11:15:40 -07:00
Legoktm
b9fd0f311c Revert "Made JobQueueFederated no longer need "checkDelay" for delaying"
Breaks Cirrus and Wikibase

This reverts commit c8f96384aa.

Change-Id: I15278d52806bf30d6ea6c6b9eb8586160f65c42b
2015-03-11 17:10:18 +00:00
Aaron Schulz
c8f96384aa Made JobQueueFederated no longer need "checkDelay" for delaying
* Cleaned up the weird logic for checking if delays are supported

Change-Id: I3a1a78bb48b4950b76f445bf8c27b5868d3dc89c
2015-03-10 15:13:18 -07:00
Aaron Schulz
f826b15bd2 Only support "daemonized" mode for redis job queues to avoid code duplication
Change-Id: I83bf61734fc48feea8a2f93adfe70f7d3a066b9e
2015-02-10 12:18:13 -08:00
Gabriel Wicke
e883b95e70 Trival: Comment speling
Change-Id: I17f50b5f26f5e8c1c9687c040c64699720ea6167
2015-02-09 23:20:29 +00:00
Aaron Schulz
ee20da4346 Always supported delayed jobs in JobQueueRedis for simplicity
* Previously, each job type had to be configured to allow delayed jobs

Change-Id: I5f3cf04deca76d6684aa6b14eea97a8673a7f5af
2014-10-21 00:39:08 +00:00
Aaron Schulz
a6814c9df3 Removed extra "tries" increment in the redis job queue
* This could result in jobs getting one less extra tries than they should

Change-Id: Ia2e82ca0965f6ce9e1354820eb03f40f047a949c
2014-10-20 21:00:31 +00:00
Aaron Schulz
015ad5d403 Avoid calling recyclePruneAndUndelayJobs() in daemonized mode
* This could cause problems if claimTTL is 0 in MW config but not
  in the runner JSON config.

Change-Id: I86418fd4426b58be1c17c97e026d14239f5e36de
2014-10-20 20:37:32 +00:00
Aaron Schulz
9d75a0c51b Avoid needing config to be in sync between MW and the jobrunner
* This unifies the retry and no-retry code paths so that its easier to use
  the separate job runner service.
* All jobs will use the ack procedure. If no retries are enabled they will
  just get deleted. As a side-effect, abandoned jobs can be seen for a few
  days in the no-retry case, which used to not happen. This could actually
  be useful to know about anyway.

Change-Id: I185092e3696fb336b9edcf19280dcd9a561161d9
2014-10-17 23:03:53 +00:00
umherirrender
44d14fc684 Doc: Reformat @params declaration
I have not found documentation about the @params command, so this seems
not valid.
I have moved the text to the corresponding @param

Change-Id: I443866d602b60570278289e6e24a77d37314cede
2014-07-24 13:12:18 +02:00
Aaron Schulz
e11da363d0 Added "daemonized" flag to JobQueueRedis
Change-Id: I6df1004a7872809bfd28ad1477b9504e76f75a92
2014-07-16 22:24:50 +00:00
Nik Everett
95bfc8b956 Work around hhvm bug in redis job queue
The hhvm redis client returns false instead of null.  This caused
JobQueueRedis to get stuck in an infinite loop.  This works around the
difference by catching null as a signal for no more jobs.

It can be reverted when https://github.com/facebook/hhvm/pull/3127/ is
in all versions of hhvm we expect to run MediaWiki.

Bug: 67622
Change-Id: I9bbad42f36a80635097b8e0140b48b6492b2f0f5
2014-07-07 18:12:12 -04:00