Commit graph

380 commits

Author SHA1 Message Date
jenkins-bot
bd78869618 Merge "No yoda conditions" 2018-12-09 01:34:23 +00:00
Timo Tijhof
6be5e0a92c objectcache: Add urls for mysql bug refs in documentation
Change-Id: Ie5fe5dacae364b2b0c07f2ab0aa9b6777277c10f
2018-12-05 09:20:42 -05:00
Fomafix
3ee1560232 No yoda conditions
Replace
  if ( 42 === $foo )
by
  if ( $foo === 42 )

Change-Id: Ice320ef1ae64a59ed035c20134326b35d454f943
2018-11-21 17:54:39 +01:00
jenkins-bot
988af574cb Merge "Use new WikiMap::getCurrentWikiDomain() for objectcache and profiler keyspace" 2018-10-30 07:08:27 +00:00
Aaron Schulz
42a6f991e0 Use new WikiMap::getCurrentWikiDomain() for objectcache and profiler keyspace
Change-Id: I0e77c58a55b7ce908ec1d6399ec6629d00a48953
2018-10-30 06:41:07 +00:00
Fomafix
43244db9a2 Use PHP 7 '??' operator instead of if-then-else
Change-Id: If9d4be5d88c8927f63cbb84dfc8181baf62ea3eb
2018-10-21 21:46:46 +02:00
Umherirrender
719bfa8977 Use a ScopedCallback to silence transaction profiler in SqlBagOStuff
This affects most LCStoreDB which is the default cache
and spamming the log.

Bug: T154424
Bug: T97693
Change-Id: I68af177c7d0d88ab266eb3fefb4336eff86d861c
2018-10-12 20:04:31 +02: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
Max Semenik
69aecc2eea Don't initialize MediaWikiServices before extensions have been loaded
Bug: T153256
Bug: T190425
Change-Id: I749f66d13a8c8a8ae4a83661b83c56f0db74a187
2018-05-03 23:36:10 -07:00
Aaron Schulz
8350329922 Avoid warnings in ObjectCache::newWANCacheFromParams if "channels" is not set"
Bug: T192473
Change-Id: I150eef62285e99fc1269a58fee3827e5fbb0537b
2018-04-19 07:53:13 +00:00
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
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Aaron Schulz
8f4ae0d51c Fix LoadBalancer::getMasterPos() callers to handle a non-object being returned
Change-Id: I3356057f27a051835734329afa339ea76842a389
2018-01-12 15:18:14 -08:00
Thiemo Mättig
409da2d8b3 Remove leading backslashes from "use \…" tags
Change-Id: I494b029de089a07e3b946ee78293a12d5036f63e
2017-12-28 16:30:05 +01:00
Aaron Schulz
8ed0b8db05 Only send statsd data for WAN cache in non-CLI mode
Bug: T181385
Change-Id: Ic51a084206cea93621393359ded4ff77beef5f13
2017-12-02 12:34:22 -08:00
Aaron Schulz
73b928750c objectcache: Run preemptive WAN cache refreshes post-send
This keeps HTTP request time consistent in case of expensive keys

Change-Id: I0746fde29a6e2f27d1b92f1af599c741d5972f46
2017-12-01 08:15:26 +00:00
Aaron Schulz
4432e898be Add statsd metric support to WANObjectCache
Bug: T178531
Change-Id: I3037281d09cd5195347789f544deae89711f128b
2017-10-25 01:41:31 +00:00
Aaron Schulz
99c80a8fc7 rdbms: Support secondary autocommit connections in LoadBalancer
This is useful for things like SqlBagOStuff and JobQueueDB
being able to write in auto-commit mode while the main
transaction round still goes on.

SqlBagOStuff already had this sort of logic.

JobQueueDB now also takes this approach so it does not have to
defer insertion except for sqlite. This makes callers more likely
to know when insertion failed or not.

Make sure LoadBalancer sets "master"/"replica" LB info itself;
this fixes a bug found in the new tests.

Bug: T140338
Bug: T42451
Change-Id: I4199a9598d7afbf976a6efa8ed84b85b56da02bd
2017-08-18 01:28:34 +00:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Aaron Schulz
f24b3899e3 objectcache: Use a separate postgres connection in SqlBagOStuff
The flags to the driver use new connections for new LBs since
fda4d46fc4. This makes it consistent with what we do for
MySQL already.

This should fix warnings about TransactionProfiler in objectcache,
as well as warnings about "Pending writes" in WANObjectCache.

