Commit graph

46 commits

Author SHA1 Message Date
Aaron Schulz
8f45d13fe1 rdbms: remove obsolete getReplicaPos() code
Also fixed incorrect comment for getGtidCoordinates()

Change-Id: Ie2ce8a8bba230ceb6d068957e5ffeb360c3fe473
2018-02-06 17:18:00 -08:00
Aaron Schulz
128068a4d8 rdbms: avoid pointless "SHOW SLAVE STATUS" calls in masterPosWait()
This code branch is not useful in the GTID case

Change-Id: Ia112c9b4b9c1f1297cc4eaac7f4a5a1ca882f02e
2018-01-31 00:11:33 +00:00
Brad Jorsch
d40916cb85 Make DatabaseMysqlBase::insertSelect() safer to use
Certain server configurations, including the current MariaDB defaults,
make INSERT SELECT unsafe for replication in MySQL/MariaDB. When the
server configuration is not known to be safe, force the use of the
non-native implementation. Note this only has effect in CLI mode, as
non-CLI mode already forces the non-native implementation since
I2dba6024.

Also, native INSERT SELECT won't be safe with any statement-based
replication method if the order of rows in the SELECT is not
deterministic. Add a warning to the method's documentation pointing this
out.

Change-Id: I9173f6559809bd01830bd0a9f443c7269cc58ce2
2018-01-26 09:10:22 -08:00
Aaron Schulz
62bb392e9e Lower DatabaseMysqlBase::lock logging to INFO
Whether the lock() acquisition failing is a huge problem depends
on what the caller is doing. Let the caller do any logging it needs.

Bug: T180793
Change-Id: I3d05138d312d8b973df153bb511e69619d663c9d
2017-12-03 03:56:32 +00:00
Chad Horohoe
93d7ac1bec Group lock failed messages in mysql db driver
Change-Id: Ia8c993a3c405c37200c6c1a0dbe6b12726def7c1
2017-11-03 09:06:12 -07:00
Matthew Flaschen
3638695419 Detect query timeouts and throw a specific exception
Throw DBQueryTimeoutError if a database query error is detected
to be a timeout.

Only DatabaseMysqlBase has been updated here.

This is a subclass of DBQueryError, so existing catch'es will work.

Bug: T175775
Change-Id: I4749dc33ad530d9b22504f02106b1ca49e8eb167
2017-09-20 08:47:09 +00:00
Aaron Schulz
1b5be5904d Add sslCAFile option to DatabaseMysqli
This makes all arguments to the mysqli::set_ssl() call be controllable.

Change-Id: I67ed742add633a77e97d08b812e420a73cd83a52
2017-08-24 16:54:19 -07:00
Aaron Schulz
07cd19aeee Make mysql getHeartbeatData() method not count query/RTT in estimate
Optimize for the common case where lag does not strictly increase
during trip times instead of being pessimistic.

Change-Id: Ibb0e3faad23862d397e1cc2a9f7e2a8293fa5f2b
2017-08-17 12:31:23 -07:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Aaron Schulz
0352fe44f1 Avoid checking double-prefixed table names in mysql tableExists()
Change-Id: I9d91a5305227171d0776ffa443d4e538fbe1b15f
2017-06-27 18:41:32 +00:00
mainframe98
b1c34a25df Fix the tableExists method of MysqlBase
The table name generated by Database::tableName() does not work in
MysqlBase's tableExist method, as the syntax of SHOW TABLES does not
function like other foreign db queries. It instead should use FROM
$database rather than the database name in front of the table name.

Bug: T168207
Change-Id: I7806090eaa647959fd34de8bc606eeb952161529
2017-06-22 21:12:47 +00:00
jenkins-bot
eb72adcb4e Merge "New maintenance script to clean up rows with invalid DB keys" 2017-04-24 15:19:30 +00:00
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
Aaron Schulz
1a1c43bdff Database: clean up lockTables() and add postgres support
A new method is now available to check whether session scope
locks are supported, which callers typically want when using lock().
Its usage can avoid deadlock prone and expensive row-level locks for
some maintenance tasks.

For Postgres, table locks are tied to the transaction. Trigger
startAtomic() in lockTables() and endAtomic() in unlockTables() to
assure that a transaction is present.

Also remove LOW_PRIORITY feature, which is ignored by mysql.

