Commit graph

33 commits

Author SHA1 Message Date
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
Ricordisamoa
60be0296c3 Stop doing $that = $this in includes/libs
Closures support $this as of PHP 5.4

Change-Id: I1b5a5d7e619029684cb8d2a8d150fcc13051c2e0
2016-02-10 18:26:25 +01:00
Brad Jorsch
25dbd91513 Clean up after Ie161e0f
Ie161e0f was done in a hurry, and so didn't do things in the best ways.
This introduces a new "CachedBagOStuff" that transparently handles all
the logic that had been copy-pasted all over in Ie161e0f.

The differences between CachedBagOStuff and MultiWriteBagOStuff are:
* CachedBagOStuff supports only one "backend".
* There's a flag for writes to only go to the in-memory cache.
* The in-memory cache is always updated.
* Locks go to the backend cache (with MultiWriteBagOStuff, it would wind
  up going to the HashBagOStuff used for the in-memory cache).

Change-Id: Iea494729bd2e8c6c5ab8facf4c241232e31e8215
2016-02-03 21:45:18 +00:00
Aaron Schulz
5ffaa6ae0d Avoid "Unable to set value to APCBagOStuff" exceptions
* This can happen due to incr/add races. Use incrWithInit()
  instead to handle such cases.
* Also made BagOStuff:incrWithInit() return the new value like incr().

Change-Id: I0e3b02a4cff7c20544a9db2eaabd3f61e5a470b1
2015-12-21 20:41:43 -08:00
Timo Tijhof
e8275758fe objectcache: Introduce IExpiringStore for convenient TTL constants
Also consistently use self:: instead of BagOStuff:: for constants
referenced within the BagOStuff class.

Change-Id: I20fde9fa5cddcc9e92fa6a02b05dc7effa846742
2015-10-28 04:07:25 +00:00
Ori Livneh
0c9fb12265 Escape colons in BagOStuff key segments
For the sake of safety and correctness, the following BagOStuff::makeKey()
invocations should return distinct keys:

   $cache->makeKey( 'ab:', 'cd' );
   $cache->makeKey( 'ab', ':cd' );

That is not currently the case, because while we use ':' as a key path
separator, we don't escape ':' in the input supplied to makeKey(). So, make
BagOStuff::makeKeyInternal() URL-encode colons.

To prevent this from messing up the max. key length calculations, reproduce
this logic in MemcachedBagOStuff::makeKeyInternal(), in lieu of having the
method call its parent.

Change-Id: I83ea7e7336a1c9e64aa42284c2517089a736efe5
2015-10-23 20:26:49 -07:00
Aaron Schulz
fb7022c54d Bound BagOStuff::lock() RTT estimate for sanity
The timestamp difference might be 0 (or in rare cases, less)

Change-Id: I0298b413df637d9da5ff33c078ad49dadc8a46ce
2015-10-21 20:14:54 -07:00
jenkins-bot
409e7d6a70 Merge "objectcache: Fix grammar error in BagOStuff::getWithToken doc" 2015-10-22 02:33:16 +00:00
Aaron Schulz
5c8ef13306 Add WRITE_SYNC flag to BagOStuff::set()/merge()
* This blocks on writing to all replicas
  and returns false if any failed.
* This is useful if ChronologyProtector is to work across
  domains by having the writes go everywhere so that later
  reads will see them (and be local at the same time).
* Redundant doc comments were also removed.

Change-Id: I9ed098d563c64dba605e7809bc96731da3b3e79d
2015-10-22 01:44:09 +00:00
Timo Tijhof
92b197dc59 objectcache: Fix grammar error in BagOStuff::getWithToken doc
Follows-up 1fa1235d32.

Change-Id: I19a4430609423f5ff32a1014ed21131175469adf
2015-10-22 02:35:35 +01:00
Aaron Schulz
d4895d5c70 Add make(Global)Key() method to WANObjectCache
Change-Id: I8e739fbe8614c9bd1c3595bbf16c8cd423aff7cc
2015-10-19 12:55:30 -07: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
b39fcc855c Add get() flags support to BagOStuff::getWithSetCallback()
Change-Id: Ib6046f5bc5d8c0481f90b56c381ba761fee558d6
2015-10-07 20:51:00 -07:00
Aaron Schulz
1fa1235d32 Clean up BagOStuff::get() interface
* Callers of get() no longer have to contend with
  the annoying $casToken parameter, which is there
  but totally unusable to non-BagOStuff code.
* The default get() now delegates to doGet(),
  which callers must implement instead. They can
  ignore the overhead of generating $casToken if
  they do not implement cas(), which applies to
  callers that use the stock merge(). If cas() is
  used for merge(), then getWithToken() must be
  implemented.
* Also add BagOStuff::READ_LATEST to mergeViaCas()
  for sanity, as that missing before.
  Likewise with mergeViaLock().

