Commit graph

28 commits

Author SHA1 Message Date
Aaron Schulz
f8c2486d15 rdbms: rename CONN_TRX_AUTO constant to CONN_TRX_AUTOCOMMIT
The "AUTO" means AUTOCOMMIT, not "automatic transactions"/DBO_TRX,
which is basically the opposite concept. The new name does not
suffer from that ambiguity.

Keep the old constant as an alias for backwards compatibility.

Also remove LoadBalancer comment about non-existing field

Change-Id: I63beeb061fc9be73f320308e4d6393b58628b8c8
2018-04-12 13:01:52 -07:00
Umherirrender
45da581551 Use ::class to resolve class names in tests
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
2018-01-26 22:49:13 +01:00
Aaron Schulz
14ee3f2107 rdbms: specify DB name and table prefix even for the local domain
When LoadBalancer opens new local domain connections, it currently
assumes that the domain specified by the server info array is the
same. For sanity, make sure that the handle is set to the local
domain.

The main LBFactory/LoadBalancer use $wgDBname/$wgDBprefix as the
local domain, corresponding with wfWikiId(). This relation is set
automatically in MWLBFactory. If $wgLBFactoryConf/$wgDBservers is
manually configured in a way breaking this correspondance, then it
is misconfigured.

Fixes made to avoid test failure:
* Make sure LoadBalancer::setDomainPrefix() updates the local
  domain alias member. Also do not bother changing the domain of
  foreign connections.
* Use the right domain ID for the connection array key names in
  LoadBalancer::openForeignConnection().
* Now that JobQueueTest no longer mistakenly uses the non-test
  tables, force it to use the main DB_MASTER handle so that it can
  see the unit test tables even if they are TEMPORARY; such tables
  are tied to the TCP connection, so separate handles see different
  temporary tables.

Change-Id: I56f8b32fe957f984b8c9753e6db3b20abe96b038
2018-01-16 17:06:52 +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
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
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
Timo Tijhof
3b35719e74 tests: Remove unused $wgMemc resets
If we really need this we can do it in MediaWikiTestCase, next
to the setting of wgMainCacheType. But from what I can see the
code being tested here already doesn't use the old $wgMemc.

Change-Id: I9e4b2109b2f3c18d8d5551bbadae5711c1d4c0a6
2015-12-06 18:06:08 +00:00
Aaron Schulz
247610aea0 Various JobQueue test tweaks
* Remove some getAcquiredCount() assertions when claimTTL=0
  as this is not well defined enough (queues may take a few
  minutes to garbage collect the failed jobs).
* Added some tests to make sure push() only de-duplicates
  among unclaimed jobs.

Change-Id: Ie0a5e539095c245dfcc8c160417e12824eb7ab83
2015-11-09 21:24:34 -08:00
Antoine Musso
7fff25afc1 Remove useless sleep() in JobQueueTest
I noticed JobQueueTest::testRootDeduplication takes ~ 6.5 seconds, which
is due to the test method using sleep(1) and being passed the provider
provider_queueLists which yields six items.

The reason is to have the array returned by Job::newRootJobParams() to
have an incread value for 'rootJobTimestamp'.  Instead, just copy the
previous array of parameters and increment the UNIX timestamp and
converting back to TS_MW format.

Change-Id: I75066df73f9f92e56b89eb6d928c41e949a2d6a9
2014-10-24 14:31:00 +02:00
addshore
892a992ab8 Remove MediaWikiPHPUnitCommand
All functionality has been moved to other places

Change-Id: I6b6b0ef846bc63108c4dff9e17098432fd9d1697
2014-08-02 21:35:34 +00:00
Aaron Schulz
94c37ffb96 Revert "Revert "Removed useless JobQueue return values""
Made the obvious update to a caller missed in the change.

This reverts commit c76d5a95c1.

Change-Id: I67400ba5b9fc7de16c9f9d5075c488c5e58cea9e
2014-04-16 11:22:31 -07:00
Reedy
c76d5a95c1 Revert "Removed useless JobQueue return values"
This reverts commit bc8c89d2df.

Bug: 64007

Change-Id: I4b4dbe4637dc50cd4630ef19d54f01efba10e138
2014-04-16 17:41:53 +00:00
Aaron Schulz
bc8c89d2df Removed useless JobQueue return values
* This are already totally redundant to the use of exceptions

Change-Id: Ia706ac0122a7dd7f418e2dc2d3bd36e9a0252c25
2014-04-02 17:56:05 -07:00
addshore
aea1b27db0 @covers tags for more test classes
Change-Id: I19d49c279646a4b4c595700e53b790ba4eb9521e
2013-10-24 20:35:04 +01:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
Aaron Schulz
266e46a5ca [JobQueue] Added a function to delete all jobs from a queue.
Change-Id: Ibad122148bdd2f7baf528929e15bae803fccfeea
2013-05-15 10:59:18 -07:00
Timo Tijhof
4bd5471ca3 docs: Remove odd colons after @todo
Most were this way already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/todo.html

