Commit graph

380 commits

Author SHA1 Message Date
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
jenkins-bot
5b1eb3a2ab Merge "Rename getMainClusterInstance() -> getLocalClusterInstance()" 2015-10-20 00:37:31 +00: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
922f15e8e0 Remove ObjectCache dependency from MultiWriteBagOStuff
This brings it closer to being able to move to /libs.

Change-Id: Ia733f9023e56d4a25ffcb99ca0cc8b29cbb2ad45
2015-10-20 00:16:51 +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
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
7c07943eab Update more docs and type hints to use IDatabase
Change-Id: I8c8d85b32a8aba21e14d2a2dde4c25eb509186c1
2015-10-06 18:49:52 -07:00
jenkins-bot
480f4e6f75 Merge "objectcache: Add BagOStuff::READ_VERIFIED flag to get()" 2015-10-05 23:13:24 +00: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
a88df43d3f Database debug log cleanup (remove wgDebugDumpSqlLength/wgDebugDBTransactions)
* Simplify the debug log call and use queries group
* Remove $wgDebugDumpSqlLength, as profiler output
  already has shortened query strings (one can use
  profiling without DBO_DEBUG)
* Removed $wgDebugDBTransactions as BEGIN/COMMIT already show
* Removed PostgresTransactionState as it was only used for
  $wgDebugDBTransactions handling
* This cuts down on lots of global variable usage

Change-Id: I185adb1694441d074dea965960429b4910727620
2015-10-05 12:47:09 -07: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
jenkins-bot
9dfb45cc7c Merge "Fix Memcached key decode" 2015-09-30 00:43:19 +00:00
Matthias Mullie
8ca796ea99 Fix Memcached key decode
Flow had a key: flowdb:flow_ref:wiki:by-source:v3:Parser\'s_"broken"_+_(page)_&_grill:testwiki:1:4.7
the '+' in there was not being encoded (it only does /[\x00-\x20\x25\x7f]+/)
but coming back, it was decoded into ' '.
getMulti() shows a key=>value array or results. Since key was different,
we couldn't find what we had requested.

Bug: T110326
Change-Id: Ia92edd73d0eb7fe0d35e38e7e7af8174fb85cbcc
2015-09-28 19:37:53 +02:00
Amir E. Aharoni
c6f066b88c Make long lines shorter to pass phpcs in 6 files
Bug: T102614
Change-Id: I3159c33ddd16bded94a70f363258a294f407fc58
2015-09-26 17:07:06 +00:00
jenkins-bot
8aafaa30df Merge "Fixes for RedisBagOStuff when using twemproxy" 2015-09-22 14:48:08 +00:00
Aaron Schulz
6303f0396f Merge "Cleaned up $asyncWrites member variable in MultiWriteBagOStuff" 2015-09-21 18:55:15 +00:00
Aaron Schulz
551940b382 Cleaned up $asyncWrites member variable in MultiWriteBagOStuff
Change-Id: I27e48aef77ac0f6453b7837f2b2686b7b5b726d4
2015-09-21 11:41:44 -07:00
Ori Livneh
481d5a3221 MultiWriteBagOStuff: require nonempty 'caches' param
MultiWriteBagOStuff::__construct() barfs if the 'caches' parameter is unset,
but it permits it to be an empty array. This means that subsequent operations
that need to reference the first (primary) cache backend need to check that
it is there at all.

Since there is not much sense in having a MultiWriteBagOStuff object with zero
cache backends, make the constructor require a nonempty array for 'caches', and
remove the subsequent checks that are made redundant by this new restriction.

Change-Id: I30f3e0dcbfe67570a368e64b8233cc0ba7f90b2f
2015-09-21 11:34:15 -07:00
Aaron Schulz
fd8e85fc2d Support async writes to secondary MultiWriteBagOStuff stores
* This is useful for ParserCache, as it tries to focus on memcached
  and use other caches (e.g. mariadb) for the long-tail of less used
  content, as setup on WMF. The class uses BagOStuff in a way that is
  compatible with this approach.

Bug: T109751
Change-Id: Ia64eb44a9b52a988fde27b468d604d9163bed4b4
2015-09-18 21:35:43 -07:00
Aaron Schulz
45fea5f477 Fixes for RedisBagOStuff when using twemproxy
* Use the nx/ex flags for the redis SET method
  to implement add() correctly. This also handes a
  prior FIXME comment.
* Made merge() work via locking instead of cas()
  since Redis::MULTI does not work with twemproxy.
  Locking, which uses add(), does, and works better
  than it did before.
* Removed some pointless newlines.