Bug: T167946
Bug: T154424
Change-Id: I0b0d9a7210b6a3270d32df778fcc4b9918d3dcd1
2017-07-06 23:08:06 +00:00
Tim Starling
fb91d409d6 Fix SqlBagOStuff exptime uniqueness assumption
The WMF parser cache tables have some 30000 rows with an identical, old
expiry time. So each time deleteObjectsExpiringBefore() is run, the
first batch on each table is correct, but the keys for the second batch
are selected with exptime > X, where X is shared exptime of the many old
rows.

So, use exptime >= X instead.

Change-Id: I6853f64f88f65d4529be2a42c9ed70cfa62cf653
2017-06-10 20:54:23 +10:00
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
Brian Wolff
c5a0fa5bed objectcache: Never use CACHE_NONE for CACHE_ANYTHING
If $wgMainCacheType = CACHE_ACCEL, but there is no APC, then its
possible that CACHE_ANYTHING will default to CACHE_NONE because
that's what CACHE_ACCEL would do.

Possibly also T147161

Bug: T160519
Change-Id: I9ac2d071437b35a0f9cd3678e2279628f7b1931e
2017-03-30 01:38:15 +00:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
Amir Sarabadani
bcf61a7080 Fix mistake in ObjectCache doc
Change-Id: Iafe3c460ca462aa160cfea6769fd78f8b023548c
2017-03-10 13:12:43 +03:30
jenkins-bot
17eda64357 Merge "includes: Replace implicit Bugzilla bug numbers with Phab ones" 2017-02-28 00:51:57 +00:00
Aaron Schulz
64df456b39 Move remaining LoadBalancer classes to Rdbms
The old names are left as aliases.

Change-Id: I52a327f2463a2ba7437324047b5b00d28cd1d758
2017-02-23 20:38:31 -08:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Aaron Schulz
59053a0716 Move ChronologyProtector/TransactionProfiler to Rdbms namespace
Change-Id: I37a655bd8bd267c9bc32028b55925b2dce527d33
2017-01-26 10:30:57 -08:00
Erik Bernhardson
9053890020 Cleanup static analysis errors
While prepping the code base for using etsy/phan i found a few problems.
A couple are real problems, while others are just places etsy couldn't
figure out the types.

* AuthPlugin referenced UserLoginTemplate which doesn't exist. Tracing
  back usages this accepts classes that extend from BaseTemplate.
* DatabaseSqlite had an invalid @var annotation.
* LoadBalancer had some missing or under-defined annotations. Make them
  more specific where possible.
* SqlBagOStuff didn't have the appropriate use statement for
  WaitConditionLoop and probably doesn't work. Also updated annotations
  that point to non-existent DatabaseBase to use IDatabase.

Change-Id: Iff2270b418ad2f8f97cfdb6df646c435d3283536
2016-12-06 16:10:38 -08:00
Aaron Schulz
f19a4a1566 Clean up newWANCacheFromParams() getInstance() calls
Change-Id: I0daa2531708d0a110e8028c4a5641153a23c0a97
2016-10-23 21:01:03 -07:00
Aaron Schulz
5c59e46a72 Remove deprecated ObjectCache::newAccelerator method
Change-Id: I2be2afe3f2bba830aea4e985005adb72f0e45a82
2016-10-12 15:15:15 -07:00
jenkins-bot
1d95c68977 Merge "ObjectCache::newFromParams fix SqlBagOStuff backcompat" 2016-10-05 21:55:45 +00:00
addshore
b63b3ce036 ObjectCache::newFromParams fix SqlBagOStuff backcompat
Bug: T147407
Change-Id: I718d01b309d96deeb9f7aa1fdcdee9f824657f9d
2016-10-05 22:11:48 +01:00
Aaron Schulz
514d759b58 Add the main stash, WAN, and server caches to MediaWikiServices
Leave getLocalServerInstance() array fallback logic.

Restores 6d99fa5824
Which got reverted by 7ab9283292.

Change-Id: Id1f48e10753d6aaf64eecb4d3c2228740abc1340
2016-10-03 18:36:06 +00:00
Reedy
c214c9a952 Detect/use APCu properly
In PHP 5.5 and above, userland APC caching moved to an extension

