This is intended for use with scripts like addWiki.php to avoid mismatched domain errors.
Bug: T209483
Change-Id: Ie24f83f4e0fad7b01690d2055e1529a4cb0275b5
Introduced in Ib6e307d76f93.
This patch updates FileBackend, LoadBalancer and LBFactory to use a public
function newScopedIgnoreUserAbort in ScopedCallback instead of all using
the exact same function but duplicated.
Bug: T184044
Change-Id: I27d7dc16abfe4b9447d7f3d8bd89f0de3ddeb662
Also clean up empty schema handling in DatabaseDomain
This reverts commit f23ac02f4f.
Bug: T193565
Change-Id: I95fde5c069f180ca888a023fade25ec81b846d44
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
Move unclosed transaction error reporting to Database so it can
include information about the caller that started the transaction.
Change-Id: I834d957f172c03005de522f3029bb634b3c7220e
Move "tablePrefix" logic to LoadBalancer::reallyOpenConnection and
make it more consistent for local vs foreign connections. The prefix
for local connections is now set even if $domain does not provide a
database.
Also set the schema even if $domain does not provide a database.
Typically a database domain is either fully specified or comes from
DatabaseDomain::newUnspecified(), but there's no reason not to use
at least the schema/prefix of otherwise unspecified domains. The only
other sensible option would be some sort of exception.
Change-Id: Ib52f4b69e429810e3c5eac92a48aecf7b22e86e6
Put the object/callback fields first, followed by config fields
and then state fields, similar to LBFactory.
Change-Id: I40ceaa48842b505f15efe5e41ca7a6de437b6ff1
This is more or less equivalent to the WMF shell script "sql", but it is
reasonably portable and written in a less hackish way.
Change-Id: I240d8d4e65ce46680cac257ee376a9b026c13f92
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
Just like 082ed053b6 fixed pre-commit callback errors when new instances
of LoadBalancer are made during that step, do the same for post-commit
callbacks.
Bug: T194308
Change-Id: Ie79e0f22b3aced425cf067d0df6b67e368223e6c
If a pre-commit callback caused a new LoadBalancer object to be created,
that object will be in the "cursory" state rather than the "finalized"
state. If any callbacks run on an LB instance, make LBFactory iterate
over them all again to finalize these new instances.
Make LoadBalancer::finializeMasterChanges allow calls to
already-finalized instances for simplicity.
Bug: T193668
Change-Id: I4493e9571625a350c0a102219081ce090967a4ac
* Handle the case where an onTransaction* callback for one handle
adds more onTransaction* callbacks to a different handle. Instead
of supporting only a short chain of such callbacks, try to resolve
the whole chain by using a loop in LoadBalancer and LBFactory.
* Add sanity checks to enforce the proper call order of LoadBalancer
transaction methods, such as those that execute callbacks. This is
the order that LBFactory already uses. Use ROUND_ERROR for problems
that can ruin the instance state. Such problems require rollback.
* Correct setTrxEndCallbackSuppression() calls in beginMasterChanges()
that were making tests fail.
* Make Database handle callback suppression for FLUSHING_ALL_PEERS
instead of making LoadBalancer/LBFactory have to manage it.
* Simplify finalizeMasterChanges() given that suppression does not
actually effect runOnTransactionPreCommitCallbacks().
* Make dangling callback warning in Database::close work properly.
* Actually use $fname in flushReplicaSnapshots().
* Use DBTransactionError instead of DBExpectedError in some places
where stages fail.
* Fix failing testGetScopedLock() unit tests so everything passes.
Add more comments to setTransactionListener and onTransactionIdle.
Change-Id: I6a25a6e4e5ba666e0da065a24846cbab7e786c7b
When reading through DatabaseMysqlBase::open(), it was not
obvious that execution would not continue after the conditional
`!$this->conn` block, given it ends in a method call, without
return or throw. I considered adding a return statement after it
for clarity, but it seems in this case it might make more sense
to throw directly given $error here has already gone through a
fallback to getLastError() a few lines up.
Replace the other three calls to reportConnectionError() as well,
which previously passed a useful string that was overwritten
with lastError(). Instead, log both. And make their call to
queryLogger->error() match the previous ones to have an 'error' as well.
This leaves reportConnectionError() as being unused, except for
a call from LoadBalancer. That call was problematic because
it was inside a conditional for IDatabase, but the method isn't
part of that interface. Replace it with a direct throw as well.
Deprecate the method as its now unused in core, and also remove its
'# New method' comment which hasn't made sense since r75341 (16cded8b32).
Change-Id: I0f2ef00ba44bf7090a3ce54edeb8c7e8e543e46a
Once getMain() was called in setSchemaAliases(), the ChronologyProtector
was initialized and the setRequestInfo() call in Setup.php had no effect.
Only the request values read in LBFactory::__construct() were used, which
reflect $_GET but not cookie values.
Use the $wgDBtype variable to avoid this and add an exception when that
sort of thing happens.
Further defer instantiation of ChronologyProtector so that methods like
ILBFactory::getMainLB() do not trigger construction.
Bug: T192611
Change-Id: I735d3ade5cd12a5d609f4dae19ac88fec4b18b51
Previously, passing a specific server index (even the master index)
would result in a connection to some server in $groups or the generic
read group being selected.
Change-Id: Ifb497f5f4bb61f16b310d4d30fb8315e3bcdce8e
The "AUTO" means AUTOCOMMIT, not "automatic transactions"/DBO_TRX,
which is basically the opposite concept. The new name does not
suffer from that ambiguity.
Keep the old constant as an alias for backwards compatibility.
Also remove LoadBalancer comment about non-existing field
Change-Id: I63beeb061fc9be73f320308e4d6393b58628b8c8
Much like the existing errorLogger, but for logging deprecation
warnings.
The default in the RDBMS layer is to call trigger_error() with
E_USER_DEPRECATED. The default in MediaWiki (via MWLBFactory) is to log
to the 'deprecated' log group, much like wfDeprecated() does, although
unfortunately we can't effectively use that directly since we have no
idea of a proper $callerOffset to pass.
Change-Id: Id13625e249516e84d72b6310953bb338a90976da
* Make onTransactionIdle() wait until any transaction round
is gone, even if there is no SQL transaction active. This
is what onTransactionPreCommitOrIdle() already does.
* Decouple "transaction round mode" (DBO_TRX) from whether a
round is active via a 'trxRoundId' LB info field. If rounds
are enabled, but not is started, then the transaction state
should be interpreted as "idle".
* Improve related documentation.
* Add more related unit tests.
Change-Id: I3ab18f577ec0375897fcb63f18f4ee2deeb436e9