Change-Id: I652bd0ad2c594097d2cb1ab77f291e8bd27ad14f
2015-09-16 10:20:38 -07:00
Matthias Mullie
58c81f5b86 Decode Memcached keys before returning getMulti result
Keys are sent to Memcached encoded. However, getMulti()
will respond in [key => value] format. The keys it
responds with should not be the encoded versions, or
callers won't be able to map them to the results.

Bug: T111138
Change-Id: I0d821b1219a492be8e93453f0249c78f18e24533
2015-09-07 05:43:49 +00:00
Aaron Schulz
2cdcea5c9e Improved getMainStashInstance() docs
Change-Id: I49e5c112478927387244214917fb06907c22186f
2015-08-28 16:24:13 -07:00
jenkins-bot
f0c88b2163 Merge "Added reentrant lock support to BagOStuff" 2015-08-25 01:28:24 +00: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
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
4f0b16b914 Fixed BufferingStatsdDataFactory::timing() callers to use ms
* The interface actually demands this

Change-Id: I1e334c2696a8a8eca73a6ae7f71428190cad3107
2015-08-19 01:01:49 +00:00
Aaron Schulz
3bf391e842 Added statsd metrics for ObjectCacheSessionHandler
Change-Id: I86e967a027e2010f962831b55a9fceab02d8a19e
2015-08-13 13:04:28 -07:00
Aaron Schulz
08039b2df4 Restored I4afaecd8: "Avoiding writing sessions for no reason"
* After 203d2c9c11, the refresh updates should actually trigger

This reverts commit e48fec5a8a.

Change-Id: I8427ed5b3a5bb80033cbdf071a33f8a3999ecb97
2015-08-11 21:46:05 +00:00
jenkins-bot
e341ad3ec5 Merge "Fixed @var doc in MultiWriteBagOStuff" 2015-08-11 20:29:45 +00:00
Aaron Schulz
012db9afc2 Fixed @var doc in MultiWriteBagOStuff
Change-Id: I53384460b7a6ccda50a23e3ab1fc614198e82d1a
2015-08-11 13:10:28 -07:00
Ori Livneh
2d607c444b Fix argument handling in MultiWriteBagOStuff::get()
Follow-up for I7ea050a2ea.

Change-Id: Ibaa4cf01ee913c7a725d1719c00308ef3c6b0aff
2015-08-11 13:02:44 -07:00
Aaron Schulz
203d2c9c11 Moved ObjectCacheSessionHandler renewal logic to wfSetupSession()
* This should trigger more reliably than the shutdown function
  callback, which is really only there for sanity to make sure
  session close/write happens.

Change-Id: I9a1aa76de121ba8de33b3fa850bd223929fae404
2015-08-10 19:10:38 +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
Ori.livneh
e48fec5a8a Revert I4afaecd8: Avoiding writing sessions for no reason
I4afaecd8 reduced the frequency at which the TTL of sessions keys is reset, on
the assumption that we were doing it a whole lot more often than necessary.
We can now assume that this assumption was false, because an uncommitted revert
of this change which I pushed to production earlier caused the rate of session
loss errors in the logs to plummet.

Bug: T102199
Change-Id: Ie67f4ca000afcf3d4f44155c13f91cd4c286866d
2015-07-31 23:30:11 +00:00
Matthew Flaschen
16c81325ed array_shift returns null on empty array, not false
Change-Id: I690f9dd0de11ff60f9cba9f401c6e456e7ba8bd6
2015-07-30 21:27:07 -04:00
Ori Livneh
1d526cae81 RedisBagOStuff: if no alternatives, skip master link status check
If RedisBagOStuff::getConnection() is able to establish a connection, only
check the master link status if automatic failover is enabled and if there are
other viable servers left to consider. If there are no servers left to
consider, or if automatic failover is not configured, just return the
connection handle without subjecting it to further tests.

This will have the side-effect of making RedisBagOStuff compatible with
Nutcracker, which does not implement the INFO command. This is because when
MediaWiki is configured to use Nutcracker, the server pool will consist of a
single server (namely, Nutcracker itself), and thus there will be no other
server to consider, so INFO will never be executed.

Change-Id: I3812ec5a0b22df122bdf44350bc0496574c02ce8
2015-07-28 16:22:57 -07:00
jenkins-bot
b95d41c62b Merge "objectcache: Ensure an integer put into memcached comes out an integer" 2015-07-09 14:20:24 +00:00
jenkins-bot
8195fd3551 Merge "Improved fail-over in ReplicatedBagOStuff for redis" 2015-07-08 06:44:42 +00:00
jenkins-bot
5de749d207 Merge "Made SqlBagOStuff set() wrap setMulti()" 2015-07-02 08:14:36 +00:00
Erik Bernhardson
508d8ee79b objectcache: Ensure an integer put into memcached comes out an integer
Some parts of resourceloader put an integer into the BagOStuff
and rejects any value it pulls back out that is not an integer.
This patch updates the memcached client behind the BagOStuff to
flag integer values and convert them back to integer when recieved.
The end result is shaving several seconds off the time it takes to
request a CSS or JS file in certain configurations.

