Commit graph

75 commits

Author SHA1 Message Date
Aaron Schulz
328365dcc8 Refactor LoadBalancer::setDomainPrefix() to use forEachOpen* method
This makes the code more consistent with the other class methods
that iterate over connection handles and less fragile.

Change-Id: Ie2d8efb80a66a5c87b5b3edd64cb6bc4268fa911
2017-07-20 13:12:33 -07:00
Aaron Schulz
f05716b1f6 Use constants for LoadBalancer connection array keys
Also renamed "foreignUsed" to "foreignInUse" for clarity.

Change-Id: Ida35042979a87417b38d256610b726611555d7b2
2017-07-20 19:38:59 +00:00
Aaron Schulz
bb54e69831 Fix docs for LoadBalancer::openConnection()
Change-Id: Ib05d98cb3670899a688d9882a2dc364f18e1d4bd
2017-07-19 19:33:32 -07:00
Mukunda Modell
148faa9f54 Downgrade 'found writes/callbacks pending.' from error to info
This generates useless logspam and should be logged with a lower
log level.

Bug: T149353
Change-Id: If5e84b89eca098ac7f8c788ca3b0d268adf799fb
2017-06-26 11:29:26 -05:00
Tim Starling
dd8a939ea6 Make "eval.php -d 2" work again
Instead of iterating through load balancer info, just set the flag in
the master and replica connections, since that seems more robust.

Deprecate LoadBalancer::setServerInfo() and
LoadBalancer::getServerInfo(), no remaining callers in core or
in-tree extensions, I think I added the function just for this feature.

Do a service reset, since Logger instances are injected into
LoadBalancer by ServiceWiring (via MWLBFactory::applyDefaultConfig()).
Similarly CryptRand, MimeAnalyzer.

Fix the usage text for shell.php

Change-Id: I3e85a6e8cfa1243a0371cfb3ce1c18665e8c711d
2017-05-03 09:49:44 -04:00
Aaron Schulz
99fcf47b52 Remove load array indexes from LoadBalancer errors
This are not very useful and where not using SPI interpolation either.

Change-Id: Ia3a33da3a4593fbcba59b21f5b5028860752ce09
2017-04-19 14:30:25 -07:00
jenkins-bot
5747ee5b93 Merge "Split up LoadBalancer::getReaderIndex() and simplify the code a bit" 2017-04-17 23:48:01 +00:00
Aaron Schulz
b1d4ceaace Split up LoadBalancer::getReaderIndex() and simplify the code a bit
Change-Id: I4e0b5318ad2c987b2a059c4ef2bda3de14486687
2017-04-17 23:31:48 +00:00
jenkins-bot
d83306610d Merge "Move DB errors to Rdbms namespace" 2017-04-17 22:06:42 +00:00
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00
Aaron Schulz
dc17c8ddbf Fix some LoadBalancer::waitFor*() inconsistencies
* Make sure waitFor() always handles laggedReplicaMode updates,
  even if the actual waiting was deferred until a connection was
  needed.
* Restore the old mWaitForPos in waitForOne()/waitForAll() since
  this do not care about the generic reader index or the sort of
  ChronologyProtector logic related to it.

Change-Id: I0767e9831b8fd7fd115a472354977e3c1e12114a
2017-04-13 19:23:09 -07:00
Aaron Schulz
f1b861dec8 Make LoadBalancer::waitFor() and friends more robust via try/finally
Change-Id: I50742752bb94ca17997138b440b911849bcbadf3
2017-04-13 04:19:47 +00:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
Aaron Schulz
3c2a172c3f Move DBConnRef/MaintainableDBConnRef to Rdbms namespace
Change-Id: I7ca6b40f973b2aae83747de92e280ded222c87e3
2017-03-29 11:04:47 -07:00
jenkins-bot
ea747bb2d4 Merge "Move IDatabase/IMaintainableDatabase to Rdbms namespace" 2017-03-29 00:46:59 +00:00
Aaron Schulz
fb3de3d75c Defer calling ChronologyProtector::initLB() until connecting
Bug: T160678
Change-Id: Id51c2854f38d9e4697e52776168b16996e9152e4
2017-03-28 16:57:55 -07:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
Aaron Schulz
64df456b39 Move remaining LoadBalancer classes to Rdbms
The old names are left as aliases.

Change-Id: I52a327f2463a2ba7437324047b5b00d28cd1d758
2017-02-23 20:38:31 -08:00
Aaron Schulz
5719d297db Make position time APC key in LoadBalancer more Het-Deploy friendly
This avoids two versions of MediaWiki fighting over Rdbms
namespace changes. A simple version string works since there
are no purges issued; it is TTL-based only.