Change-Id: I499061bcc2763afb1ff4a43319064eed4ba3a8fe
2017-04-07 16:28:36 -07:00
Tim Starling
e4a716ac0d Update comment for indexName(), explaining why it exists
Bug: T154872
Change-Id: Idf64b85dc56dcc28f3a25b2b8ded44c5490cf56c
2017-04-03 03:26:22 +01:00
Reedy
3b000dc2a8 Make the indexName functions more obviously laid out
Move Sqlites's indexName to Database to have no remapping by default.
This is because MSSQL and Postgresql both don't need remapping, it's
just MySQL that's the problem.

So move the one from Database into MysqlBase to only do the remappings
there.

Also fix up the comments to make them less vague, not mentioning tables
when the function has no table parameter passed, so hence, no context
as to which table said index is wanted to be used

Bug: T154872
Change-Id: I46c575771e6cb36176bcf6cd1a865b703db0275d
2017-03-30 12:29:35 +01:00
This, that and the other
6519c42d24 New maintenance script to clean up rows with invalid DB keys
The TitleValue constructor, used by the link cache among other things,
throws an exception for DB keys which do not satisfy a simple sanity test
(starting or ending with _, or containing a space, tab, CR or LF
character). This has broken certain special pages on a number of WMF sites;
see T99736, T146778 and T155091.

The new cleanupInvalidDbKeys.php script allows these bogus entries to be
removed from the DB, making sure these exceptions won't be thrown in the
future. It cleans the title columns of the page, archive, redirect,
logging, category, protected_titles, recentchanges, watchlist, pagelinks,
templatelinks, and categorylinks tables.

The script doesn't support batching; most wikis should have fewer than 500
broken entries in each table. If need be, the script can be run several
times.

To make the LIKE queries work properly I had to fix the broken escaping
behaviour of Database::buildLike() -- previously it had a habit of double-
escaping things. Now an ESCAPE clause is added to change the escape
character from the problematic default backslash, and tests are added to
cover the changes.

Bug: T155091
Change-Id: I908e795e884e35be91852c0eaf056d6acfda31d8
2017-03-11 00:27:27 +11:00
Aaron Schulz
004ffaa91a Make masterPosWait() error clearer
Change-Id: I86706b2c4167fba897c56235072675b66ed06634
2017-03-08 21:22:36 -08:00
Aaron Schulz
e01fd44388 Move ResultWrapper subclasses to Rdbms
Change-Id: I6f3f0e85e268b24c57c537aa6ad8016e0b4cdddb
2017-03-03 00:44:41 +00:00
Aaron Schulz
8a5d8c0c71 Move Field classes to Rdbms namespace
Update core callers and leave a class alias to \Field.

Change-Id: I4908282301d5de2a20baafe510557bd2c3867de5
2017-02-16 01:14:37 +00:00
Aaron Schulz
864eab03e7 Move DBMasterPos to Rdbms namespace
Updated all callers

Change-Id: Iacd5d6f7f18d8b23df24637cda61592112490eb0
2017-02-10 02:38:56 -08:00
Fomafix
ce6f7faadd Remove trailing empty lines in PHP
Performed using
find . -name \*.php -exec sed -i -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba' {} \;

Change-Id: I5d0627f94c73690cf3a8a453539c22c760c2aa60
2017-01-16 22:06:43 +01:00
Aaron Schulz
22ac7bac9e Avoid starting transactions in getHeartbeatData()
This can avoid excess round trips in LoadBalancer::getLagTimes()

Change-Id: Ibe9558cc825c5a0dd03ea109926ff15d00c60e31
2016-12-22 15:16:07 -08: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
Aaron Schulz
fa8253824f DatabaseMysqlBase visibility cleanups
Change-Id: I015fc37a5525a31fb779ba841a1966675ebc494d
2016-11-03 07:33:05 +00: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
jenkins-bot
5738075f50 Merge "Call parent::__construct() in MysqlBase AFTER transferring specific parameters" 2016-10-12 16:49:35 +00:00
Reedy
91e54fcad8 Call parent::__construct() in MysqlBase AFTER transferring specific parameters
Bug: T147852
Change-Id: Id07bb38efb6a9a3b4f4f7e07c0a2c6a74bb1b58d
2016-10-11 22:29:04 +01:00
jenkins-bot
84ca06799f Merge "SECURITY: quote booleans as string (not integer) in DatabaseMysqlBase" 2016-10-11 15:31:49 +00:00
Gergő Tisza
24a108b334 SECURITY: quote booleans as string (not integer) in DatabaseMysqlBase
Comparing a string column to 0 will produce spurious matches, and it is easy
to get a false value in unexpected places. Comparing an int column to '0'
does not seem to cause any problems.