Bug: 60563
Change-Id: Ie4dc8cf2c2cd232a2c167b4075ff4254b656bcbc
2015-07-01 03:51:55 +00:00
jenkins-bot
7bc770bbd8 Merge "Made SqlBagOStuff unset DB handles on connection errors" 2015-06-28 00:28:30 +00:00
Aaron Schulz
29dbdc3a64 Made SqlBagOStuff set() wrap setMulti()
* This also makes sure garbageCollect() is called on writes from
  time to time, since set() is used much more often

Change-Id: I5b6cc686bd6204fc3d6ff8b003be8b8d6a493e24
2015-06-24 13:16:50 -07:00
jenkins-bot
799ca9856b Merge "Made ReplicatedBagOStuff wrapping the SQL class the default stash" 2015-06-24 20:09:53 +00:00
Aaron Schulz
4825b4c08e Made ReplicatedBagOStuff wrapping the SQL class the default stash
* To make this work, a slaveOnly flag was added to SqlBagOStuff
  and it no longer prunes expired items on get(), it just treats
  them as missing. The use of garbageCollect() for the writeFactory
  cache and the use of replace() on updates already makes this
  a non-issue.
* This also makes the default $wgMainStash non-bogus.

Bug: T88493
Change-Id: I9d1f31305e08430de29a3cd521cdb10a82dffd10
2015-06-24 19:37:03 +00:00
Aaron Schulz
674858617a Made SqlBagOStuff unset DB handles on connection errors
* A "gone away" error can trigger ping(), which can fail,
  triggering a full open(). If this fails (as it often will),
  mConn is false and the DatabaseBase object is not usable.

Bug: T103435
Change-Id: Id2aaed87d2642e73c7811076da908180ee5ab5a4
2015-06-23 12:28:03 -07:00
Aaron Schulz
646fdc978c Added pre-emptive session renewal to avoid "random" submission errors
* The session will be renewed on access if it will expire in 10 minutes
* This avoids a problem both with 532ef78 + PHP <= 5.5 or any PHP >= 5.6

Bug: T102199
Change-Id: I8cad100bc35e86fa95ad144bcad338f3cb5d82a1
2015-06-18 21:51:15 +00:00
umherirrender
d8821f2b0b Fixed spacing
- Removed space after casts
- Removed spaces in array index
- Added spaces around string concat
- Added space after words: switch, foreach
- else if -> elseif
- Removed parentheses around require_once, because it is not a function
- Added newline at end of file
- Removed double spaces
- Added spaces around operations
- Removed repeated newlines

Bug: T102609
Change-Id: Ib860222b24f8ad8e9062cd4dc42ec88dc63fb49e
2015-06-17 20:22:32 +00:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00: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
jenkins-bot
af2f7e00c3 Merge "Added ObjectCache::getMainStashInstance() and $wgMainStash" 2015-05-19 07:44:44 +00: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
42bf202b19 Added RedisBagOStuff FIXME comments
Change-Id: I6f4f85166584439a38d632356f3ed95e4fd4fd6f
2015-05-15 23:00:16 +00:00
Aaron Schulz
e45d07d7fd Improved fail-over in ReplicatedBagOStuff for redis
Bug: T96123
Change-Id: I3f37417a1a4f010b092a7718d43bfcdfe16e8f4c
2015-05-02 13:45:41 -07:00
Aaron Schulz
63c132e050 Refactored ReplicatedBagOStuff to use generic factory methods
* Moved the class to /libs as is possible now

Change-Id: I6b724cf4b2ea627d485acb1e1882a5a04772d6f6
2015-04-29 20:08:19 -07:00
Aaron Schulz
1f48d8e193 Added ObjectCache::getMainWANInstance() helper method
Change-Id: I3d8d93b3bb6f7e06fae7adc694e6d4d851b2d8c2
2015-04-27 14:28:43 -07:00
Aaron Schulz
c7bf955bca Moved WAN cache and relayer to /libs
Change-Id: I9586d22890ce1cda7f74869ff701de73d65eaaef
2015-04-27 12:35:58 -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
Aaron Schulz
cbe67ce13b Make RedisBagOStuff support tag name hashing
Bug: T95126
Change-Id: I266dd30c93cfc44395eba5bca64f451ca77c23a4
2015-04-07 07:12:10 +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
Aaron Schulz
b48f51c522 Minor doc fixes
Change-Id: I80678e64cafcfd6e2c779452f466d8a630089568
2015-03-09 23:08:37 -07:00
Aaron Schulz
61df5e785f Made SqlBagOStuff avoid tripping TransactionProfiler
* Set a custom profiler with no expectations to avoid tripping
  the "0 write" expection. This avoids useless log entries.

