Commit graph

98 commits

Author SHA1 Message Date
Aaron Schulz
6c73b32fd5 Convert JobRunner to using beginMasterChanges()
This lets the runJobs.php $wgCommandLineMode hack be removed.

Some fixes based on unit tests:
* Only call applyTransactionRoundFlags() for master connections
  for transaction rounds from beginMasterChanges().
* Also cleaned up the commitAndWaitForReplication() reset logic.
* Removed deprecated DataUpdate::doUpdate() calls from jobs
  since they cannot nest in a transaction round.

Change-Id: Ia9b91f539dc11a5c05bdac4bcd99d6615c4dc48d
2016-09-07 03:56:37 +00:00
Niklas Laxström
e2fde0fe45 Add --wait option for runJobs.php
It is now very easy to implement a simple low delay job runner:

while true; do php runJobs.php --wait; sleep 1; done;

Change-Id: I50cf00aed4b15d90384a2cc12bddd64d96d5a1ad
2016-02-21 09:24:39 +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
Max Semenik
59db24e90b Use addDescription() instead of accessing mDescription directly
Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
2016-01-30 01:28:32 -08:00
Aaron Schulz
7f1d4dfb0e Enable DBO_TRX for runJobs.php, just like HTTP job runner
Change-Id: Ic6fa2f9f0d18aeeb15f482e2faab2ebc56650570
2015-04-21 17:42:31 -07:00
Aaron Schulz
e9a65a5194 Removed redundant wfReadOnly check in runJobs.php
* JobRunner handles this and doing it pre-fork is less safe

Change-Id: I9e53e6b2d04f3f370723af8140e796ba337cfd3b
2015-04-21 23:22:36 +00:00
Bryan Davis
1195e11a8a Move MWLogger classes to MediaWiki\Logger namespace
Move the MWLogger PSR-3 logging related classes into the
MediaWiki\Logger namespace. Create shim classes to ease migration of
existing MWLoggerFactory usage to the namespaced classes.

Bug: T93406
Change-Id: I359cc81fbd2dcf8937742311dcc7d3dee08747b0
2015-04-03 11:32:24 -07:00
Bryan Davis
2eea1d5a42 Convert JobRunner to PSR-3 logger
* Implement Psr\Log\LoggerAwareInterface
* Categorize log events with levels (debug, info, error)

Bug: T87521
Change-Id: I2637c40a44e396b1020b76f54c2e8b931f764f02
2015-01-26 15:04:12 -08:00
Aaron Schulz
baaf489633 Set "has value" flag correctly for result parameter
Change-Id: I97eeef620ddfdda6f09abbfdf0388146d4d02e36
2014-07-28 17:38:56 -07:00
Aaron Schulz
5dc6ff0f36 Added support for result=json parameter to runJobs.php
* This can let the caller get info about what was run, just like the web version

Change-Id: I49d7eccee52eb1dc161249fdc0546259ccf1f959
2014-07-28 10:30:18 -07:00
Aaron Schulz
094d901b88 Refactored duplicated code into JobRunner.php
* Also added an async flag to SpecialRunJobs so that it can be
  set to false to get a JSON blob back with a regular 200 status.

Change-Id: I2f5763e017684c3c61f3d3f27ddf7f7834bdfce2
2014-07-25 17:28:10 +00:00
Aaron Schulz
2979f0b6f1 Avoid useless delay and master connections in wfWaitForSlaves() in runJobs.php
* Some jobs, like Parsoid ones, do not actually do master DB updates

Change-Id: I1a8830eafd7760d081df966bb423030dcdc96408
2014-07-19 15:19:40 -07:00
Aaron Schulz
76b8f81419 Made --maxtime a soft limit again
* The new job loop already manages timeouts and this version caused
  some problems with the time-sharing approach that used --maxtime.
  This killed runners too fast for some jobs and only handled CPU
  time anyway, not wall clock time.

Change-Id: Id3462554b1ecba9ecdf7d49673645d54c0555cd6
2014-07-18 11:01:01 -07:00
Aaron Schulz
ca1a36bfe3 Use job backoff times in the case of high failure rates
Change-Id: Ica0c81bfb127e858ec6f1aa193da351930493b2d
2014-07-15 17:22:39 -07:00
Gergo Tisza
c1a60bfb8e Allow floating point values for $wgJobBackoffThrottling
Useful for jobs which take longer than a second to finish.