Bug: T147537
Change-Id: I5ad547de509b3417b5937be6bdda9befb8aed8b6
2016-10-11 11:16:50 -04:00
Aaron Schulz
5c3d22a029 Make DatabaseMysqlBase use connLogger for connection errors
Previously, they went to queryLogger, which is not the proper log.

Change-Id: Ifeea2261afc9572bf613a96306537f564b3e95d7
2016-10-04 21:20:39 +00:00
Aaron Schulz
0bdab07814 Move DatabaseBase to a class alias for type-hints
Change-Id: Ib6bbbd751358cbc2f2d2767c80721d3d8f142c0d
2016-09-29 06:09:03 +00:00
Aaron Schulz
a8a8eb39a8 Rename getSlavePos() => getReplicaPos()
All callers updated

Change-Id: Ieb87df1bd134e6b0d8b01be581288e98fe3543ee
2016-09-23 21:17:32 -07:00
Aaron Schulz
508d3b21ea Remove unused Database::isView()/clearViewsCache() methods
Also make getLazyMasterHandle() protected.

Change-Id: Id6b48ff976a800052c22e90b572695ab3b8beb7e
2016-09-23 20:32:36 -07:00
Aaron Schulz
3a839c5927 Inject schema vars into DatabaseMysql
Also fix broken patchSql.php maintenance script

Change-Id: I45bccb0e2e10bd06651a551fa08ed0c66d11eb6a
2016-09-22 21:07:27 +00:00
jenkins-bot
ef3825614c Merge "Clean up lock name in lock messages in DatabaseMysqlBase" 2016-09-21 21:13:36 +00:00
Aaron Schulz
d0e6d92fb0 Check Database::mSessionTempTables in Database::tableExists()
Also make the temp table tracking catch plain "DROP TABLE"
in addition to the stricter "DROP TEMPORARY TABLE" clause.

Bug: T146300
Change-Id: Ia8306ec25e63adcdcf0dcc8f6a700dd01afdc948
2016-09-21 19:02:09 +00:00
Brad Jorsch
29d7ab8eeb Add table prefix in new MySQL tableExists()
Bug: T146289
Change-Id: If73907f69471a6a91e1db7131a57439f950c5d8c
2016-09-21 11:44:06 -04:00
Aaron Schulz
87157b7b44 Clean up lock name in lock messages in DatabaseMysqlBase
Change-Id: I9d3eb566f4e4f6d982cbc15df082cf2dd3f9614e
2016-09-20 17:25:58 -07:00
Aaron Schulz
c0f79b0c05 Mention the lock name in DatabaseMysqlBase lock() errors
Also use warning() instead of debug()

Change-Id: I9f5b331072caf29985bfb4319786cc2c5cddf5dd
2016-09-20 23:37:21 +00:00
Aaron Schulz
4e4b999749 Improve tableExists() for MySQL
Use SHOW TABLES to avoid log spam when the table does not exist.
This should make the CLI jenkins log a bit more readable.

Change-Id: I027a9d0af0e42959e9f03cebb295218068a263d3
2016-09-20 17:37:41 +00:00
Aaron Schulz
fcf67bde0e Stub out DatabaseBase::getSearchEngine() as a dummy method
SearchEngineFactory::getSearchEngineClass() should be used instead

Change-Id: I984b80815633a8dc38a76d7de8a46ec249ae729f
2016-09-19 08:11:18 -07:00
Aaron Schulz
ff38b54d61 Move LIST_ constaints to IDatabase class constants
Leave aliases in Defines.php for backwards compatibility.

Change-Id: I88b45e0943cbfe97d863c2e0a4911fc0f81e5bb5
2016-09-19 07:59:21 +00:00
Aaron Schulz
fd224eac76 Move mysql database classes to /libs/rdbms
Change-Id: I1ba1799deec10e5a8ab8829b69e0708626e723e2
2016-09-17 23:38:51 +00:00
Renamed from includes/db/DatabaseMysqlBase.php (Browse further)