Change-Id: Iac849a729eb36b1a8affb0dbc8b8c195fab4b03a
2015-02-27 17:45:48 +00:00
jenkins-bot
087e70d6d2 Merge "Start moving objectcache into libs/" 2015-02-25 16:04:49 +00: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
Aaron Schulz
0a873a3c28 Avoid calling rollback() in handleWriteError() if there is no trx
Change-Id: Ic3be89151160ad57acda5d95e3995a77f3835717
2015-02-24 11:34:23 -08:00
jenkins-bot
8256db3493 Merge "Removed cas() from ReplicatedBagOStuff as it is unused" 2015-02-23 19:21:39 +00:00
aude
e653640924 Make HashBagOStuff::lock() compatible with BagOStuff::lock
Fixes php strict standard error.

Bug: T90427
Change-Id: Ica2bddead9b5ad367510e898eeea1257a53b5b19
2015-02-23 12:35:55 +01:00
Aaron Schulz
40bfb9bfa0 Removed cas() from ReplicatedBagOStuff as it is unused
Change-Id: I2ff33ba806856ec4cc140a52590a922e13191bf2
2015-02-22 21:38:30 -08:00
jenkins-bot
e2e2fff1eb Merge "Made BagOStuff::cas properly optional" 2015-02-23 05:32:38 +00:00
Aaron Schulz
250f2b9e5a Made BagOStuff::cas properly optional
* merge() using the locking version by default. The callers that implement cas()
  override merge() to use the cas-based version. Those that do not no longer
  need to define the unused dummy method.
* Removed some redundant doc blocks.

Change-Id: I49f7dd5432efa8d76f4758c273f0859376ddafb7
2015-02-23 05:15:24 +00:00
Aaron Schulz
3817818aca Add a ReplicatedBagOStuff class
Bug: T88634
Change-Id: I1f7cccd6ac376055ff2b84641ff38a85571c65b0
2015-02-23 05:09:08 +00:00
jenkins-bot
014615d926 Merge "Made BagOStuff::debug protected" 2015-02-12 17:17:30 +00:00
Aaron Schulz
fd2c11c24b Made BagOStuff::merge() take any callable
Change-Id: I5ce99b8d343f1629f888a3b7594976a83839e2b7
2015-02-11 12:20:41 -08:00
Aaron Schulz
61697bab1e Made BagOStuff::cas protected, which is just one merge() implementation
Change-Id: I3ef82226231f7e03f7493ae042cad22339f4c869
2015-02-10 10:38:41 -08:00
Aaron Schulz
532ef7851c Avoiding writing sessions for no reason
bug: T88635
Change-Id: I4afaecd8dc29390b1ee2a6a77f9ca0cba333ef92
2015-02-10 18:14:02 +00:00
Aaron Schulz
ac8d6b3538 Removed old SqlBagOStuff alias
Change-Id: I6fdd8791713ce9ed67473065332266c217284974
2015-02-06 02:03:04 -08:00
jenkins-bot
2da34d0a9c Merge "Removed unused and poorly supported time argument to BagOStuff::delete" 2015-02-05 02:28:01 +00:00
Aaron Schulz
659ebf050d Made BagOStuff::debug protected
Change-Id: Ic05961e49e30d2537b411030b2b891adcc29a29e
2015-02-02 03:57:37 +00: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
Aaron Schulz
13d1a86eef Removed unused and poorly supported time argument to BagOStuff::delete
Change-Id: I8f90f480ec8bc70605c85c39f73f29df21d1927d
2015-01-26 17:14:33 -08:00
Aaron Schulz
24c970667e Tweaked BagOStuff::lock() retry times slightly to be faster
Change-Id: Id04e373dcd2ed57951b68432fcd7491f4288b028
2015-01-14 11:54:38 -08: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
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
Reedy
4d9143c7f5 Add lots of @throws
Change-Id: I09d0c13070f966fcf23d2638d8fc1328279a5995
2014-12-24 13:49:20 +00:00
jenkins-bot
b0dcb13e9b Merge "Made $timeout in BagOStuff::lock() actually work" 2014-11-20 09:39:41 +00:00
Aaron Schulz
1fa3a4d678 Unbreak lock()/unlock() for MemcachedPhpBagOStuff
Change-Id: I49ce96b65fe6a6e2cba86a990962fe4efc43bbb8
2014-11-20 01:25:38 -08:00
Aaron Schulz
19f3068ce5 Made $timeout in BagOStuff::lock() actually work
* Also added a separate $expiry option for things that take a long time