Change-Id: I2e57d61fd67b97fbd593274b31e1bfada8f522f5
2014-05-09 00:40:21 +00:00
Aaron Schulz
d1723b7820 Disable job throttling for DuplicateJob jobs
Change-Id: I461ea9710660d061ae2da1f99f39247877332ca2
2014-04-28 23:18:25 +00:00
Siebrand Mazeland
606c680b21 Update formatting in maintenance/ (4/4)
Change-Id: I6b58d014a4bfd6600e4e6f80188fdcfce18482ca
2014-04-23 20:09:26 +02:00
Siebrand Mazeland
89d8c583d7 Pass phpcs-strict on maintenance/ (2/8)
Change-Id: I69e2bca3c98fe9d3713c852699f49b7b4c868338
2014-04-22 21:25:47 +00:00
umherirrender
e78776373e Fixed some @params documentation (maintenance)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I727deec35a712de0f0c676cc87dfa661f1ee965b
2014-04-17 22:48:32 +02:00
jenkins-bot
35b2d649a9 Merge "Made runJobs.php fully respect $wgJobBackoffThrottling" 2014-04-08 16:15:30 +00:00
Brian Wolff
2ab242ae0f Rollback transaction in case of uncaught exceptions during job
If there is an unhandled exception during a job, rollback the
transaction to be safe. Otherwise its likely that the
transaction will be commited when next job is run, as $dbw->begin()
implicitly commits any open pending transactions. This can result
in database referential integrity issues.

Change-Id: I5807e64440ff6c6651fbbb4924645d05d843b98e
2014-04-05 23:02:02 -03:00
Aaron Schulz
0929a1fba8 Made runJobs.php fully respect $wgJobBackoffThrottling
* Previously, it did not if --type was used
* A --nothrottle option was added to ignore throttling

Change-Id: Ib3ca899f1ce30250a63084096f1b660c96e359fe
2014-04-02 18:20:16 -07:00
Chad Horohoe
518fa756f2 Remove $wgTitle from all maintenance scripts
Shouldn't be needed and aren't for any core operations. If any
extension relies on these $wgTitles being set in maintenance
environments those extensions are broken and should be fixed.

Change-Id: Ie02a5042ab96e155d783d56d5340dd0da8e3d55c
2014-03-12 18:28:47 -07:00
Aaron Schulz
256beb9200 Fixed silly regression with $job not being set in runJobs.php
Change-Id: I2dae31574e5822b7b76bf1b04aba0063bed17944
2013-12-28 16:07:25 -08:00
Aaron Schulz
e8cb20737a Added $wgJobBackoffThrottling to replace wmf sleep() hack
* This also adds a Job::workItemCount() method
* Removed unused USE_PRIORITY constant
* A few small cleanups in runJobs.php

Change-Id: Ife9370e488fa63dcd1f702ed98f3b7f26057f10c
2013-12-23 15:10:50 -08:00
Antoine Musso
670cc77d20 runbJobs: rm outdated options in comments
We had a comment at the top of runJobs.php listing potential options to
use. That unsurprisingly ended up being outdated. Instead folks should
either:

* page down to the constructor to have the exhaustive list of options
* RTFM by invoking the script with --help

Change-Id: Ic87574b26145376bb9926894a7c35f9f0622a3e9
2013-12-17 23:32:25 +01:00
umherirrender
24bfde2710 Fix spacing and break some lines
Change-Id: Ia57685d8858e02e399ad5c75ce64d12609d340ac
2013-08-24 17:06:25 +02:00
jenkins-bot
7465a1b83d Merge "Made runJobs.php respect time limits better and try to bail before OOMs" 2013-08-13 18:09:10 +00:00
Aaron Schulz
a50f3e7f7a Removed unused $dbw variable and connection
Change-Id: I47060139fe762257847f482d24bd284fe6123452
2013-08-13 00:42:09 -07:00
Aaron Schulz
1bdb0c8501 Made runJobs.php respect time limits better and try to bail before OOMs
Change-Id: I93b9cebda591f15d42c401f4dc51ecd746d45a0d
2013-06-27 09:50:03 -07:00
Aaron Schulz
f52950c33e Include the backtrace in the log for job exceptions
Change-Id: Iff478f452142f1ccc9af70b4a64cfb66d04014f3
2013-06-25 23:16:05 +00:00
Aaron Schulz
e990facd73 Actually update $lastTime in runJobs.php
Change-Id: Ic51b0941aa72f444b1bad919e6a05ff0ba273ce7
2013-05-24 18:09:45 +00:00
Timo Tijhof
beb1c4a0ec phpcs: More require/include is not a function
Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81.

Also updated usage in text in documentation and the
installer LocalSettingsGenerator.

Most of them were handled by this regex:
- find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$
- replace: $1 $2;

Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa
2013-05-21 23:26:28 +02:00
Aaron Schulz
294e591a3c Make sure job runner exceptions get logged.
Change-Id: Ie468e7009c45a2b637df38309fd7b8368e021b6d
2013-05-16 13:51:36 -07:00
Timo Tijhof
50e7985d4d phpcs: Fix WhiteSpace.LanguageConstructSpacing warnings
Squiz.WhiteSpace.LanguageConstructSpacing:
   Language constructs must be followed by a single space;
   expected "require_once expression" but found
   "require_once(expression)"

It is a keyword (e.g. like `new`, `return` and `print`). As
such the parentheses don't make sense.

