Commit graph

26 commits

Author SHA1 Message Date
jenkins-bot
2f86f8dbb9 Merge "Don't throw an exception when waiting for replication times out" 2018-09-04 02:20:12 +00:00
Tim Starling
e8df0fbab1 Don't throw an exception when waiting for replication times out
For maintenance scripts it is usually harmful to throw an exception.
For jobs the exception was already caught and handled appropriately,
so this can continue as before. For DeferredUpdates it was extremely
harmful to throw an exception. So in the web case, reduce the timeout to
1s and continue as normal if the 1s timeout is reached. This allows the
DeferredUpdate to be throttled without being killed.

In the updater, increase the replication wait timeout to 5 minutes.
ALTER TABLE could indeed cause replication lag, but exiting the update
script with an exception will probably ruin your day. Update actions are
not necessarily efficiently restartable.

Do not call JobQueue::waitForBackups() when jobs are popped. Maybe it
makes sense to call a queue-specific replication wait function for
bulk inserts, like copyJobQueue.php, but doing it when jobs are popped
just makes no sense. Surely the worst that could happen is that the
queue would become locally empty? Removing this waitForBackups() call
avoids waiting for replication twice when JobQueueDB is used.

Bug: T201482
Change-Id: Ia820196caccf9c95007aea12175faf809800f084
2018-09-03 12:29:35 +10:00
Zoranzoki21
1f2e9c1b54 Fix common typos in code
Bug: T201491
Change-Id: Id962b79f2590c51380cb977e727b7548abc11d33
2018-09-02 09:03:07 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Reedy
765370a6db Add @deprecated tags to various class_alias calls
Bug: T195576
Change-Id: I10cd8415891bfe4a278eee06c9cfe905b3e036dc
2018-05-29 13:10:20 -07:00
Aaron Schulz
3975e04cf4 rdbms: make Database query error handling more strict
Handle all errors in query() that might have caused rollback by
putting the Database handle into an error state that can only be
resolved by cancelAtomic() or rollback(). Other queries will be
rejected until then.

This results in more immediate exceptions in some cases where
atomic section mismatch errors would have been thrown, such as a
an error bubbling up from a child atomic section. Most cases were
a try/catch block assumes that only the statement was rolled back
now result in an error and rollback.

Callers using try/catch to handle key conflicts should instead use
SELECT FOR UPDATE to find conflicts beforehand, or use IGNORE, or
the upsert()/replace() methods. The try/catch pattern is unsafe and
no longer allowed, except for some common errors known to just
rollback the statement. Even then, such statements can come from
child atomic sections, so committing would be unsafe. Luckily, in
such cases, there will be a mismatch detected on endAtomic() or a
dangling section detected in close(), resulting in rollback.

Remove caching from DatabaseMyslBase::getServerVariableSettings
in case some SET query changes the values.

Bug: T189999
Change-Id: I532bc5201681a915d0c8aa7a3b1c143b040b142e
2018-04-04 21:26:11 -07:00
Gergő Tisza
cd222cc601 Mark DBError as runtime exception
Some tools (e.g. PHPStorm) can trace exceptions through the
call tree and show warnings when a call can throw an exception which
is neither handled nor acknowledged via @throws annotation.
This is quite useful but currently too noisy to use due to all methods
involving some kind of DB interaction potentially throwing a DBError.
To avoid false warnings, make DBError inherit from RuntimeException
to signal it to such tools that it is not meant to be handled.

Change-Id: I847d258791b128547e10672c5e06a9ce18458371
2018-01-03 02:26:17 +00:00
Tim Starling
dc2948d76d A few doc comment fixups
* Remove some creation dates, they are not protected by GPL
* Remove duplicate @defgroup API
* Remove @ingroup from some @file doc comments on class files. It is not
  useful to list class files alongside classes in the doxygen module menu.
  Add @ingroup to some more class files that had @ingroup on their file,
  that was probably the author's intent.