Change-Id: Ie5f81dea031f3c3f3ca8d61ad4cb322a5b876f61
2014-11-20 00:26:44 -08:00
Kunal Mehta
dd8fef31e7 ObjectCacheSessionHandler::getCache() returns BagOStuff
Change-Id: I7f514857154297c7033dd26af97b6ac83c13f104
2014-11-13 12:53:50 -08:00
Sergio Santoro
807b24eb27 SqlBagOStuff: reuse code of parent class
It'll be easier to change the time threshold (currently 10 years)
in the future.

Change-Id: I24005148d40c47905d5b20cfd506decef2ae447e
2014-10-25 19:26:21 +02:00
Sergio Santoro
4c79d2e7e4 SqlBagOStuff: fix percentage in deleteObjectsExpiringBefore()
Partial deletion percentage progess was computed using
$remainingSeconds. This is incorrect since $remainingSeconds
is going to *decrease* ( instead of increase ) while the
process continues.
The correct implementation uses 'processed seconds' instead.

Change-Id: Ic745f6e8375a85da543de36703fad6d31f62ea90
2014-10-16 20:43:38 +02:00
Sergio Santoro
9ae3d27ef0 SqlBagOStuff: document public method deleteAll()
Change-Id: I23700714453b6243e564642f2bad4a2d1c2469c6
2014-10-15 22:57:53 +02:00
Reedy
f3ae6fa6cc Fix expires typo in comment
Change-Id: I4bb63f610ce0ec246c4aa7aef3d04f096fb3e564
2014-10-08 16:55:52 +01:00
Tim Starling
9f0d40e08f HashBagOStuff: use the value itself as the CAS token
Avoid an unnecessary serialize() call on get() requests, which makes it
faster and also happens to work around a nasty crash bug which is
causing lots of segfaults right now.

CAS semantics should be the same, if the caller handles a CAS token in
an opaque way and does not assume it is a string. I could only find one
caller of cas() in core and WMF deployed extensions, and that is
BagOStuff::mergeViaCas(), which does correctly handle CAS tokens of any
type.

Bug: 71724
Change-Id: I0b0b5f0157c005ec7f76210dfb8576c056314733
2014-10-07 16:29:57 +11:00
Aaron Schulz
330e18c45d Removed MultiWriteBagOStuff::replace
Change-Id: Ifa6373cda099d1b87e90592598267987e9185a25
2014-09-12 11:13:06 -07:00
Aaron Schulz
9d59d4088e Removed deprecated BagOStuff::replace() method
Change-Id: Ife2f8e0f10ad7be76b79d5aee435491ea78d4655
2014-09-12 02:03:32 -07:00
Aaron Schulz
eaf2f36483 Make sure getMulti() returns an array per the class interface
Change-Id: Ic08f3ac37467a2743d7f8be5f5fb0032f84c3b82
2014-09-03 20:17:28 +00:00
umherirrender
63dc5abc9a Fixed spacing
- Added space after reserved words: function, foreach, if
- Combined 'else if' into elseif
- Added braces to one-line statements
- Added spaces after comma, before parentheses

Change-Id: Ie5bbf680d6fbe0f0872dab2700c16b1394906a72
2014-08-27 18:31:50 +02:00
Bryan Davis
d7c8c3446d Ensure that expiry times are given as integers
Fixes "Fatal error: Argument 4 passed to Memcached::cas() must be an
instance of int, float given".

Change-Id: Ibf1ea638ec1a4dcf009cdaea8aa66008c74ff30b
2014-08-22 09:55:59 -06:00
addshore
dfd4c8c2a2 Use public instead of var in classes
Change-Id: I16d1714ba37667d8c9c7c79a765c7199ea0023e4
2014-08-17 21:07:37 +01:00
umherirrender
3b2b6a2773 Add missing @param to function docs
Change-Id: I47fa96a976f55a1a93cb75397285edb8c7f4cd8a
2014-08-14 20:22:52 +02:00
jenkins-bot
088a8bd2b4 Merge "Revert "Made LCStoreDB try to use a separate DB connection"" 2014-08-13 21:01:36 +00:00
umherirrender
21e0c1c533 Correct variable names in @param to match method declarations
Some @param have a typo in the variable name,
some @param's were in wrong order.

Change-Id: Ie25806831027112b398f6f4a909c59147ac3a5fa
2014-08-13 21:48:28 +02:00
C. Scott Ananian
9c0fff5a4b Revert "Made LCStoreDB try to use a separate DB connection"
This commit broke `php tests/parserTests.php`.

