Commit graph

89 commits

Author SHA1 Message Date
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
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
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
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
Amir Sarabadani
bcf61a7080 Fix mistake in ObjectCache doc
Change-Id: Iafe3c460ca462aa160cfea6769fd78f8b023548c
2017-03-10 13:12:43 +03:30
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
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
Subramanya Sastry
fc05a13a2d Trivial: Typo fix in comment
Change-Id: I7ad1ee3ca1e3007e70b5566209e3bbbc9b19201a
2016-09-07 14:44:14 -05:00
Aaron Schulz
16266edff3 Change "slave" => "replica DB" in /includes
Change-Id: Icb716219c9335ff8fa447b1733d04b71d9712bf9
2016-09-05 21:01:01 +00:00
Amir Sarabadani
efa0d7af44 Clean up array() syntax in docs, part III
Also fixing some typos here and there

Change-Id: I29c29acf87f84ba9993ba75ebf2ad8091d981574
2016-08-13 05:40:40 +04:30
Bartosz Dziewoński
a49b3216fc Canonicalise '@deprecated since' doc comments
Change-Id: I440041512feb47a998efb45e76e3fd00e0655752
2016-08-02 22:21:57 +00:00
Aaron Schulz
5f921702d2 Avoid stack overflow in LoadBalancer with CACHE_DB WAN/server cache
* Add the ability to expose key BagOStuff attributes like whether the
  emulation SQL cache is being used. Several callers use hacks to detect
  this and can be updated later.
* Fallback to a safe empty WAN cache in the CACHE_DB case. This fixes
  a regression from f4bf52e843.
* Also add this protection to the server cache, which could break
  similarly before too.
* Also fix CACHE_ANYTHING by avoid the recursion risk from
  fc1d4d7960 by just checking the disabled service map.

Bug: T123829
Bug: T141804
Change-Id: I17ee26138f69e01ec1aaddb55ab27caa4d542193
2016-08-02 13:06:49 +00:00
daniel
fc1d4d7960 Fix installer issues introduces by MediaWikiServices
This fixes three issues with the installer:

1) Make sure LocalizationCache can find the installer's i18n files.
2) Make sure we don't try to use an SqlBagOStuff for caching before we have
   a functioning database.
3) Don't try to output HTML when redirecting (this is unrelated to
   MediaWikiServices, but came up during testing)

Bug: T135169
Change-Id: I7caa932024cd771d6fa226a3ac6001c3148ecc9c
2016-05-17 15:24:31 +00:00
Stanislav Malyshev
4f95365877 Convert EventRelayerGroup to services infrastructure
Change-Id: If55ddf441de69189c7fcdd3440f899c6b14f690f
2016-04-25 14:22:31 -07:00
Aaron Schulz
09a0a5e4f6 Make WAN cache config use $wgEventRelayerConfig
This makes the channels more explicit and defined in a less
ad-hoc way. Systems like Kafka would prefer explicit channel
definitions anyway, so the channel prefix just obscures things.

Change-Id: I5631eb1b1382083396a0f08904d9273cc92601e8
2016-04-25 12:08:09 -07:00
Bryan Davis
450bb6723d BagOStuff: Optionally log duplicate key lookups
Add new 'reportDupes' parameter to BagOStuff. This parameter enables scheduling
of a callback after the current web request ends. This callback will emit warning
log messages for all keys that were requested more than once.

The default ObjectCache factory for MediaWiki enables this option by default.
Not by default for plain BagOStuff instances, however. E.g. `new HashBagOStuff()`.

It also set 'asyncHandler' for all classes now (not just MultiWriteBagOStuff).

Bug: T128125
Co-Authored-By: Timo Tijhof <krinklemail@gmail.com>
Change-Id: I8a2b06cf54d2acf5950eed71756ecdf50e224be1
2016-04-22 04:21:20 +00:00
Bartosz Dziewoński
361b09576e Remove comments about isset( $string['foo'] ) being true on PHP 5.3
...but don't remove the code. Calling isset( $bar['foo'] ) without checking
that $bar is an array seems not very nice to me.

Change-Id: I822c925b6f36bf34902f8075e54f71fe4f6d2566
2016-02-17 20:12: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
Timo Tijhof
185f6e17c6 objectcache: Improve entry point docs and fix typo in READ_LATEST
Add missing colon in "BagOStuff::READ_LATEST".

Change-Id: I93f55299b49b5240e3ef6354d3a1fca2b416e40d
2015-12-07 19:54:16 +00:00
jenkins-bot
f6f9869534 Merge "User: Migrate from foreign cache to global cache for UserRightsProxy" 2015-11-02 23:51:52 +00:00
jenkins-bot
dad19d999c Merge "Convert SiteStatsUpdate to using getMainStashInstance()" 2015-11-02 22:47:10 +00:00
Timo Tijhof
b3acd4fb5d User: Migrate from foreign cache to global cache for UserRightsProxy
Avoid having one wiki access another wiki's local keyspace.
Instead, use the global keyspace to share values across wikis.

