* Refactor out some code duplication in query() into a
separate private method.
* Remove the total master/slave query profiling, which is not
necessary and redundant.
* Provide a default implementation for reconnect().
* Make reconnect() catch errors so it can match the docs that say
it returns true/false to indicate failure. Likewise for ping().
* Optimize ping() to no-op if there was obvious recent activity.
* Move the ping() round in JobRunner to approveMasterChanges.
This way, all commit rounds benefit from this logic.
* Add more doc comments for DatabaseBase fields.
Change-Id: Ic90ce2be4187244a0e8d44854c39d4b78be8e642
* Do not commit() inside masterPosWait(). This could happen
inside JobRunner::commitMasterChanges, resulting in
one DB committing while the others may or may not later commit.
* Migrate some commit() callers to commitMasterChanges().
* Removed unsafe upload class commit() which could break
outer transactions.
* Also cleaned up the "flush" flag to make it harder to misuse.
Change-Id: I75193baaed979100c5338abe0c0899abba3444cb
* Disallow $ignoreErrors in query() on deadlocks, since that would otherwise
silently rollback all changes from any other callers.
* Move recoverability checks for disconnects to canRecoverFromDisconnect().
* The first write of a DBO_TRX transaction is now considered recoverable.
* Run onTransactionResolution() callbacks on disconnect/deadlock rollback.
Some DeferrableUpdate need this to know to abort.
* Disallow $ignoreErrors on disconnects considered unrecoverable. This
makes it so that query() callers cannot cause writes from other callers
to be silently lost, which is hard to reason about.
* Moved ping() logic to simple reconnect() method and ping() simply do
a dummy SELECT, which triggeres reconnection if safe. Previously,
ping() might cause subtle partial transaction loss.
* Remove ping() from strencode(), which would cause partial transaction
loss where it actually reached.
* Remove mysqlPing() per https://bugs.php.net/bug.php?id=52561.
Bug: T142079
Change-Id: Ifb7f772ae849d67c0d92240a115c3f392e252937
This avoids having users think they can make edits when an
exception will just be thrown when they try to save. Likewise
for other write actions.
Bug: T24923
Change-Id: I49c4057b672875ec6f34681a5668a509cec05677
The IDs will be included in MySQLMasterPos objects and,
if specified by config, in slave lag wait methods.
Bug: T135027
Change-Id: I1dfc0210b715b449ec07760c712d0267763f2697
* Make the slave wait methods work properly in this case if
the config flag is set.
* Also fixed a small IDEA error.
Bug: T135690
Change-Id: I9a12f1fc54c0b426f64c19ac2bf720e683fcf2fe
* Clean up return value types and docs.
* Handle master switch-over better w.r.t the job queue due
to binlog name changes (the host portion). Previously the method
would fail and trigger read-only mode when waiting on former
master positions. Assume the the switch-over was done properly
and thus return immediately.
Bug: T126436
Change-Id: Ib8c05a5c72d03a5c98e41b23c5653fc194b6d130
Otherwise, transactions might be committed without cooperative
locks that were supposed to be present. This is similar to the
logic of not auto-reconnecting if a transaction was started to
avoid committing incomplete changes.
Change-Id: Ia7bc6b188bb5ee53a5bf7c5a30718bc7c4dd0ba9
Use a sha1 hash if the lock name exceeds the MySQL limit. The class
for Postgres already avoids this problem with number hashes.
Change-Id: If587c672b4ff210ee3b512bbe2910ae247079d3f
Before, it just used the immediate master entry, which could be another
slave. In that case, it may not even exists at all.
Bug: T119648
Change-Id: Iea970b81ad2c9855aafcccf0bb0662fc0b3a8d4d
Saves a small trip through ObjectCache::getLocalClusterInstance(),
call_user_func_array, and func_get_args.
Change-Id: If5d2170accaecb6cc8c0520ab9de9241b42a4727
* This avoids bothering with MASTER_POS_WAIT() if an equal/higher
position was already successfully waited on by another process.
* Add DBMasterPos toString() and hasReached() methods, which
MySQLMasterPos already implemented and used.
* Moved more wfDebug() statements to the 'replication' log.
Change-Id: I423b5fe2da8d97889a6d204a635e351342de7649
* This gets lag information that is useful when
the calling code is about to run queries that
will have their results cached.
* This is now used in place of trxTimestamp() for
WANObjectCache set() and getWithSetCallback().
* The WAN cache will use a low TTL if the lag is
too high to avoid caching stale data for weeks.
* Bumped MAX_COMMIT_DELAY as nothing enforces it.
Bug: T113204
Change-Id: I2a95b4088cff42d6e980351555f81a4b13519e24
This gives static method callers the option
to use methods like Database::factory() instead
of having to use the uglier DatabaseBase::factory().
Change-Id: I61800626b71ad2803a897df060059dbaf8778679
Changed some old bugzilla links to new phabricator links in comments,
test data and error message. This reduces the need for redirects from
old bugzilla to new phabricator from our source code.
Change-Id: Id98278e26ce31656295a23f3cadb536859c4caa5
* Moved some duplicated logic to assertOpen() method
* Override doc type for mConn for the mysqli subclass
* Fixed a few code comments
Change-Id: I78d595554ed51f64ca7cf7bd7ce369a492a59145
* This is useful if the first slave picked went down and others
can be used, especially in longer running scripts.
* A possible improvement to this would be to eventually allow
retries by removing the bad handles from the load balancer,
since isOpen() will never change from false. This would only
be useful for very very long running CLI scripts and is
probably an edge case for now.
Change-Id: Iecfc4004b4b2289907a4645b431de19198790d6c
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.
Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.
Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.
Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
MediaWiki running with an old mysql or php without mysqli cannot
use the newly added flags property of Database::fieldInfo.
For backward compatibility add the missing properties using the flags
property to the result of Database::fieldInfo.
Added missing unsigned, numeric, blob and zerofill properties to the
MysqlField using flags in mysqli.
The missing fields in mysqli are taken from
http://php.net/manual/en/function.mysql-fetch-field.php
Follow-Up: I641dc1fad0a5bb14815f55e0357243a562fd672b
Change-Id: I1da904df72f8af7725fc7ff94121ef85b18a36f8
The primary key of the user table is an unsigned int, the column
user_newtalk.user_id refer the id and should have the same typ to store
the same values as the user table does.
No pre-deployment activity necessary; no need to sync deployment
and merge; can be done at any time (now or later)
Bug: T77005
Change-Id: I641dc1fad0a5bb14815f55e0357243a562fd672b
Doc comments state that these methods return ints. In order to ensure
that, values must be cast to int before they are returned.
With respect to selectRowCount(), follows-up 65f81d2843.
Change-Id: I108221ce4ad1b5b103b015fe875de54e04781741