This reverts commit 4c0871fa0e.

Bug: 69082
Change-Id: If0781f8f51681717a848ec359c7b8c70932ed72d
2014-08-03 17:40:03 -04:00
jenkins-bot
627e33ed36 Merge "Cleanup some docs (includes/[m-r])" 2014-07-25 17:14:53 +00:00
jenkins-bot
9fc8b2228e Merge "Check for boolean false result from database query in SqlBagOStuff" 2014-07-25 01:31:55 +00:00
umherirrender
dd8921c9d9 Cleanup some docs (includes/[m-r])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I8ebfbcea0e2ae2670553822acedde49c1aa7e98d
2014-07-24 19:43:25 +02:00
umherirrender
abfa0d7854 Standardize @todo
Always use lowercase @todo
Changed some "@FIXME" to "@todo FIXME: "

Change-Id: I016d1f9511e6f3bbd22427f0fffeccd77ab5e0db
2014-07-23 22:27:20 +02:00
Ori Livneh
a1f1850252 Check for boolean false result from database query in SqlBagOStuff
Database::select() can return false, so we should check for it before
attempting to iterate on the result or to call methods on it.

Change-Id: I0862493305e5b2784422e0e94b3e62e734267795
2014-07-21 15:13:31 +02:00
umherirrender
2b021dc48a Fixed spacing
- Added/removed spaces around parenthesis
- Added space after switch/if/foreach
- changed else if to elseif

Change-Id: I99cda543e0e077320091addd75c188cb6e3a42c2
2014-07-19 23:12:10 +02:00
Aaron Schulz
d9385014fe Avoid breaking DB transactions in SqlBagOStuff
* Callers still sees some decent time ordering since writes block
  until committed. This will not blindly flush transactions though.
* Basically reverts 59e8032

Change-Id: Ib9a91ac023f8e3fafb0bf0eef9dca6e31b867be9
2014-07-16 17:59:36 +00:00
Aaron Schulz
4c0871fa0e Made LCStoreDB try to use a separate DB connection
* This avoids breaking the main transaction in finishWrite().
* Also removed an unused variable in SqlBagOStuff.

Change-Id: Ia330ac362b080c1338616d95b793032c4752dc23
2014-07-15 19:20:01 -07:00
Erik Bernhardson
ca4690d823 Correct out of date comment
The comment claims there is no cas method, but that was
implemented in 74f581e348

Change-Id: I6ffdc255204bcb3a03b0468c18609b0d30b6269c
2014-07-11 20:07:00 -07: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
Matthew Flaschen
737653546a Don't unserialize integer reply from Redis incrBy
It does not work with unserialize because RedisBagOStuff->unserialize
expects either strings of digits, or serialized strings.  A plain integer
is neither.

incr docs were incorrect, so fix and expand by copying from parent class.

Change-Id: Ifc9c7a36f221b251ceea0d9a79ae6c3ce5753dd4
2014-06-27 18:24:35 -04:00
jenkins-bot
ad6289a7e9 Merge "objectcache: Actually unserialize integers as integers in RedisBagOStuff" 2014-06-27 18:47:27 +00:00
Aaron Schulz
211d6062e1 Add some casts for sanity before BagOStuff::add() calls
Change-Id: I6ecb609c88e4fc1ef614e94c551199bd610ca360
2014-06-26 16:25:31 -07:00
Timo Tijhof
eb0a3b7830 objectcache: Actually unserialize integers as integers in RedisBagOStuff
Before:
> SET   (stored)    GET
>  5     5          (string) "5"
>  '5'   5          (string) "5"
>  'x'   s:1:"x";   (string) "x"

After:
> SET   (stored)    GET
>  5     5          (int) 5
>  '5'   s:1:"5";   (string) "5"
>  'x'   s:1:"x";   (string) "x"

Follows-up 2ceda41c57.

Bug: 60563
Change-Id: I2bb09381b2bb733ac5a89175e053cb10eca68b08
2014-06-26 23:06:39 +00:00
Niklas Laxström
cc0a51fd39 Don't die on empty keys in MWMemcached
Bug: 64287
Change-Id: Iedfec96286212577a181b83957cdc4545be206d2
2014-06-05 08:09:47 +00:00
Matthias Mullie
63b22fe634 Cached misses in getMulti should be omitted
SqlBagOStuff::getMulti currently returns an array with false values for missed
cache keys.
Default BagOStuff::getMulti (and other specific implementations like memcached),
however, just omit missed values.

e.g.:

    $cache->getMulti( array( 'goodkey' 'badkey' ) );