Also, imitating wfMemcKey from wfForeignMemcKey was semantically
incorrect due to $wgCachePrefix having precedence. Most interfaces
(e.g. UserRightsProxy, FileRepo, JobQueue etc.) only have access
to the wiki id (dbname + prefix). The local cache configuration
for wgCachePrefix is not and shouldn't have to be exposed.

Start enforcing that local cache keys are left private and
to share keys, one must use global keys.

Global keys (prefixed with "global:") have their own space and we
can use the wiki-id as regular key segment for keys about users.

Also:
* Expose a method to keep formatting of this key in one place.
  As it used used in many different places in core, as well
  as in CentralAuth.
* Make use of wfWikiId() in getDefaultKeyspace() to avoid
  duplicating this logic.

Change-Id: I58836a24b9e239f460ab489bd2fe8ced8259833c
2015-11-02 21:39:46 +00:00
Aaron Schulz
17c91ad610 Replace newAccelerator() with getLocalServerInstance()
The name is clearer and more consistent, with simpler arguments.

Change-Id: I7205a99ce033e8b086a52cd02c8a721e99c84b1e
2015-11-02 21:39:08 +00:00
Aaron Schulz
6cc65335f3 Convert SiteStatsUpdate to using getMainStashInstance()
Also fixed various $wgMemc related comments

Change-Id: I20602b672f724c8df1e82bbe3c586cb899a54640
2015-10-31 13:05:03 -07:00
Timo Tijhof
e970b79d4c objectcache: Use singleton cache in newAccelerator()
It was re-creating objects for each call.

This matches behaviour of newAnything().

Bug: T115729
Change-Id: If12aedae7f9f791eb8e233eb241c12efd2921762
2015-10-30 22:25:37 +00:00
jenkins-bot
30135f1dec Merge "Protect WAN cache sets() against uncommitted data" 2015-10-27 10:18:52 +00:00
Aaron Schulz
6344e0b185 Update CACHE_MEMCACHED to not used newMemcached
* Follow up to 0dd27b1da9
* Also removed that method, which is not used by callers

Bug: T116541
Change-Id: Ic6e4e25089de112cfd263fb042d654ee06970859
2015-10-25 18:27:21 +00:00
Aaron Schulz
dc646b464c Protect WAN cache sets() against uncommitted data
This generally only effects wikis with no slave DBs,
but also matters if the master has non-zero LB load.
If the master ends up being used for DB_SLAVE, care
should be shown for cache-aside writes

Interesting WAN cache events are now logged.

Change-Id: I2cd8e84138263c13ea23beb9ab3d7562340e1fd3
2015-10-24 17:21:22 -07:00
Aaron Schulz
0dd27b1da9 Move MemcachedBagOStuff b/c logic to ObjectCache
Change-Id: Iedb173b00d543237b3e7560b8079b8d488e00d80
2015-10-24 15:09:28 -07:00
Aaron Schulz
1171cc00cd Inject MultiWriteBagOStuff addCallableUpdate() dependency
Inject the DeferredUpdates::addCallableUpdate method via the
ObjectCache. This brings it closer to being able to move to /libs.

Change-Id: Ifa0d893002c3d709a4dc7346c263a92162274bd7
2015-10-20 10:31:36 -07:00
Aaron Schulz
cb862afaf3 Rename getMainClusterInstance() -> getLocalClusterInstance()
Also corrected some ObjectCache docs

Change-Id: I322f4cbd72fbd5d4c6887d90ee75d0baddb6ac25
2015-10-20 00:26:21 +00:00
Aaron Schulz
d4895d5c70 Add make(Global)Key() method to WANObjectCache
Change-Id: I8e739fbe8614c9bd1c3595bbf16c8cd423aff7cc
2015-10-19 12:55:30 -07:00
jenkins-bot
7436cd31a2 Merge "Add makeKey and makeGlobalKey to BagOStuff" 2015-10-17 01:06:12 +00:00
Ori Livneh
6916548490 Add makeKey and makeGlobalKey to BagOStuff
* Add a string `keyspace` member to BagOStuff instances. The default
  implementation, meant for simple key/value stores, treats the key space
  as a string prefix to prepend to keys. By default, its value is `local`,
  but any instance created via ObjectCache::newFromParams() (or or one of
  its callers) will have that default to $wgCachePrefix / wfWikiID().
* Add `makeKey` and `makeGlobalKey` methods to the base BagOStuff class.
  These methods are not static to allow for BagOStuff types which require
  a configured instance to know the underlying storage engine's key semantics.
* Make wfMemcKey() and wfGlobalCacheKey() delegate to these methods on the main
  ObjectCache instance.

Change-Id: Ib7fc2f939be3decfa97f66af8c2431c51039905f
2015-10-13 09:32:48 -04:00
Aaron Schulz
1a6151e3a6 Caching documentation tweaks and doxygen cleanups
Change-Id: I4b37a6c7d267d4eb0b39b313d92e6c0bf87d460e
2015-10-10 01:06:37 -07:00