Commit graph

173 commits

Author SHA1 Message Date
umherirrender
70f3afd548 Remove unneeded empty lines at begin of if/else/foreach body
An if body must not begin with an empty line

Change-Id: I62b058be337fcc85a120fcd3dadce564db59a271
2015-06-19 20:05:45 +02:00
Aaron Schulz
4ab579e066 Made LoadBalancer debug log entries use "localhost" placeholder
* If $wgDBserver is empty, getServerName() now gives localhost.
  A few other bits use this method, which should be fine.

Change-Id: I44b0c1ed31c854990c0e7d81a710f456907b8081
2015-05-21 03:02:23 +00:00
jenkins-bot
661f171575 Merge "Added $wgJobSerialCommitThreshold setting" 2015-04-27 08:29:46 +00:00
Aaron Schulz
7c821caef5 Added $wgJobSerialCommitThreshold setting
* This is used to avoid lag by certain jobs

Bug: T95501
Change-Id: Id707c9a840fa23d56407e03aaae4e25149a1f906
2015-04-24 11:38:16 -07:00
Aaron Schulz
fb10df98df Moved DBConnRef to a separate file
Change-Id: I9c8570aefb8927a3d69b7fd446165f6e8661e84d
2015-04-24 18:02:50 +00:00
Aaron Schulz
5f163008d1 Added LoadBalancer::waitForOne method
* This waits on the generic reader (or a random slave)

Change-Id: I4d4a96806d55b119fa535556e11abd55736e9077
2015-04-22 20:49:11 +00:00
Aaron Schulz
01a5c6013e Made wfReadOnly() more robust at handling the lagged-slave case
* Previously if it was called before a DB_SLAVE connection, it would not
  be set. This is fixed now.
* Also set mLaggedSlaveMode in LoadBalancer as appropriate. Before, it
  was only set in the "too lagged for ChronologyProtector" case.

Change-Id: Ic4dc555cf762653f157df1795f53f3577c1e587a
2015-04-08 18:41:57 +00:00
Aaron Schulz
02a5f968df Made rollbackMasterChanges catch exceptions, throwing the last one
Change-Id: Ida36a302b35434d1af464cb77a0084ec441d038a
2015-04-03 09:37:01 -07:00
Aaron Schulz
4d58457784 Added slave/master fallback logic in Revision
* This is a more specific form of the logic removed in 3c2bc32ae1.
  It does not suffer the problem of causing constant master DB
  queries due to a bad template reference or such.
* It will use the master if writes from the current thread
  are pending or were recently committed. This deals with the
  common problem of code that needs to read things it just wrote,
  such as diffs on rollback or edit hooks.
* This commit reverts 8624e261f by making the hack obsolete.

Bug: T93866
Bug: T94407
Change-Id: Ib9ecb75e1236e767bdc86d124d5e22a03ae0fb5f
2015-03-31 23:39:28 +00:00
Aaron Schulz
a00be92e99 Avoid certain useless dbperformance log entries
* If DB_SLAVE was used but a master was picked due to having
  non-zero load, that should not issue a warning.

Change-Id: I79f3c477b4160b15ffb7f7679d7e15cabc236b82
2015-03-12 18:50:05 -07:00
Aaron Schulz
c39a4530b0 Made master connection expectations actually work
Bug: –T86862
Change-Id: If918904c6c02ea83473dfaf34dfc2787ab610c6f
2015-03-03 13:18:18 -08:00
Timo Tijhof
ada627005a database: Move LoadBalancer::getConnection debugmsg to getReaderIndex
Most of the time the early $this->mReadIndex inside getReaderIndex()
should be a hit, in which case this message isn't very useful.

This one message was filling up over 60% of the build logs (496/720 lines).
> LoadBalancer::getConnection: using server  for group ''

Move it to further down in getReaderIndex() where it actually
tries and finds one.

Change-Id: Id572f2bb3a905e095fcc929a9e2c17f40f7b1b6e
2015-02-19 21:24:26 +00:00
Aaron Schulz
c51517be48 Fixed backwards $group check in LoadBalancer
* Fixes 9190427

bug: T89507
Change-Id: I192ac3b00160c85e22e18d69cea5d9c46d2a301a
2015-02-18 01:32:10 +00:00
jenkins-bot
972eadb656 Merge "Log to DBPerformance log when many LB connections are acquired" 2015-01-08 19:49:53 +00:00
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01:00
Aaron Schulz
e0c286646e Log to DBPerformance log when many LB connections are acquired
Change-Id: Idcb7233bc418a793b87f4d445807be5eced12d95
2015-01-08 18:51:24 +00:00
Aaron Schulz
3226337f17 Converted some section profiling to scopedProfileIn
Change-Id: If69de34a046f4f33fc57b93beaf264f522ce7386
2015-01-07 14:19:06 -08: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
jenkins-bot
d8ab903223 Merge "Cleaned up LoadBalancer::getConnection" 2014-12-12 02:47:39 +00:00
Aaron Schulz
6ade2968ae Avoid blocking on ChronologyProtecter check in LoadBalancer::getConnection()
Change-Id: Iccf324d87d117972cc6321b2abf1ff101d98fa65
2014-12-12 02:25:04 +00:00
Aaron Schulz
52e6121447 Cleaned up LoadBalancer::getConnection
* It will also no longer call getReaderIndex( false, ... ) twice
* Removed various related ampersands