should return

    array( 'goodkey' => 'value' );

instead of

    array( 'goodkey' => 'value', 'badkey' => false );

Bug: 65637
Change-Id: Ib2de06a0f76421094707f7ad4218346087f4dc55
2014-05-22 17:19:22 +02:00
Siebrand Mazeland
a36be914c3 Pass phpcs-strict on includes/objectcache/
Change-Id: Ib99f2e34255df0cc846727b134d1788aec48529d
2014-05-11 16:52:18 +00:00
Kunal Mehta
c592011404 Add BagOStuff::setMulti for batch insertions
Includes implementions for Redis, Sql and MemcachedPecl,
other types will fallback to using $this->set repeatedly.

Change-Id: I0924a197b28ee69e883128ccd672343e5c041929
2014-04-25 15:12:22 -07:00
Aaron Schulz
89d85a4be4 Added pool counter support for all thumb.php requests
* This can limit how many workers work on a given file at once,
  regardless of which specific thumbnail parameters are requested.
* Also added a BagOStuff::incrWithInit() method per DRY.
* Tweaked the register_shutdown_function() callback to avoid
  File/MediaTransformOutput references, since they may involve
  TempFSFile objects.

Change-Id: Ic01461cb974ab23b179ac3b60cf6de12e36360f6
2014-04-23 20:57:17 +00:00
umherirrender
23bb3d1cb4 Follow-Ups to "Fixed some @params documentation"
Fix of inline comments of the following patch sets:
Follow-Up: I0056b4a8df243cfc0c5f25378de48f7a35170aca
Follow-Up: I7f605aa9e117b5fd80d9b1440864fe526d2b14a5
Follow-Up: I3622f216a2ca8ac1b5e51892be9f98665f65bc36
Follow-Up: I6627ba0e76d3577c40bf2473e0f78a5ad7368634
Follow-Up: Id75b5ecf648ca50f955b3bde3307c82c4366b102
Follow-Up: I4ca5231119f33039d91da3b57a41cd40719a576b

Change-Id: Id9bbe84b2820e9db44af5783411e955f55f643d4
2014-04-23 13:39:49 +02:00
umherirrender
b9cd789fce docs: closure -> Closure; callback -> callable
Changed closure to capital word Closure in doc and type hint,
also changed callback in docs to callable

Change-Id: I52c8e8f13d38a837052101c38b9986be780ca057
2014-04-19 08:43:31 +02: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
Bartosz Dziewoński
59002d8935 Consistently use '@deprecated since <version>'
Variants included 'in <version>', 'as of <version>' and just the
version number.

Some @deprecated annotations do not have the version number at all,
I want to hunt them down separately.

Change-Id: I8208c6097098f4735d4f51bc42254675f1f27f6d
2014-04-15 22:18:19 +02:00
umherirrender
23fab68274 Fix spacing after @param and friends in comments
Searched for:
\@(param|return|throws|since|deprecated|access|todo|var)[ \t]{2,}

Change-Id: Icce22ba9fe0635455691ca58d9872d618151f346
2014-04-05 20:02:29 +00:00
Alexandre Emsenhuber
28fe01dcdc Remove trailing line break check from MemcachedBagOStuff::debugLog()
wfDebugLog() already does the same, so it's unnecessary here.

Change-Id: Ia7bbbd2806fcd638861d010835c33969322d262a
2014-04-05 20:28:06 +02:00
Aaron Schulz
4d7f18f6d5 Made BagOStuff fail fast in cas/lock on certain errors
* This avoids wasting time waiting on down servers

bug: 63058
Change-Id: Ia78a2036ffa7a20102ec9e8bf941cacb7fa63435
2014-04-01 13:26:44 -07:00
Aaron Schulz
587a98aa02 Lowered high lock timeout in mergeViaLock() and lock() in BagOStuff
Change-Id: Ib5cd0a98ce6ec47edb24f8cc9f4df2c941ce1c38
2014-03-25 17:14:33 +00:00
umherirrender
2000672ac3 Fixed spacing
- Added spaces after if/foreach/catch
- Added new line before end of file
- Added or removed spaces before/after parenthesis, comma
- Added spaces around string concat

Change-Id: I0590070f1b3542108e242730e8d9a3ba9831e94f
2014-03-20 20:37:30 +00:00
Ladsgroup
a90f1a2d79 Changing URLs of mediawiki.org in scripts to the SSL-based website
http://www.mediawiki.org --> https://www.mediawiki.org

Part 3

Change-Id: Ica633881b1744fa2854f4b012b79dbf5a7e5e7e2
2014-03-13 22:28:14 +00:00
Aaron Schulz
83dd6d7e3d Deprecated useless BagOStuff::replace method
* Almost nothing actually uses this (one extension)
  as it doesn't really solve race conditions like merge().
