Commit graph

67 commits

Author SHA1 Message Date
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
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
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
Aaron Schulz
0a873a3c28 Avoid calling rollback() in handleWriteError() if there is no trx
Change-Id: Ic3be89151160ad57acda5d95e3995a77f3835717
2015-02-24 11:34:23 -08: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
61697bab1e Made BagOStuff::cas protected, which is just one merge() implementation
Change-Id: I3ef82226231f7e03f7493ae042cad22339f4c869
2015-02-10 10:38:41 -08: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
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
Reedy
4d9143c7f5 Add lots of @throws
Change-Id: I09d0c13070f966fcf23d2638d8fc1328279a5995
2014-12-24 13:49:20 +00: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
umherirrender
3b2b6a2773 Add missing @param to function docs
Change-Id: I47fa96a976f55a1a93cb75397285edb8c7f4cd8a
2014-08-14 20:22:52 +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
9fc8b2228e Merge "Check for boolean false result from database query in SqlBagOStuff" 2014-07-25 01:31:55 +00: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
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
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
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
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
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
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
MatmaRex
df8ec1e216 No spaces after (casts)
Also removed some unnecessary ones. I think I've caught them all.

The spaceless version already appears in core ~300 times (after
accounting for false positives when grepping). Some consistency would
be nice.

Change-Id: I607655b5f4366e66dc78730d5fd2f57ed8776cae
2013-09-04 20:05:43 +02:00
Tim Starling
9407284253 In SqlBagOStuff::getMulti(), catch connect errors
This case was somehow neglected in Ifba0d276. The other methods work
correctly.

Change-Id: If29f0212f07c13bd72469c580bb096a2a41a96b5
2013-04-03 09:56:42 +11:00
Siebrand Mazeland
9b7889b84b Use American English spelling for behavior
Spotted in ipbreason-dropdown by Shirayuki.

Change-Id: I576ed4bc0abe5ab980aaee3fb9f9e4b43087311f
2013-03-04 10:24:57 +01:00
Reedy
b3e34e3c46 Add missing parameter in handleWriteError call
Change-Id: If3ebf6f77d66121bac8e11d43582f1dbb3e88e12
2013-02-27 09:48:32 +00:00
Aaron Schulz
0b442a82e8 [BagOStuff] De-breakified cas() for SqlBagOStuff.
* Seemed to be a functional merge conflict with sharding code.

Change-Id: I1e49790f6b82b09ea2cd6606ca918f0a620a191f
2013-02-15 14:31:19 +00:00
umherirrender
48cd72819e fix some spacing
Change-Id: Ia9650be8b791fd2f0ccbc099436918a9d12d9968
2013-02-04 20:04:26 +00:00
Antoine Musso
f6b92231fd style: normalize end of files
By PSR2 PHP Standard, the files should ends with exactly one newline.
Some of our files have 2 or more and some other were missing a newline.

Fix almost all occurences of CodeSniffer sniff:
PSR2.Files.EndFileNewline.TooMany

I have not fixed the selenium files, I believe we will drop them.

Change-Id: I89fca8c1786fee94855b7b77bb0f364001ee84b6
2013-02-03 15:04:39 +01:00
Demon
0e5f53d262 Merge "Removed useless keys() function from BagOStuff." 2013-01-14 11:48:31 +00:00
Matthias Mullie
74f581e348 Added merge() function to BagOStuff for CAS-like functionality.
* merge() will use CAS if supported or use locking otherwise
* The lock()/unlock() methods now have a default implementation
* added unit tests for merge

Change-Id: Ic27088488f8532f149cb4b36e156516f22880134
2013-01-10 09:03:09 +01:00
Aaron Schulz
692e6103f2 Removed useless keys() function from BagOStuff.
Change-Id: Ie4249b2770de81377019ad383039ab85c0c5de7a
2013-01-07 17:32:27 -08:00
Tim Starling
7c4198805a Use consistent hashing for SqlBagOStuff servers
Also factor out consistent hash code from Redis and the new application
into a class called ArrayUtils. The name "ArrayUtils" is from
I0f4e7d7c, I expect that change will be rebased on top of this one at
some point.

Change-Id: I9375087f4d7a6e8e629d97bfb6b117d9cb7d1bcf
2013-01-04 18:07:07 +00:00
Tim Starling
30d6510f63 Multiple servers in one SqlBagOStuff
Added a multi-server feature to SqlBagOStuff.

Tests done:
* With both the "shard" and multi-server features enabled and
  $wgAllDBsAreLocalhost, tested getMulti, set, incr, decr, keys,
  garbageCollect, deleteAll. Tested wiki page views with
  $wgMainCacheType set to such a cache.
* Tested connection errors.
* In the plain CACHE_DB configuration, tested wiki page views.

Change-Id: Ifba0d276ef724cc9b33f687bc0adae4637054328
2012-12-28 19:13:21 +11:00
Reedy
d537d96868 Add numerous missing @throws to method documentation
Change-Id: Iba868e82a75fef7c7d011bc5be192bf059d037c0
2012-12-09 03:09:48 +00:00
Aaron Schulz
5c164069a3 Fixed warning spam in SqlBagOStuff.
Change-Id: Iac573980596349deab757eac859d9e28dc2963b6
2012-09-16 10:56:52 -07:00
Aaron
ad183cc875 Catch exceptions in SqlBagOStuff and cache connection failures.
Change-Id: I443f1bed3f9ccb40c444dd01ec446b677caf9d03
2012-08-16 12:44:24 -07:00
Reedy
019e74a31a Flesh out parameter documentation etc
Remove some trailing whitespace

A bit of code simplification

Change-Id: Iea96a2482c53868713a43569be4e5de4c9edb2a2
2012-07-09 12:44:13 +00:00
saper
646a9490f7 (bug 27283) SqlBagOStuff breaks PostgreSQL txns
* SqlBagOStuff should not turn off automatic transaction
    control just like that. Keep previous
    connection for PostgreSQL and SQLite

* 94633ff448 introduced
    rollback on error to restore sanity
    for the connection. Don't do this
    if you are in the middle of INSERT IGNORE
    and we have a savepoint open.

    Making sure query syntax errors don't
    get silenced by our "wonderful" implementation
    of INSERT IGNORE is bug 35572.

Change-Id: I841b03895e1189c47307fefb1516c4c7c4102e25
2012-06-14 23:33:11 +02:00
Aaron Schulz
6a460ed446 Renamed new BagOStuff getBatch() function to getMulti() for consistency.
Change-Id: Icfe673919f65192565aa114c165c90d97d33785a
2012-05-15 01:48:22 -07:00