Commit graph

67 commits

Author SHA1 Message Date
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
Ori Livneh
b739bf5a74 Add ObjectCache::getMainClusterInstance()
Provide a complement to ObjectCache::getMainWANInstance() and
ObjectCache::getMainStashInstance() which gets the default ObjectCache
instance.

Change-Id: Ib16ee40908b159e60be41a308db49a9291b5de0d
2015-10-10 00:48:33 +00:00
Marius Hoch
e6e4ffd2f4 Fix ObjectCache::newAccelerator with string fallback in PHP 5.3
Because in PHP5.3:

php > $a = "hash";
php > echo isset( $a['fallback'] );
1
php > echo $a['fallback'];
h

This will fix using MediaWiki with MySQL on PHP5.3
if neither APC, xcache nor wincache are available.

Change-Id: Iebf034be75b282e2654cd298713455caf062eda4
2015-10-03 19:15:33 +02:00
Timo Tijhof
9afd767226 objectcache: Implement 'fallback' param for newAccelerator()
This way it can be used in $wgObjectCaches using 'factory', whilst
also specifying a fallback.

Change-Id: I8d4de1e2a394e7e915513fae91808fe32a21f75d
2015-10-02 12:01:38 -07:00
Aaron Schulz
2cdcea5c9e Improved getMainStashInstance() docs
Change-Id: I49e5c112478927387244214917fb06907c22186f
2015-08-28 16:24:13 -07:00
Timo Tijhof
62e3da7e58 objectcache: Document the primary entry points people should use
There are imho too many ObjectCache methods, $wg*Cache* variables,
CACHE_ types, and wfGet*Cache() functions to know which ones
should actually be used publicly. This should make it easier to
know which ones should be used.

The difference between them was also harder to understand with the
main documentation sections about each of these living in
conceptually different places:
- classes (WANObjectCache)
- methods (ObjectCache::getMainStashInstance)
- variables (DefaultSettings: wgMainCacheType, wgMainWANCache, wgMainStash)

Also:
* Correct wfGetCache() documentation.
* Add the missing keywords for 'public' visibility.

Change-Id: I3b05fdb8b7888bf7e3f05bdca36538f3484556b8
2015-08-25 03:11:15 +02:00
Timo Tijhof
79ce51d1c9 objectcache: Make first parameter of newAccelerator optional
Makes it more convenient to use.

Change-Id: I1e11f7a759bd2816e47d1c2453cbe39b8f44b2f0
2015-08-24 23:43:19 +02:00
Aaron Schulz
c3dec1193c Added BagOStuff READ_LATEST flag for replicated stores
Bug: T88493
Change-Id: I7ea050a2eabba635f2aadb4e33b6f8fbfb1b01a8
2015-08-04 16:03:37 -07:00
Timo Tijhof
7b20e0ef7a objectcache: Minor code clean up in ObjectCache.php
* Whitespace.
* Simplify logic.
* Apply coding conventions to documentation blocks (empty line
  before annotations, no empty lines between annotation, consistent
  order of annotations).

Change-Id: I3e5268d6a6295643d5725c66ea2a01bccf610ed8
2015-06-10 04:53:41 +01:00
Aaron Schulz
793d01401c Added ObjectCache::getMainStashInstance() and $wgMainStash
* This provides factory/config more appropriate for stashes
* Cleaned up some neighboring config comments while at it

Bug: T88493
Bug: T97620
Change-Id: Id370ee50be6e493a4700c858df863a183abc05fd
2015-05-18 11:39:14 -07:00
Aaron Schulz
1f48d8e193 Added ObjectCache::getMainWANInstance() helper method
Change-Id: I3d8d93b3bb6f7e06fae7adc694e6d4d851b2d8c2
2015-04-27 14:28:43 -07:00
Aaron Schulz
3a1f8b1111 Added WANObjectCache class
This class handles caching across distance sites where purges
must reach both. It also aims to make purging more reliable in
the face of network glitches and node consistent hash ejection.

bug: T88492
Change-Id: I686811b3075bf22e2f4de45127e8461e54648ead
2015-04-23 21:36:42 +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
Kunal Mehta
ed90263776 objectcache: Use Psr\Log\LoggerInterface instead of wfDebug
ObjectCache::newFromParams() will handle a 'loggroup' parameter
specially, getting an instance of \Psr\Log\LoggerInterface to
pass to the BagsOStuff.

BagOStuff implementations can use $this->logger which will be
an implementation of \Psr\Log\LoggerInterface. As this is set in
BagOStuff::__construct(), all subclasses must now call the
parent constructor.

The goal of this is to make the logging in BagOStuff non-MediaWiki
specific, in the hopes of separating it out into a separate library
in the future.

Change-Id: I8a8e278e6f028814499d8457d6d5341d03eabc7a
2015-01-30 22:03:23 +00:00
Brad Jorsch
1128c8d56f Allow CACHE_NONE as a fallback for ObjectCache::newAccelerator
Test for null specifically rather than falsiness,
because CACHE_NONE is 0.

Bug: T86162
Change-Id: I98b9da42c6a5fd6cdf721cdbd5473a5e959581b8
2015-01-08 12:58:17 +00:00
Aaron Schulz
f9ddcb0453 Made getMaxLag() use caching to reduce connection spam
* This method is currently hit when bots use the maxlag API parameter
* Also added a $fallback param to ObjectCache::newAccelerator so code
  does not have to keep reinventing that logic.

Change-Id: I45bf1085301c5cf69b29b494a146c6a067534581
2014-07-10 10:46:42 -07:00
Siebrand Mazeland
a36be914c3 Pass phpcs-strict on includes/objectcache/
Change-Id: Ib99f2e34255df0cc846727b134d1788aec48529d
2014-05-11 16:52:18 +00:00
umherirrender
fd66273c94 Fixed some @params documentation (includes/[cache|objectcache])
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: I86fd10e3f2d4bb80e7432533038d124693acfb3c
2014-04-19 01:19:46 +02:00
jeroendedauw
9104af80ef Fix return types in documentation
Change-Id: I726e6201a737ab406dd0e46754d2bbbd95e769b4
2013-06-28 23:48:31 +02:00
umherirrender
892ee7a4af Fixed spacing in db/debug/diff/externalstore/objectcache folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I32a43c547630ce31b6b25cc1bc9eedc50e67b2d7
2013-04-20 22:28:52 +02:00
umherirrender
ca31ebad3f fix some spacing
Added/removed spaces after opening/before closing parentheses

Added a space after a comma

Removed unneeded parentheses in condition

Change-Id: I306091347ccaaf11dee0cdfda3019cb0c12be51b
2013-02-09 23:03:53 +01:00
Niklas Laxström
ac7e23b553 Typofix
Change-Id: I50bf84c3d7f75f6d2a0f3d4f8e86622486f2be28
2012-11-14 07:43:02 +00:00
umherirrender
c66d868e6d Remove a bunch of trailing spaces and unneeded newlines
Change-Id: I166a171c196f4c2c75886be12f913ffa9a4a35ad
2012-10-19 22:10:42 +02:00