Commit graph

141 commits

Author SHA1 Message Date
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
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
Aaron Schulz
9190427ae2 Fixed getReaderIndex() handling of $group
* Connections for a group should not override the generic connection handle.
  That can cause special DBs to be reused for general queries more so than
  optimal.
* Also made the code use ProfileSection to clean it up a bit.

Change-Id: Ia8973133a93410bd906d8ad52a711a7d810df2f6
2014-01-30 22:36:26 +00:00
Aaron Schulz
b3c9653090 Removed unused postConnectionBackoff() from LoadMonitor
* This setting proved to be not terrible useful

Change-Id: I58b18947ff0edb8937229d0f130d7d10e846125e
2014-01-28 11:00:55 -08:00
jenkins-bot
e27845d5fd Merge "Provide correct type as input for LoadMonitor::postConnectionBackoff()" 2014-01-22 22:06:12 +00:00
Siebrand Mazeland
e1860613f5 Update/add documentation in the LoadBalancer class
These should fix the last (but one) remark by the PHPStorm code analyser
on code documentation in includes/db.

Change-Id: Ib836ab052dbc8a3f347db3013af2f00138231d47
2014-01-11 08:38:43 +00:00
Siebrand Mazeland
073c601f75 Provide correct type as input for LoadMonitor::postConnectionBackoff()
float is expected, bool was given.

Change-Id: I046cc4b73166e79905e3556365f567420a4cabb9
2014-01-11 08:37:56 +00:00
Siebrand Mazeland
e22a70a103 Update documentation for database related classes
Change-Id: I364e192e2624f89a91dcb19e371ce3412142a95f
2014-01-06 19:45:40 +01:00
Siebrand Mazeland
210edff11b Remove underscore from classes LBFactory_*, LoadBalancer_*, LoadMonitor_*
Part of program to remove underscores from class names. Checked core and
600+ extensions for occurrences. All uses are in core in core are updated
in this patch.

Patches for extensions:
* https://gerrit.wikimedia.org/r/#/c/96463/ CentralAuth
* https://gerrit.wikimedia.org/r/#/c/96460/ SimpleSecurity
* https://gerrit.wikimedia.org/r/#/c/96459/ WikiBase
* https://gerrit.wikimedia.org/r/#/c/96472/ Wikimedia configuration

Antoine added tests to test the back compatibility.

Change-Id: I507ba00a83bca8375a0215f00891b47e3c7afb9f
2013-12-26 16:30:15 -05:00
jenkins-bot
d7d5f28826 Merge "Break long lines and formatting updates for includes/db/" 2013-11-21 16:48:47 +00:00
jenkins-bot
6a8d67c177 Merge "Update formatting on database-related classes" 2013-11-21 16:45:08 +00:00
Siebrand Mazeland
b547395796 Break long lines and formatting updates for includes/db/
Fix all line length related CodeSniffer warnings.

Change-Id: Id0fd8f4c7276185f51489659ee3cd06962fbc16d
2013-11-21 16:43:40 +00:00
Siebrand Mazeland
1e10dcd3aa Update formatting on database-related classes
Change-Id: I91f83e28ae25f80ba9e36c612f1ad050ffa1573c
2013-11-21 16:39:38 +00:00
Siebrand Mazeland
0c2a9d4f97 Remove function calls from for loop test part
Change-Id: If1f8996854889b526fef96cd29a153e0b36e9133
2013-11-21 04:44:49 +00:00
Tim Starling
203565a9c1 Exclude servers with zero load from lag checks
Since r13582, servers with zero load have been isolated from the rest of
the servers in the section in terms of query flow. However, lag checks
still remained. This is not appropriate for backup/QueryPage servers
that are routinely lagged. IIRC we dealt with this once before with a
special case in the core excluding benet from master pos waits, but that
doesn't seem like a very appropriate solution today. Perhaps there is an
application for including zero-load slaves in lag checks, but I can't
think of any right now.

Related WMF conf change in I8fac5c99.

Change-Id: Id354039123f8c04febc8090eea9940fff044c5ea
2013-11-18 11:10:42 +11:00
addshore
a6169910ea Remove use of deprecated LoadBalancer pickRandom
Change-Id: If28b6dfe7d70827d1c7f7b3604cea2409b6ec483
2013-10-04 20:38:45 +02:00
Aaron Schulz
dd181032e9 Added a getLazyConnectionRef() function to load balancer
* This is useful for injecting dependencies without adding pointless traffic
  in some cases

