Commit graph

16 commits

Author SHA1 Message Date
Aaron Schulz
fe0af6cad5 rdbms: Database::selectDB() update the domain and handle failure better
LoadBalancer uses Database::getDomainId() for deciding which keys to use
in the foreign connection handle arrays. This method should reflect any
changes made to the DB selection.

If the query fails, then do not change domain field. This is the sort of
approach that LoadBalancer is expects in openForeignConnection(). Also,
throw an exception when selectDB() fails.

The db/schema/prefix fields of Database no longer exist in favor of just
using the newer currentDomain field.

Also:
* Add IDatabase::selectDomain() method and made selectDB() wrap it.
* Extract the DB name from sqlite files if not explicitly provided.
* Fix inconsistent open() return values from Database subclasses.
* Make a relationSchemaQualifier() method to handle the concern of
  omitting schema names in queries. The means that getDomainId() can
  still return the right value, rather than confusingly omitt the schema.
* Make RevisionStore::checkDatabaseWikiId() account for the domain schema.
  Unlike d2a4d614fc, this does not incorrectly assume the storage is
  always for the current wiki domain. Also, LBFactorySingle sets the local
  domain so it is defined even in install.php.
* Make RevisionStoreDbTestBase actually set the LoadBalancer local domain.
* Make RevisionTest::testLoadFromTitle() account for the domain schema.

Bug: T193565
Change-Id: I6e51cd54c6da78830b38906b8c46789c79498ab5
2018-10-10 12:03:30 -07:00
Aaron Schulz
8ee45c99be rdbms: make LBFactorySingle/LoadBalancerSingle set the local domain from the connection
Change-Id: I657cea85ae3838bc76e7eb50b9ca66db16746bde
2018-08-27 11:50:24 -07:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Reedy
765370a6db Add @deprecated tags to various class_alias calls
Bug: T195576
Change-Id: I10cd8415891bfe4a278eee06c9cfe905b3e036dc
2018-05-29 13:10:20 -07:00
jenkins-bot
801c6810a7 Merge "rdbms: set the schema in the LBFactory local domain" 2018-02-02 04:25:46 +00:00
Aaron Schulz
d444b2c0b4 rdbms: set the schema in the LBFactory local domain
Also, enforce that new DB connection use the domain
schema as is the case with the DB name and table prefix.

The code worked previously since the local domain did not override
the schema in the server configuration arrays, so it happened not
to clobber the domain schema.

Lastly, fix unit test fatal in LBFactorySingle::forEachLB() when
called during LBFactorySingle::_destruct().

Change-Id: Ia9ddef0f21591d0c8b15f2947cd61569e3fec7a0
2018-01-31 08:53:29 -08:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Aaron Schulz
14ee3f2107 rdbms: specify DB name and table prefix even for the local domain
When LoadBalancer opens new local domain connections, it currently
assumes that the domain specified by the server info array is the
same. For sanity, make sure that the handle is set to the local
domain.

The main LBFactory/LoadBalancer use $wgDBname/$wgDBprefix as the
local domain, corresponding with wfWikiId(). This relation is set
automatically in MWLBFactory. If $wgLBFactoryConf/$wgDBservers is
manually configured in a way breaking this correspondance, then it
is misconfigured.

Fixes made to avoid test failure:
* Make sure LoadBalancer::setDomainPrefix() updates the local
  domain alias member. Also do not bother changing the domain of
  foreign connections.
* Use the right domain ID for the connection array key names in
  LoadBalancer::openForeignConnection().
* Now that JobQueueTest no longer mistakenly uses the non-test
  tables, force it to use the main DB_MASTER handle so that it can
  see the unit test tables even if they are TEMPORARY; such tables
  are tied to the TCP connection, so separate handles see different
  temporary tables.

Change-Id: I56f8b32fe957f984b8c9753e6db3b20abe96b038
2018-01-16 17:06:52 +00: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
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
Aaron Schulz
3e4a2307f4 Remove redundant LoadBalancerSingle doc block
Change-Id: Ibbf952bb1c6ded5e47a325de3c2ecdc5e171e4e7
2016-10-24 07:36:13 +00:00
Paladox
34de93fa70 Fix LoadBalancerSingle::reallyOpenConnection() signature
Declaration of LoadBalancerSingle::reallyOpenConnection() should be
compatible with
LoadBalancer::reallyOpenConnection(array $server, $dbNameOverride = false) 

Caught in https://travis-ci.org/paladox/mediawiki/jobs/167910508

Change-Id: I9bc30249c3b43c3dd3b4eb6f3a70765ef428fd2c
2016-10-15 17:07:10 +00:00
Aaron Schulz
896a4c74de Move LBFactorySingle to /libs/rdbms
Also add newFromConnection() methods for cleaner looking construction
since the IDatabase is fundamental and required.

Change-Id: Ife478d045cee92a30c91e9004833a557488bd512
2016-09-17 19:13:21 -07:00
Aaron Schulz
e4948970dd Fix file/class name mismatch from e2adcc89bb
Change-Id: Ieac65f29a13612cecd421b62e1cb3a3f47552bb6
2016-09-17 19:00:01 -07:00
Renamed from includes/libs/rdbms/lbfactory/LBFactorySingle.php (Browse further)