Change-Id: Ie155c20352e8fea00ea469d162d25bda3600ae60
2017-02-14 13:47:58 -08:00
Aaron Schulz
473b200a7d Type check the APC value in LoadBalancer::doWait()
Change-Id: If00cd5fd2ace828ce03824ec7b5735de7d950dec
2017-02-10 12:00:44 -08:00
Aaron Schulz
864eab03e7 Move DBMasterPos to Rdbms namespace
Updated all callers

Change-Id: Iacd5d6f7f18d8b23df24637cda61592112490eb0
2017-02-10 02:38:56 -08:00
Aaron Schulz
6494ea0ba0 Move ILoadBalancer to Rdbms namespace
All callers are in core and have been updated.
Other callers can now be switched from LoadBalancer type hints to
ILoadBalancer type hints. Once that migration is done, the classes
implementing it can be moved too.

Change-Id: I6b34099b5816dd8bf9646ed39f7a2d1960e2ed06
2017-02-07 23:22:36 -08:00
Aaron Schulz
38b31bc8db Move DatabaseDomain to Rdbms namespace
Change-Id: Ifb06e792a36b5123ec3596933d0d394711ee5d08
2017-02-07 13:21:40 -08:00
Aaron Schulz
2c7b26c169 Move LoadMonitor to Rdbms namespace
Change-Id: Icc178acb5ba0e21d1a8e857c43724c694c7ebeb1
2017-01-31 19:45:54 -08:00
Aaron Schulz
59053a0716 Move ChronologyProtector/TransactionProfiler to Rdbms namespace
Change-Id: I37a655bd8bd267c9bc32028b55925b2dce527d33
2017-01-26 10:30:57 -08:00
Aaron Schulz
11d0f9a8c5 Make some replication logging more structured
Change-Id: I0ec3c615047b666ff5ee430453c1de2a1316ef61
2017-01-02 13:26:18 -08:00
jenkins-bot
5b3fd5a4a9 Merge "Fix various minor IDEA warnings in LoadBalancer" 2016-12-17 06:41:34 +00:00
Max Semenik
633e638cae Fix type annotation
Change-Id: I8996a7617c4723c9c4ff8f91d0f3767c9e67dd28
2016-12-16 17:11:51 -08:00
Aaron Schulz
614028768b Fix various minor IDEA warnings in LoadBalancer
Change-Id: Ic65a04ca1b988fe36e088709d7dc4e981670cb62
2016-12-15 19:32:26 -08:00
Aaron Schulz
fe59c39da9 Add LoadBalancer::getMaintenanceConnectionRef() method
This is useful when IMaintainableDatabase methods are needed
for foreign wiki connections to things like external store.

Also:
* Set visibility for ExternalStoreDB methods.
* Cleaned up various type hints and comments.

Change-Id: Ie35b1ff21032cc4e78912dc499486da23aeba041
2016-12-10 15:35:09 -08:00
Erik Bernhardson
9053890020 Cleanup static analysis errors
While prepping the code base for using etsy/phan i found a few problems.
A couple are real problems, while others are just places etsy couldn't
figure out the types.

* AuthPlugin referenced UserLoginTemplate which doesn't exist. Tracing
  back usages this accepts classes that extend from BaseTemplate.
* DatabaseSqlite had an invalid @var annotation.
* LoadBalancer had some missing or under-defined annotations. Make them
  more specific where possible.
* SqlBagOStuff didn't have the appropriate use statement for
  WaitConditionLoop and probably doesn't work. Also updated annotations
  that point to non-existent DatabaseBase to use IDatabase.

Change-Id: Iff2270b418ad2f8f97cfdb6df646c435d3283536
2016-12-06 16:10:38 -08:00
Hashar
4d487d1942 Revert "objectcache: detect default getWithSetCallback() set options"
Causes HHVM 3.12.7 to segfault and or:
Fatal error: Stack overflow in includes/libs/objectcache/BagOStuff.php on line 754

This reverts commit b47ce21cec.

Bug: T150833
Change-Id: Ia52fdf65f5e386c0eaa1046328680fb5c8a9081a
2016-11-16 10:35:27 +00:00
Aaron Schulz
b47ce21cec objectcache: detect default getWithSetCallback() set options
This works by setting a callback to return the cache set
options. The callback will watch DB reads and create a
merged result from said usage.

This handles callers that are missing getCacheSetOptions().

Change-Id: Ia264f011e45e8cf105480955dad7e2c4c2357b73
2016-11-16 04:53:53 +00:00
jenkins-bot
69ae945e8d Merge "Update weblinks in comments from HTTP to HTTPS" 2016-11-08 21:32:00 +00:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
jenkins-bot
619a3195c2 Merge "Clean up postgres connection handling" 2016-10-19 01:24:07 +00:00
Aaron Schulz
fda4d46fc4 Clean up postgres connection handling
* Remove non-connection magic case when no DB $user
  is given. This was removed from the base class.