Change-Id: Ia79e2007dbf84e7437f9439aa6371333aa3e1b23
2014-12-10 00:27:48 -08:00
Thiemo Mättig
e698d93bad Add missing visibility keywords to all LoadBalancer methods
Quite a few methods are unused, at least in my code base (which does
not cover all extensions). I made them public. All other decisions
are based on the usage of that method in my code base. If you think
a specific method should be public, please tell me.

Change-Id: Ie83a2921fe02a198bd75c5ff7a41bcd4f0b4980b
2014-11-20 21:02:14 +01:00
Thiemo Mättig
a0fc2000e0 Add array type hints to LoadBalancer classes
Change-Id: I3dde038a71da8f775074916d47fa7f34eb37bf3f
2014-11-20 16:22:11 +01:00
Thiemo Mättig
7553367fe9 Fix/update inline documentation of LoadBalancer
Plus two very minor fixes in the code,
* an unused variable and
* a broken error message.

Change-Id: I40a39c81bd0d6d6054f983c82880f4bf31c21275
2014-11-20 16:13:13 +01:00
Bryan Davis
2792ea9783 Add logging context to database logs
* Add optional $context parameter to wfDebug, wfDebugLog, wfLogDBError
  and wfErrorLog that will be passed to MWLogger.
* Add support for PSR-3 style log message parameter interpolation in
  MWLoggerLegacyLogger.
* Add context information to wfLogDBError calls made from DatabaseBase,
  DatabaseMysqlBase and LoadBalancer instances.
* Deprecate wfDebugTimer() which now appears to be unused.

Change-Id: Ic90d593d00a2b0b5b80ed205908cbe624042603c
2014-11-19 17:59:55 +00:00
Aaron Schulz
fc2e6df64f Added wfLogDBError() call to LoadBalancer::doWait()
Change-Id: Ida0970754a2a7287c129bb5ad633765dab97133a
2014-11-13 21:34:54 +00:00
Aaron Schulz
7916aeeaea Support empty DB names in LoadBalancer more fully
* This convention to avoid selecting a DB is already supported for
  new connections but not when an existing foreign wiki connection
  is reused. This avoids giving PHP notices.

Change-Id: Ic6e9ed031bc8ea6d6f519b6998f0414364c087d0
2014-11-03 16:52:42 -08:00
Aaron Schulz
5f1f698ad0 Removed unused method
Change-Id: I8d72798ed5a7048ca8c8f410612bb6645b06f634
2014-10-06 12:54:07 -07:00
Aaron Schulz
855a19ec86 Simplified getMaxLag() to use getLagTimes()
* This method now benefits from more cache sharing and de-duplicated
  lag time querying to reduce connection stampedes.

Change-Id: I2f3b9a22e4adabea703fbae1f96e65fb65125e2b
2014-09-26 00:21:27 +00:00
Aaron Schulz
cbdb81d1bc Limit active DB connections spawned in waitForAll() to one
* If new connections are created, they will be closed before
  making the next ones now.

Change-Id: I289d81ec00d3e1e313624e2a4c28a67bfb317feb
2014-09-24 22:40:30 +00:00
Aaron Schulz
103ff32fbc Fixed doc typo
Change-Id: I80aa85337357d25b1973b4a266a3c961843b08b6
2014-09-24 15:13:30 -07:00
Aaron Schulz
a55544180b Slave lag check tweaks to JobRunner
* Do not block forever, but wait up to 10 seconds. Likewise,
  check the lag times in memcached on startup. This at least
  lets runners avoid lagged wikis but still work on others.
* Made a few small related documentation and code cleanups.

Change-Id: Ic1339bab54cba6b6cbea7d97a80ff87c7c5c87af
2014-09-24 00:59:55 +00:00
Aaron Schulz
11ef48d121 Commented and re-ordered the LoadBalancer fields
Change-Id: Ie05cfd9a4a60f07ea9710c6bf7657ca956a7dd5e
2014-09-12 11:32:01 -07:00
Aaron Schulz
cafcb6b225 Vastly increase how long wfWaitForSlaves() can block in CLI mode
* All maintenance scripts pretty much assumed this behavior, but it
  was not actually the case. This can avoid some massive lag problems.

