* If $wgDBserver is empty, getServerName() now gives localhost.
A few other bits use this method, which should be fine.
Change-Id: I44b0c1ed31c854990c0e7d81a710f456907b8081
* 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
* 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
* 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
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
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
* It will also no longer call getReaderIndex( false, ... ) twice
* Removed various related ampersands
Change-Id: Ia79e2007dbf84e7437f9439aa6371333aa3e1b23
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
* 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
* 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
* This method now benefits from more cache sharing and de-duplicated
lag time querying to reduce connection stampedes.
Change-Id: I2f3b9a22e4adabea703fbae1f96e65fb65125e2b
* 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
* 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
- 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
* 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
* 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
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
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
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
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
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
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