Ran a find/replace on the odd ones. Also made them all
lower case.

Change-Id: I70c6a69344ddebc603e9a1c1d87e3cc4f4f4c560
2013-05-15 06:23:40 +00:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Aaron Schulz
720ba67b5f Added a quick test for getAllQueuedJobs().
Change-Id: Ia39461bc1e2356da1a694bf1898b8ca8e4200ff8
2013-04-09 14:32:20 -07:00
Siebrand Mazeland
6da93fc6f6 Update code formatting
Also update some previous inconsistencies pointed out by Krinkle in change IDs:
* Ide20743a2e84ff68549286120e6cff9d9f396f54
* I811ca957b6588085d67606ebc0cd4033a1e53839

Change-Id: Ife33b931870d0d7e04fcb40974997436d27f528f
2013-03-27 14:15:11 +01:00
jenkins-bot
b3d9004342 Merge "Tests: Use more setMwGlobals" 2013-03-22 19:15:03 +00:00
Timo Tijhof
b36d883017 Tests: Make phpunit providers "public static".
Follows-up I9d2b148e57 (including phpunit/languages this time).

Bug: 46434
Change-Id: I30e5efcd88c516121c454676bd7a18f9b7c8fca6
2013-03-22 03:12:37 +01:00
umherirrender
ff3485ec99 Tests: Use more setMwGlobals
Change some tests to use setMwGlobals to have restoring of globals after
the test.
This also removes some save/restore code, which is not needed, due to
the automatically restoring on tearDown with setMwGlobals.

Change-Id: I8d2ac9f6cc14f0bd4ee8eb851c09f2e71babc6e0
2013-03-21 20:35:44 +01:00
Aaron Schulz
cc3ac23c4f [JobQueue] Optimized redis queue to use Lua scripts.
* Cleaned up some data structures into hashes, which get better
  compression and play well with the KEYS parameter in Lua scripts.
  The claim list is now a sorted set with O(logN) removal in ack()
  and O(log(N)+M) searching in recycleAndDeleteStaleJobs().
* Made the class itself control object serialization, so that lua
  scripts have an easy time. Only the job data itself needs to be
  serialized, where as other things just get bloated.
* Used Lua scripts to get push(), pop() and ack() down to 1 RTT.
* Likewise rewrote recycleAndDeleteStaleJobs() to use a script.
* Fixed bug where claimed duplicate jobs removed the data on ack(),
  which meant that claimed duplicated jobs could no-op newer ones.
  De-duplication should only apply to unclaimed jobs like for the
  JobQueueDB class, so that unfinished jobs don't no-op new ones.
* Removed locking in recycleAndDeleteStaleJobs(), which would not do
  much since the exclusive set request would serialize on the lua
  script anyway. The lua script will finish quickly the next times
  if done more than once in a row due to sorted set usage.
  Also made recycleAndDeleteStaleJobs() run randomly to reduce the
  chance of a single calling tying up the server.
* Removed useless hDel() call in getJobFromUidInternal().
* Changed unit tests to handle the different supported orders better.
  Added tests for the 'timestamp' ordering.

Change-Id: Ib2d7aff18753195248ab856afd4a46e18b301db9
2013-03-20 01:04:53 +00:00
umherirrender
8764b3aa7c Remove spaces in function signature
Change-Id: I45aea7a7af88cd913b2f485913620a8af0ab2fed
2013-03-18 20:44:43 +01:00
Aaron Schulz
9cc7e6a39a [JobQueue] Cleanups for JobQueueRedis.
* Cleaned up 'server' option to not fragment the pool.
  Also made it actually match the documentation.
* Made it use doGetPeriodicTasks() for job recycling.
* Made it so that other job queue classes can be tested.
* Renamed "redisConf" => "redisConfig".
* Tweaked comments about the "random" order option.

Change-Id: I7823d90010e6bc9d581435c3be92830c5ba68480
2013-02-21 05:38:01 +00:00
Siebrand Mazeland
de04f37ef1 Update formatting
5 of n.

Change-Id: I811ca957b6588085d67606ebc0cd4033a1e53839
2013-02-15 12:35:50 +00:00
Aaron Schulz
5e81bffce0 [JobQueue] Added unit tests for job queue code.
Change-Id: I13f2dd555ea807b5d13ea9fbee6626d6a8f5aab3
2013-02-07 09:18:10 -08:00