* In PackedOverlayImageGallery, use the file comment as a class comment
* Don't put @defgroup and @file in the same comment. @defgroup makes the
  whole doc comment describe the group.
* Instead of putting AnsiTermColorer in two groups, use hierarchical
  groups.

Change-Id: If54f6e0b2bc1ea6de42045885cf836ee67b8e961
2017-12-04 11:11:52 +11:00
Aaron Schulz
2048c04055 Revert Message dependency from DB exception classes
This was added in a90bbf1a.

These classes are in /libs and should not depend on all of MediaWiki.

Change-Id: I67bc818b0c674f1aa3e0dde27a38a9f385fcab75
2017-09-27 09:18:15 +02: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
Chad Horohoe
78b78644fb DB excepions: consistently declare constructors as public
Also DBTransactionSizeError::getKey() while we're here

Change-Id: Ic76abf3ca0bf74dd96018d67da466365957bf3b1
2017-08-30 16:44:50 -07:00
Umherirrender
3f1a52805e Use short type bool/int in param documentation
Enable the phpcs sniffs for this and used phpcbf

Change-Id: Iaa36687154ddd2bf663b9dd519f5c99409d37925
2017-08-20 13:20:59 +02:00
Umherirrender
bf61a77431 Change @inheritdoc to @inheritDoc
Only @inheritDoc works for the Sniff
MediaWiki.Commenting.FunctionComment

Change-Id: I91fc02cda6701d790e4334fc2bc47f230955545c
2017-08-11 16:49:52 +02:00
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +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
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07: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
Brad Jorsch
a90bbf1a48 Add ILocalizedException interface
We already throw around some exceptions that are localized
(ErrorPageError and its subclasses, MalformedTitleException), but
there's no standard way to recognize them. Let's change that.

Then let's use them in the API to be able to have internationalized
errors when such exceptions are caught, instead of wrapping the
English-language version.

Change-Id: Iac7c90f92a889f8de9dae373547c07b884addaea
2016-12-08 13:53:24 -05:00
Stephane Bisson
e87858e4f3 DBError expects IDatabase|null as its first argument
I came across LBFactory.php:357 while testing my
master/replica db setup. It was not configured correctly
and I got "Argument 1 passed to DBExpectedError::__construct()
must implement interface IDatabase, string given" instead
of the actual error.

Change-Id: I949e1803f84459f8bb83e957a88d1e927cad16f7
2016-11-01 10:51:13 -04:00
Aaron Schulz
5bbac35ed1 Replace DatabaseBase:: with Database:: and update type hints
Change-Id: I3919b04eb2de4fa0bf8a02239fb5bbf17d347511
2016-09-27 04:20:03 +00:00
Aaron Schulz
80bee99157 Break long lines and generalize some comments in /rdbms
Change-Id: Ibf80c67b59df748e98d74eeab492b1f33d198024
2016-09-22 14:02:53 -07:00
Aaron Schulz
aa9d1c91b6 Split up DBError classes into their own files
Change-Id: I671f1a88f0192a5199cfc9c6d7fbde1bff5c4ac8
2016-09-22 13:32:08 -07:00
Aaron Schulz
aec9ad8ad7 Remove MediaWiki mentions from /rdbms error strings
Change-Id: Ia330d8e465641d04e5d22a24490d792913f1ccb8
2016-09-22 19:23:18 +00:00
Aaron Schulz
5820c6dcac Exception cleanups for LoadBalancer
* Make the error message itself be dumb/raw.
* Make the exception exposer show the same GUI message.
* Remove overzelous wgLang check in MWExceptionRenderer.

Change-Id: Ifffff3b3cc785ea3080e4975efe33b3c2cf304d6
2016-09-15 01:32:43 +00:00
Aaron Schulz
048da5273b Move DBError to /libs/rdbms/exception
Change-Id: I2ad40db66a68f03fb34a63278a652e0505195076
2016-09-14 11:55:33 -07:00