Change-Id: I5894409d6abade16afd8144f6689c2aff3fa7327
2014-07-31 23:28:11 -07:00
umherirrender
02dc9da399 Cleanup some docs (includes/[a-d])
- 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: I7b65fe04db431342cc58b469dc48f41a50c4e891
2014-07-24 19:42:45 +02:00
Aaron Schulz
92e0d0f927 Added a hasMasterConnection() method to LoadBalancer
* Made wfWaitForSlaves() use it instead of using isOpen() incorrectly.
  The index for the master is 0, not DB_MASTER. This fixes 2979f0b6.

Change-Id: I48e5c7f10d8fe6b8bf6e830282352e3238b5d3ae
2014-07-19 16:19:43 -07:00
jenkins-bot
b3c307518a Merge "Made getMaxLag() use caching to reduce connection spam" 2014-07-11 18:02:10 +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
Aaron Schulz
faaf616549 Made getMaxLag() skip checking the master DB
Change-Id: I81a9102570bf9a45af56f31d04e3a0f2be72b919
2014-07-09 12:11:32 -07:00
jenkins-bot
c9148b7121 Merge "Remove LoadBalancer::closeConnecton (deprecated since 1.18)" 2014-06-26 18:47:43 +00:00
Aaron Schulz
26f386ae55 Removed old DB_LAST cruft
Change-Id: I5517c43389182e61e4a969ed9ca71dae2388a5d0
2014-06-25 16:12:36 -07:00
umherirrender
44572ddae8 Remove LoadBalancer::closeConnecton (deprecated since 1.18)
Change-Id: Ic572ab2787623bb2b525ffa640e1232dcb1643fb
2014-06-25 19:57:05 +02:00
withoutaname
28f77aebe6 Deprecate $wgMasterWaitTimeout
Not only was this global unused, it also caused the LoadBalancer
to look for the wrong array key, which would always set
$mWaitTimeout to 10 in the conditional. There is also
a manual function LoadBalancer::waitTimeout() for this.

Change-Id: I4b409ef890bec5aac7f666a2ed3dff9ea8bc14cc
2014-06-11 22:24:07 -07:00
umherirrender
f5f1e38b9a Fixed some @params documentation (includes/[db|installer])
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: I3595e9aac69ac42fbb74b0783fae0ad9bcc831aa
2014-04-19 13:55:27 +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
Brad Jorsch
dc7d342d93 Improve handling of uncommitted DB txns with "uncaught" exceptions
One of the causes (if not the cause) of bug 56269 is if something
manages to throw an exception that makes it to MediaWiki::run's
last-resort exception catcher while having an open database transaction:
the transaction never gets committed or rolled back, so it gets
implicitly rolled back and a warning is raised.

The API has the opposite problem in bug 63145: it catches the exception
but then does the normal DB shutdown which *commits* the transaction.
This is certainly the Wrong Thing to do.

Ideally, neither of these would ever happen because any code using
transactions would have its own try-catch that would catch any
exception, rollback the transaction, and then rethrow the exception. But
it happens anyway, so let's have both of these last-resort exception
handlers do the rollback, and also log the exception so the throwing
code has a better chance of being properly fixed.

Bug: 56269
Bug: 63145
Change-Id: I8f1da51187b281fe4afc0d5a0c49f5caf3612e92
2014-03-27 12:46:07 -04:00
Alexandre Emsenhuber
59c42b90d5 Automatically add a new line at the end of wfLogDBError()
I found two calls to wfLogDBError() that do not add a new line
at the end of the message. So instead of adding them to that
entries, I changed wfLogDBError() to automatically put it on
icoming messages; as for wfDebugLog().

Change-Id: Id014b5827a0aeef6873ebf08d78f0a3d7581d63b
2014-03-23 10:30:59 +01:00
Alexandre Emsenhuber
85a7f625de Move variable definitions near to where they are used
In LoadBalancer::reuseConnection(), if the condition
"$serverIndex === null || $refCount === null" is met,
then those variables will not be used. So only define
them when they will readlly be used.

Change-Id: Ifbd4131f40d3babe733b8723d0d29d39890bb309
2014-03-15 14:34:52 +01:00
Aaron Schulz
5959af31ca Move clearing of $i down a bit in LoadBalancer
* Fixes 56b22fbea8

Change-Id: I6b99d93562743270dbb65c60facdd503f470ab14
2014-02-10 22:52:03 +00:00
Aaron Schulz
56b22fbea8 Avoid fatal error in LoadBalancer when all servers are busy
* Fixes bug from b3c9653

Change-Id: Ida22f0ee3e97f98e4a1de6f7260a9a9f8aa08a39
2014-02-10 14:37:42 -08:00