* Use PGSQL_CONNECT_FORCE_NEW to let LoadBalancer
  handle connection reuse. This makes it work like
  the mysql classes.
* Make postgres connection error messages actually
  be useful by using the PHP error when possible.
  This makes it clear if the problem is authentication
  or something else and so on.

Change-Id: I3fd76c1e2db8d6008074f5347b201554579b549a
2016-10-19 01:08:49 +00:00
jenkins-bot
6e6396d75e Merge "Postgres installation fixes" 2016-10-19 00:35:42 +00:00
Aaron Schulz
e8eab2d313 Deprecate Database::getProperty()
Change-Id: If0399dded731b139ffbaab405eceeeafcdf9aed9
2016-10-18 11:05:39 -07:00
Kunal Mehta
61adc1e146 Use namespaced ScopedCallback
The un-namespaced \ScopedCallback is deprecated.

Change-Id: Ie014d5a775ead66335a24acac9d339915884d1a4
2016-10-17 15:46:05 -07:00
Aaron Schulz
66b0ad56df Postgres installation fixes
* Make isTransactableQuery() exclude CREATE/ALTER.
  Starting transactions for schema changes like this can cause
  errors as it is not supported for MySQL and some Postgres
  operations. Note that temporary tables are session-level,
  so they are not effected by this change.
* Clean up the transaction logic in determineCoreSchema()
  so a transaction is not left dangling.
* Fix broken getSchemaPath() call in PostgresInstaller.
* Avoid warnings in DatabasePostgres::closeConnection() if
  mConn is already unset.
* Commit master changes in doMaintenance.php before running
  deferred updates, just as MediaWiki.php does.
* Change E_WARNING to E_USER_WARNING to avoid notices in the
  default /rdbms error handlers.
* Also avoid trying to rollback in MWExceptionHandler if the
  LBFactory service is disabled, which just results in an error.

Bug: T147599
Change-Id: I64ccab7f9b74f60309ba0c9a8ce68337c42ffb0f
2016-10-17 15:06:38 -07:00
Aaron Schulz
9a8c8ab98c Make TransactionProfiler::setSilenced() calls handle nesting
Change-Id: I6511a72a0fb921468a8a19ceb4d0a8ae669aa6e4
2016-10-12 18:14:03 -07:00
jenkins-bot
1e11b78e32 Merge "Make server index validity checks in LoadBalancer actually work" 2016-10-11 20:02:04 +00:00
Aaron Schulz
b6d8421ab6 Minor LoadBalancer cleanups
* Close the master connection in safeWaitForMasterPos() if created.
* Remove unnecessary reuseConnection() calls.
* Add DOMAIN_ANY constant for readability.

Change-Id: I9e64a7405e0eedc50e7b93d05d65cf00d5544a77
2016-10-06 19:07:27 -07:00
Aaron Schulz
94d5c2bf6d Ignore reuseConnection() errors after LoadBalancer/LBFactory destruction
Bug: T147520
Change-Id: I9fe6acb0ab24127c1e9f3279129ff46c6b480873
2016-10-06 01:04:26 +00:00
Aaron Schulz
d1d5d00267 Add more information to reuseConnection() exceptions
Change-Id: Id2e6b275c8dc074fde460424178a2bc54f303d65
2016-10-05 15:04:32 -07:00
Aaron Schulz
4154c688e8 Make LoadMonitor use $serverIndexes in the cache key
* This avoids collisions of generic and custom LB group
  server list keys, which could cause warnings and errors.
* Remove $group param from scaleLoads(), which was unused
  and less robust for making keys anyway.
* Remove clearCaches() method, which only had one caller
  in a script that printed lag times in a loop. Its not
  worth keeping and having to pass in the server index
  list.
* Also guard scaleLoads() against recent server additions.

Bug: T147359
Change-Id: Idd15f0bebb68782fda36f483880cf7fe9673b940
2016-10-05 20:07:03 +00:00
Aaron Schulz
9fd0c1d5e7 Make server index validity checks in LoadBalancer actually work
Change-Id: I8f0fd802ee3ce67903af5a83ec07dc0506ec84ba
2016-10-04 04:24:25 -07:00
Aaron Schulz
23909318c8 Implement scaleLoads() in LoadMonitorMySQL
* Recently pooled servers will get more traffic as
  their internal caches warm up by getting queries
* Also let LoadMonitor support options for flexibility
  The "loadMonitor" config field now takes in array in
  LoadBalancer.
* Make LoadMonitor the default instead of LoadMonitorNull.

Change-Id: I53b89b0c25bdcc30deec3f8b502fb14479c53ae8
2016-10-03 22:32:33 +00:00
jenkins-bot
0e1fd82089 Merge "Set ignore_user_abort( true ) during DB commit for sanity" 2016-09-28 03:27:58 +00:00