* Removed subclassed versions too.

Change-Id: I4d4123afcc0576a90a3cbf1e4e6daff7ebce39c3
2014-03-09 02:53:04 +00:00
Aaron Schulz
4265d8f23f Added simpler handleError() method in RedisConnectionPool
* Callers should not need to give $server since it is stored in RedisConnRef

Change-Id: I902d984d6a7f19dd0d8c71ee374cbed359de378e
2014-02-12 07:29:32 +00:00
Alexandre Emsenhuber
8d701eeeea Remove trailing line breaks from wfDebugLog() messages
This is useless since the message is passed through trim() and a
line break is added afterwards.

Change-Id: I1a26b30a07f7c9c749fce5bb6b2b4b3d79901b7c
2014-02-04 22:16:13 +01:00
tonythomas01
225f1b724c Removed version check for mysql 4.1.0 from SqlBahOStuff::createTables
Presently mysql v5.0.2 or later is supported.

Bug: 59125
Change-Id: I9043a6f792c6479a85411addbe9fd448ed5e02a6
2014-01-28 15:43:32 +05:30
Siebrand Mazeland
eabdda4fba Remove FakeMemCachedClient
Was deprecated in 1.18. Not used in core or Gerrit extensions.

Change-Id: I06bc9c6f01f21386c772fa7fad57b55a7c7b2fe4
2014-01-22 17:17:18 +00:00
Chad Horohoe
736820f8f2 Remove DBABagOStuff
Isn't useful outside of testing as the comments state, but it's
barely even useful for that. People who are testing the cache
code can use CACHE_DB if CACHE_MEMCACHED is too hard.

Change-Id: Ief0aa148376957fdd844c8bb585a133b854a012c
2014-01-16 11:43:59 -08:00
Chad Horohoe
19873e7693 Ehcache more like mehcache
mehcache isn't a caching system, it's a pun.

I'm removing Ehcache support because it's an experiment didn't pan out
and the code's just sitting here abandoned now.

Change-Id: Ief5728b4c61bb5ad8f5a5f0b55415b23ef6727eb
2014-01-16 18:44:09 +00:00
Matthias Mullie
2a4dfa169b Don't use complex datatypes as CAS tokens
For caches where CAS is not natively supported, we have a workaround, where the
CAS token is (based on) the stored value.

To confirm the data can be written to cache, the CAS token is compared against
"whatever is currently in cache", so we pull the cached data and rebuild the
value.

In the case of objects, we have now pulled & rebuilt (unserialized) 2 objects
that are actually the same object (for CAS purpose - it's the correct value to
overwrite), but in terms of ===, they're 2 different values.

This patch should make sure CAS tokens are always a serialized version of the
value we're saving (where no native CAS exists); these serialized versions can
reliably be compared.

Bug: 59941
Change-Id: I2760416c48f2ceb7a0e0c874dd70ec07b4dccdfc
2014-01-14 16:45:32 +01:00
Joel Natividad
bee00fcac9 changed memcached server parsing to allow for local unix domain socket connections
* This works with local memcached (e.g. unix:///var/run/memcached/memcached.sock:0 )
  and noticeably increases memcached mediawiki performance

Change-Id: Ie08c151caa09eb0a4269df88965d71c2367c398b
2013-12-31 11:10:53 -08:00
jenkins-bot
dd981eb7b5 Merge "Fixes to RedisBagOStuff" 2013-12-03 20:48:20 +00:00
Aaron Schulz
2ceda41c57 Fixes to RedisBagOStuff
* Avoid serializing scalars like the memcached client does.
  This means incr/decr can be fast and preserve the TTL.
* Properly call unwatch() in the cas() method.
* Made the expiry set on add() actually atomic.
* Also cleaned up the profiling calls.

bug: 56069
Change-Id: I3e0d1c4888062544c54aef32085f8ce608ff5423
2013-12-03 11:56:24 -08:00
umherirrender
0bc583af2c Move closing parenthesis from multi line if and function to own line
The Line continuation Coding conventions prefers the closing parenthesis
on the same line than the beginning curly braces. This is done for ifs
and functions.
Also move some boolean operator from the end of a line to the beginning
and changed some indentation to make the condition hopefully better
readable.

Change-Id: Id0437b06bde86eb5a75bc59eefa19e7edb624426
2013-12-01 21:39:00 +01:00
Aaron Schulz
59e803274b Made SqlBagOStuff fully avoid transactions when possible
Change-Id: I775d872b522f68462496bbfa685665cc8faf9bf1
2013-11-21 16:26:24 -08:00