Per our code conventions, we use a space after keywords like
these. We appeared to have an unwritten exception for `require`
that doesn't make sense. About 60% of require/include usage
was missing the space and/or had superfluous parentheses.

It is as silly as print("foo") or return("foo"), it works
because keywords have no significance for whitespace between
it and the expression that follows, and since experessions can
be wrapped in parentheses for clarity (e.g. when doing string
concatenation or mathematical operations) the parenthesis
before and after basiclaly just ignored.

Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87
2013-05-09 05:56:26 +02:00
Aaron Schulz
110450d73c Wrap job execution around profiling calls.
Change-Id: Idf184b7c2f7003032d3a28830ee9c4a1eaeaa98b
2013-04-18 12:22:33 -07:00
Aaron Schulz
0b6bce6d2f Do not bother with ForkController for procs=1.
Change-Id: I84d4dd5369c5640b849d2fb58e01b8565b2abd65
2013-04-17 14:23:10 -07:00
Aaron Schulz
a6aec4d1fb Make sure a job is logged as OK if the status is NULL for sanity.
Change-Id: Ib1e194fc6d655c48b72f0cfae30a9ec78e54419f
2013-04-04 10:50:26 -07:00
Aaron Schulz
9399d52dc6 [JobQueue] Added more isQueueDeprioritized() checks to avoid refreshLinks spam.
Change-Id: I29cb22ed471f129efba2bb7b0743c700456f0f4d
2013-03-28 21:00:42 -07:00
Aaron Schulz
8d5af36eb0 [JobQueue] Try to cut down on waitForBackups() calls in runJobs.php.
Change-Id: I2fc97ef8dbc02d1184959ba962dcafdae9fae808
2013-03-11 18:56:16 -07:00
Aaron Schulz
d8c2a618e5 Made runJobs.php wait for slave lag.
* Relying on waitForBackups() alone will not work with non DB queues.

Change-Id: I2124c5cd11a70d183cfde00ad21d6642a3a0ee9e
2013-03-06 03:59:33 +00:00
Aaron Schulz
4c8b037a78 Cleanups for runJobs.php.
* Handle exceptions in run() better.
* Made the profiling more accurate.
* Simplified the code to handle non-boolean results of run().
  wfWarn() was removed, and bugs reports were already filed.

Change-Id: Ic702319420efbdf12c17d51494255a64a6212d99
2013-02-21 11:08:39 -08:00
Aaron Schulz
d0985f4f04 [JobQueue] Added aggregate empty/non-empty queue caching.
* The default class is JobQueueAggregatorMemc.
  This essentially has the logic that nextJobDB.php used.
* Also created a JobQueueAggregatorRedis class.
  This is much more efficient and more responsive.
* This can speed up calls to getQueuesWithJobs().
* Removed unused getDefaultQueuesWithJobs() function.

Change-Id: Ifb3c6c881decd643da1b662956ded69db4b39431
2013-02-20 17:34:14 -08:00
Aaron Schulz
f8988e0894 [JobQueue] Allow certain job types to always opt out of retries.
Change-Id: I4cdd43b0b248700e199947e99d2df32b91e23ef7
2013-02-19 16:58:34 -08:00
Aaron Schulz
3283a2dd0a Treat a null result of Job::run() like "true".
Change-Id: Ie5b725b9d8aad9d6b1869242e82b13306b61478f
2013-02-13 10:58:18 -08:00
Siebrand Mazeland
ea1f4d1bb4 Start yelling if a job's run() does not return bool
Change-Id: Ia31be9cc5bac1427225c993911a1f77e8654f778
2013-02-13 19:49:44 +01:00
Aaron Schulz
0ca0e1296c [JobQueue] Improved job recycle rate for small queues.
* Make the recycling a bit more periodic rather than based on
  how often pop() gets called essentially. This works better if
  a queue does not have jobs inserted very often.

Change-Id: I64fbc8afbb1cf096717ba4bfc6fe7b7715abdb72
2013-02-06 09:49:34 -08:00
Aaron Schulz
77ae02cebf [JobQueue] Re-try jobs that fail normally.
* Jobs will be re-attempted if run() returns false.
  This means that claimTTL is useful beyond just the case
  where runners get killed in the middle of a job or an
  uncaught exception is thrown.
* Moved MAX_ATTEMPTS constant up to base class.
* Clarified docs a bit.

Change-Id: Id7f970e82a63aa563e9a7a023ce32e5d6680433a
2013-01-31 06:26:20 +00:00
Aaron Schulz
7ed3ea6213 Fixed slave check when the job type is not specified.
Change-Id: I6bee31d149330ead537b9deebb57294f12ce9e02
2013-01-26 19:09:33 -08:00
Aaron Schulz
9583884e2d Added a read-only check to runJobs.php to avoid log spam.
Change-Id: I049fe087d7e9c59383de8efb34e40d311804951a
2013-01-17 15:17:26 -08:00