Change-Id: I755ed008c387a3e4555934c84a5dc013ee8c2392
2013-08-20 13:25:16 -07:00
jenkins-bot
ebbea3c974 Merge "Never prefix table names with $wgSharedDB when used in foreign DB" 2013-08-09 00:19:48 +00:00
Aaron Schulz
1fbb0404f5 Allow for IDatabase to be used as type hints for DatabaseBase|DBConnRef
* Use this in LogEntry to avoid needless type errors

Change-Id: I8644b35b0d9cd171243dd28de52e94ef39d361a7
2013-07-18 03:43:20 +00:00
Aaron Schulz
d921b2fd7e database: added DBConnRef wrapper to manage calling reuseConnection()
Change-Id: Ifc9db62d1ac34d0c6a072d6f2d05bdcf73af14bb
2013-07-15 15:10:45 -07:00
Liangent
af154bea2b Never prefix table names with $wgSharedDB when used in foreign DB
Now database classes have an extra "foreign" property when used in
foreign databases, where $wgSharedDB and $wgSharedTables are not
considered.

Bug: 48819
Change-Id: I45db6860d0a4b4480e0b93aa7e750f096424e40f
2013-05-27 04:52:20 +00:00
Aaron Schulz
dc252e0aaf Reset the error string in LoadBalancer::getConnection() to avoid it crufting up.
Change-Id: I89e9fb46367970a0877986cd72d397eef51a0a06
2013-05-23 00:26:46 -07:00
Timo Tijhof
176c5354bb docs: Consistently use "since" phrasing in @deprecated
Most have it already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/deprecated.html

Ran a find/replace on "@deprecated \d" to fix the odd ones.

Change-Id: I5217aaf75264a0036b5426cd8536116b4bb8f535
2013-05-15 00:56:57 +00:00
umherirrender
892ee7a4af Fixed spacing in db/debug/diff/externalstore/objectcache folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I32a43c547630ce31b6b25cc1bc9eedc50e67b2d7
2013-04-20 22:28:52 +02:00
umherirrender
978bb31c5e Add missing wfProfileOut before throwing an exception
Change-Id: I1d830da0597f19efd0b2ae48642389975e736e23
2013-04-08 18:37:24 +00:00
Aaron Schulz
7fd8d513c4 Fixed fatal when using fake load balancers.
The error was:
Catchable fatal error: Argument 1 passed to DatabaseMysql::masterPosWait()
must implement interface DBMasterPos, boolean given, called in
/var/www/DevWiki/core/includes/db/LoadBalancer.php on line 419

Change-Id: I230585930c1424b0868f9aa290167c66bc6848bd
2013-04-04 10:29:13 -07:00
Catrope
319ace8125 Fix wfWaitForSlaves() for foreign DBs
We thought we'd fixed it previously, but the LB now connects to the
foreign slaves and tries to select $wgDBname. Fixing this by having
doWait() open connections that don't select any DB name, by passing
the empty string as the DB name. This is an undocumented feature
in the DatabaseMysql constructor, apparently.

Change-Id: Icc5594143a3eaa31170a7fc8c93d429c1a7dd575
2013-03-20 17:43:44 -07:00
Platonides
2763191221 (Bug 42461) Remove call to "new Database()"
* Refactored LoadBalancer::reportConnectionError()
 * Removed PHP4-style reference from DatabaseError constructors
 * Allowed to not pass a database to the DBError family of exceptions.

Change-Id: If9570b45ea7285de2b8b2391e704bc01f76be48a
2013-03-18 13:49:44 +11:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
Reedy
c3e4057e06 Kill off numerous unused variables
Change-Id: I7039f1328f37ee669b694f73ee282602186bffd1
2013-03-08 02:36:24 +00:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
Aaron Schulz
9ace77f03c Moved wfPickRandom to ArrayUtils.
Change-Id: I45e21e722245901ab2988be4892cdb393169c62c
2013-03-05 15:07:09 -08:00
Alexandre Emsenhuber
4421f598ea Correct documentation for wfPickRandom()'s return types
Also make LoadBalancer::pickRandom()'s one consistent.

Change-Id: Ib80827ef20b32fecb799f327545b1232272076d2
2013-03-01 08:22:46 +01:00