Change-Id: I4efce6a9ab4b1eadd2f161dff641004a7239c516
2015-10-07 02:54:57 +00:00
Aaron Schulz
355ba8530e objectcache: Add BagOStuff::getWithSetCallback() convenience method
Change-Id: I9cc162ff1cc48c1c500f2999327bd18ba235bfd0
2015-10-05 17:26:32 -07:00
Aaron Schulz
54991403ff objectcache: Add BagOStuff::READ_VERIFIED flag to get()
* This lets multiwrite backends upgrade cached items
  to higher tiers using UPGRADE_TTL.
* This is useful for memcached/sql tiers or apc/memcached.

Change-Id: I34b30ce8b54f8de36429d48c80f6768aed310272
2015-10-05 16:03:00 -07:00
Aaron Schulz
c9b1fe1896 Added reentrant lock support to BagOStuff
* Also fixed HashBagOStuff::delete() return value for non-keys

Change-Id: I9a977750c6fc6b8406bc1c9366a6b1b34bf48b6b
2015-08-25 01:17:45 +00:00
Kunal Mehta
221acd4ee4 BagOStuff: Don't try to access a protected variable in a closure
Follows up 78f1fee559.

Change-Id: Id356509cc55a5953351dfd98896cf01055739ee0
2015-08-23 15:31:36 -07:00
jenkins-bot
27155a28ea Merge "BagOStuff: Don't use $this in a closure" 2015-08-21 20:50:29 +00:00
Kunal Mehta
78f1fee559 BagOStuff: Don't use $this in a closure
Change-Id: Ib9fb92a70adc2b4d75c30148e17dff6f7765afe1
2015-08-21 20:41:11 +00:00
Aaron Schulz
7b997f4ae5 Fixed IDE error in mergeViaLock()
Change-Id: I50b5a22bf353272ad6960181db07c2f4ec857f3c
2015-08-21 20:37:02 +00:00
Aaron Schulz
d8931781e8 Fixed BagOStuff getScopedLock() docs
Change-Id: I4d6d3211e93ee1c279728ff787acff558a47fbee
2015-08-19 19:28:01 +00:00
Aaron Schulz
97c7a897c8 Avoid some possible deadlocks on account creation
* This uses a non-blocking $wgMemc lock to reserve the user
  name in question. This should prevent two threads from
  reaching LOCK IN SHARE MODE and getting stuck on INSERT.
  The lock is global to better cover auth plugins.
* This adds a BagOStuff::getScopedLock() convenience method.
  It uses less queries than LockManager by being EX only.
* Avoid extra lock attempt in lock() in non-blocking mode.
* Removed (un)lock() HashBagOStuff overrides that made it
  behave differently than other caches (wrt to re-entrance).

Bug: T106850
Change-Id: Iecf95206d712367f5d202f76ab0eaa9d7bdabf2b
2015-08-17 21:33:50 -07:00
Aaron Schulz
4065e4d1ab Made BagOStuff::merge() avoid retries on I/O errors
Change-Id: Ia2fd61132322ed3fa8909d60d9f7eb42e39cb443
2015-08-07 04:31:15 +00: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
Aaron Schulz
4fe54ae2db Removed partly obsolete and redundant BagOStuff comment
Change-Id: I265912276af8f2bcdba4e49b4cc522df0a39a5db
2015-05-25 20:33:55 -07:00
Aaron Schulz
a2ea6116af Fixed some <code> tags for doxygen
Change-Id: I550b8760556e4916ee9b63ee244bbbcb4d926142
2015-04-29 06:01:59 +01:00
jenkins-bot
fe4b02f1d1 Merge "Cleaned up a few exceptions and IDE errors in BagOStuff" 2015-04-27 20:28:41 +00:00
Aaron Schulz
f208215e8b Cleaned up a few exceptions and IDE errors in BagOStuff
Change-Id: I7ae88009f50c259c20572349b5d01480e36f7cb8
2015-04-27 20:20:19 +00:00
Aaron Schulz
67b835194a Fixed getLagTimes() locking
* Previously it deleted the value it just cached due to a missing suffix,
  which would lead to connection spam to get the new lag values.

Change-Id: I1040b2b87d3d4ddd7c368291cab87daf4227c2d0
2015-04-27 20:19:28 +00: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
Aaron Schulz
dfc5afc286 BagOStuff doc tweaks
Change-Id: I0eea84bbbc4c742c07a35a2b157517ad9dd40bb8
2015-04-20 10:23:07 -07:00
Kunal Mehta
1e3888de00 Start moving objectcache into libs/
The base BagOStuff class and some of the implementations are
not dependent on MediaWiki and can be in the libs folder.

Change-Id: I299f9abb778abc65a70461a2aff3015c02a1f04d
2015-02-25 00:22:50 -08:00
Renamed from includes/objectcache/BagOStuff.php (Browse further)