Bug: T140587
Change-Id: Ie0871776cd7e67838471a4fe95451cf4164079b7
2016-10-01 23:07:47 +01:00
Hashar
7ab9283292 Revert "Add the main stash, WAN, and server caches to MediaWikiServices"
$ php maintenance/eval.php
 > $wgMessageCacheType = CACHE_ACCEL;

 > wfGetMessageCacheStorage();
 PHP Warning:  Illegal offset type in isset or empty in includes/objectcache/ObjectCache.php on line 93
 PHP Warning:  Illegal offset type in isset or empty in includes/objectcache/ObjectCache.php on line 125
 PHP Notice:  Array to string conversion in includes/objectcache/ObjectCache.php on line 133
 Caught exception InvalidArgumentException: Invalid object cache type "Array" requested. It is not present in $wgObjectCaches.
 #0 includes/objectcache/ObjectCache.php(94): ObjectCache::newFromId(Array)
 #1 includes/objectcache/ObjectCache.php(287): ObjectCache::getInstance(Array)
 #2 [internal function]: ObjectCache::getLocalServerInstance(Array)
 #3 includes/objectcache/ObjectCache.php(181): call_user_func('ObjectCache::ge...', Array)
 #4 includes/objectcache/ObjectCache.php(137): ObjectCache::newFromParams(Array)
 #5 includes/objectcache/ObjectCache.php(94): ObjectCache::newFromId(3)
 #6 includes/GlobalFunctions.php(3430): ObjectCache::getInstance(3)
 #7 maintenance/eval.php(78) : eval()'d code(1): wfGetMessageCacheStorage()
 #8 maintenance/eval.php(78): eval()
 #9 {main}

This reverts commit 6d99fa5824.

Change-Id: I4d756eb6f66318a12d8cbbc1ba546397be8a29bf
2016-09-29 10:46:48 +02:00
Aaron Schulz
6d99fa5824 Add the main stash, WAN, and server caches to MediaWikiServices
Also removed unused getLocalServerInstance() b/c $fallback logic.

Change-Id: Ifa5f798de10783741a7b079f22d283bb9cb7f4c0
2016-09-28 15:35:44 -07:00
Aaron Schulz
5bbac35ed1 Replace DatabaseBase:: with Database:: and update type hints
Change-Id: I3919b04eb2de4fa0bf8a02239fb5bbf17d347511
2016-09-27 04:20:03 +00:00
Aaron Schulz
8729167f13 Move RedisBagOStuff to /libs
Change-Id: Ia49fb044aacb44e53d36c80277783cd806aca439
2016-09-23 20:13:36 -07:00
Aaron Schulz
10593ffaab Move RedisConnectionPool to /libs/redis
Change-Id: Ied4a85d7172ab76b90f6d9ce4d47a83c3fd7d111
2016-09-23 00:20:19 -07:00
Aaron Schulz
64060bea46 Split out new ObjectCache::newWANCacheFromParams() method
Change-Id: Ib2e409dd129bd1e2871fe239e71a4eb8fb42944c
2016-09-21 22:06:37 +00:00
Aaron Schulz
5a3d42dbd8 Use standard exceptions in ObjectCache and always handle CACHE_NONE/"hash"
* If cache CACHE_NONE or "hash" is not set yet or was unset,
  return the proper new object anyway for sanity.
* Also fixed $params typo in newFromParams(). This should not
  have any effect since SqlBagOStuff ignores the key in this case.
* Removed excess "use" statement.

Change-Id: I36108a865273b9c209145828e5e1216b545ef431
2016-09-21 21:49:15 +00:00
Marius Hoch
2d16cb6069 Fix SQLite $wgObjectCaches definition + b/c handling
Follow-up to 47e816c69c

Change-Id: Id94857a7c8726871cf826a34b5cf10cb465b7125
2016-09-19 19:41:23 +00:00
jenkins-bot
d9f412635f Merge "Move PECL memcached class to /libs" 2016-09-14 01:45:02 +00:00
Aaron Schulz
a3dacac90f Support masking the WRITE_SYNC latency from ChronologyProtector
* Use OutputPage::output() as the method to mask latency, since it
  takes a good while to run. By the time it runs, cache replication
  should have caught up, so the reap call will likely not block.
* For redirects emitted after changes in POST, instead of masking
  with OutputPage, add a parameter to the redirect and block on
  the positions appearing. This uses the redirection RTT to mask
  the replication latency.

Change-Id: Ib23690c302e8033610fef9a0ef451dafe8a5803e
2016-09-12 23:58:49 +00:00
Aaron Schulz
05589cad6b Move PECL memcached class to /libs
Remove IP class dependency, which is simple enough here

Change-Id: I3aed6ae6747d8d2b9e75b492e5d5293ba4ce9edd
2016-09-07 22:55:11 -07:00
Subramanya Sastry
fc05a13a2d Trivial: Typo fix in comment
Change-Id: I7ad1ee3ca1e3007e70b5566209e3bbbc9b19201a
2016-09-07 14:44:14 -05:00
Aaron Schulz
57e19b610d Renamed some variables from "slave" to "replica"
Change-Id: I455278294cd7ea344d14a76ac5957ece2e07fbf3
2016-09-05 23:03:01 -07:00