Commit graph

1125 commits

Author SHA1 Message Date
Timo Tijhof
cbeda77bd3 Database: Generalise SQL before writing to debug log
The log often contains stuff like the following, where the trimmed
snippet can span many many lines:

* DatabaseBase::query: Writes done: INSERT IGNORE INTO `msg_resource`
   (mr_lang,mr_resource,mr_blob,mr_timestamp) VALUES ('۶?2x?ptt?`0<snip>?`0??O?')
* DatabaseBase::query: Writes done: REPLACE INTO `objectcache`
   (keyname,value,exptime) VALUES ('۶?2x?ptt?`0<snip>?`0??O ?`???`0??O ?`???`0?')

Bug: 67382
Change-Id: I76ca042f166fed56d86df15f788702384d48064c
2014-07-01 21:38:53 +02:00
jenkins-bot
c9148b7121 Merge "Remove LoadBalancer::closeConnecton (deprecated since 1.18)" 2014-06-26 18:47:43 +00:00
jenkins-bot
300f34dd12 Merge "Remove DatabaseMysqlBase::getLagFromProcesslist() (deprecated 1.19)" 2014-06-26 18:39:23 +00:00
jenkins-bot
1bf9ea5143 Merge "Made DB commit() method properly bail out if no trx is active" 2014-06-26 03:52:02 +00:00
jenkins-bot
5f5d4e1c06 Merge "Made DB rollback() method properly bail out if no trx is active" 2014-06-26 03:51:26 +00:00
jenkins-bot
c4f80b4256 Merge "Include trx state in query profiling (and DBPerformance log)" 2014-06-26 00:01:55 +00:00
Aaron Schulz
26f386ae55 Removed old DB_LAST cruft
Change-Id: I5517c43389182e61e4a969ed9ca71dae2388a5d0
2014-06-25 16:12:36 -07:00
Aaron Schulz
a1bc02ec8b Include trx state in query profiling (and DBPerformance log)
* Replaced use of spl hash with random transaction IDs.
  These can be correlated better and make the DBPerformance
  log easier to make sense of. They are also shorter.

Change-Id: I5f49c0d0c26e37807341bbc83b1b41b124164419
2014-06-25 14:13:25 -07:00
umherirrender
44572ddae8 Remove LoadBalancer::closeConnecton (deprecated since 1.18)
Change-Id: Ic572ab2787623bb2b525ffa640e1232dcb1643fb
2014-06-25 19:57:05 +02:00
umherirrender
3b2236e40f Remove DatabaseMysqlBase::getLagFromProcesslist() (deprecated 1.19)
Change-Id: I7dfdd943abf1c94a35e2401f92208c19683dc200
2014-06-25 19:54:15 +02:00
Aaron Schulz
3de2a4022e Made DB rollback() method properly bail out if no trx is active
Change-Id: I157b3c9e7a869866c08d127cb7f9277582e1bc9e
2014-06-25 10:17:21 -07:00
Aaron Schulz
1045fdf312 Made DB commit() method properly bail out if no trx is active
* Also flipped conditional to avoid being in the negative

Change-Id: I30bce9a015bea5909322bba93493500b5b418d18
2014-06-25 10:12:44 -07:00
Brian Wolff
8e98f9e3e6 Double check its safe before dropping new table during db cloning
parserTests.php just killed my user table :(

Bug: 65654
Change-Id: Idcf1c6af6a513c9e6dc650237863db8d61519886
2014-06-25 10:56:53 +00:00
Aaron Schulz
433d57f00f Set MYSQLI_OPT_CONNECT_TIMEOUT in mysqli
* There is no php.ini setting for this, and it is unclear how
  high the default is. The retry behavior of MediaWiki also
  makes little sense without knowing this value.
* Also removed the retry loop which will mostly result in
  giving up the position in some FIFO queue only to come
  back at the end of the line.

Change-Id: Id24f6635508ba87288a2e40f71d4e8016a1805b0
2014-06-20 15:51:45 +00:00
jenkins-bot
93e5dd7d41 Merge "Remove use of strencode() in buildLike()" 2014-06-20 00:19:52 +00:00
Brian Wolff
0b32b01adb Make CloneDatabase error out on shared tables.
Due to the way prefixes are handled, this doesn't work properly.

Make it quit early to prevent confusion. I don't think there's
many people who need shared table support, so I don't know if
its worth the effort to actually fix.

Bug: 65654
Change-Id: I6cd701998fc9066d8c7a4fc86d93a4282cc7f9bd
2014-06-19 09:36:12 +00:00
withoutaname
28f77aebe6 Deprecate $wgMasterWaitTimeout
Not only was this global unused, it also caused the LoadBalancer
to look for the wrong array key, which would always set
$mWaitTimeout to 10 in the conditional. There is also
a manual function LoadBalancer::waitTimeout() for this.

Change-Id: I4b409ef890bec5aac7f666a2ed3dff9ea8bc14cc
2014-06-11 22:24:07 -07:00
jenkins-bot
e50ef5784e Merge "Fetch string to pass through writeTemporary() in DatabaseOracle.php" 2014-06-10 22:24:11 +00:00
Kevin Israel
f2f49c0f21 Remove use of strencode() in buildLike()
This may cause unnecessary backslashes (in the case of a literal
% or _) to end up in the query when the DBMS uses C-style string
escaping; however, the query should still work.

Change-Id: I82681f83dd45fcbecf4bfd672f550cd4dba30949
2014-06-10 15:51:33 -04:00
withoutaname
176213b898 Fetch string to pass through writeTemporary() in DatabaseOracle.php
Pulled some code from insertOneRow() to fix the update() function
and prevent the error warnings in bugzilla 64970 from showing up.
Note that since insertOneRow() and update() contains a lot of
duplicate code, they may be candidates for merging, but that is
outside the scope of this request.

Bug: 64970
Change-Id: I9ff9077d68e77f05f878fc541f87e0a5ce86ecc2
2014-06-08 02:45:46 -07:00
Jeff
72ecbfc127 PostgreSQL: Only rollback when in a transaction
SQL errors would issue a rollback, even when it was
not actually in a transactions.  Doing so would cause
another error to be reported.  This could obscure the
original error, particularly during unit tests.

Fix this by not rolling back when not in a transaction.

Bug: 58095
Change-Id: Ib5220e37dd6c364feee6b7f8e7ecbdae2a2e0ba1
2014-05-29 23:51:57 -07:00
Jeff
52fd3a0e83 PostgreSQL: Support table prefixes
PostgreSQL is usually not used with table name prefixes,
and some of the PostgreSQL-specific code took the
shortcut of not dealing with prefixes.  However, the PHPUnit
tests do force a prefix to be used, exposing this limitation.

Make PostgreSQL code add the prefix to table names being used
in FOR UPDATE OF clause.

This fixes 13 of the 17 PostgreSQL unit tests errors against
git HEAD:

EditPageTest::testAutoMerge with data set #1 ('Elmo', 'one
EditPageTest::testAutoMerge with data set #2 ('Elmo', 'Intro
EditPageTest::testAutoMerge with data set #3 ('Adam', 'one
EditPageTest::testAutoMerge with data set #4 ('Adam', 'one
EditPageTest::testAutoMerge with data set #5 ('Adam', 'Intro
EditPageTest::testAutoMerge with data set #6 ('Berta', 'one
EditPageTest::testAutoMerge with data set #7 ('Berta', 'one
EditPageTest::testAutoMerge with data set #8 ('Berta', 'Intro
WikiPageTest::testDoEdit
WikiPageTest::testDoEditContent
WikiPageTest::testDoRollback
WikiPageTest::testDoRollbackFailureSameContent
WikiPageTest::testExists

The change also applies to 1.22.6 and fixes several unit tests
errors there.

Change-Id: I054690f49e250cadd2dc2a6d9e20dea879d896b6
2014-05-29 15:11:33 -07:00
jenkins-bot
de1f04ace1 Merge "Cleaned up database reconnection logic" 2014-05-27 18:17:02 +00:00
Kevin Israel
6949668b3d DBConnectionError: Expand {{SITENAME}} in pagetitle with Message::text()
Follows-up 485ff9ead9 by making the same change in DBConnectionError,
which overrides MWException::msg() to not use database messages.

Bug: 58447
Change-Id: Iafa9dd741f1f099a4a6cfb8cf655b7d5f504011a
2014-05-26 13:40:34 -04:00
physikerwelt
5048f30f69 Fix: numFields wrong for sqlite
Currently the first row of the result
is used to return the number of fields.
This fix corrects that calculation, which has returned
twice the number of fields before. The reason for that
was that the resulting data array has the following form:
array() {
 [0] => value_0
 ["field_name0"] =>value_0
 [1] => value_1
 ["field_name1"] =>value_1
...
Furthermore the constant 0 (int) is returned if the result
set is empty. This issue should be corrected in the future,
since the number or fields should be answered in a metadata context
independent of the data stored in the relation.

Bug: 65578
Change-Id: I399c7c857dcbd774cc4eb6102bbfe8a8764b07c9
2014-05-21 13:09:13 +00:00
jenkins-bot
638478158a Merge "Avoid fatals in begin/commit/rollback if close() was called" 2014-05-19 04:20:00 +00:00
Aaron Schulz
7868e80b77 Minor fix to DatabaseBase::close() logic
* Only set mOpened to false if closeConnection() was called (or mConn was unset)

bug: 65100
Change-Id: I1ba6b765cfc647a47f21048d993047c0fe0cfe19
2014-05-16 18:34:17 +00:00
Aaron Schulz
3f495e4519 Avoid fatals in begin/commit/rollback if close() was called
Change-Id: I3c555ece5c1e16c6ffcdbec6645d659531400a1b
2014-05-16 10:50:05 -07:00
Aaron Schulz
1cf1450330 Cleaned up database reconnection logic
* If callbacks are pending, just throw the normal query error
  exception for the failed query and clear the callbacks. This
  way an error is still reported, but the handle can be reused
  if desired, instead of being left broken. Also the reported
  error makes more sense.

bug: 65263
Change-Id: Icb2d372e65e6c62b5d5b90a442ea7b7a7f853adc
2014-05-13 14:34:23 -07:00
Siebrand Mazeland
5bc1cf4093 Remove underscore from classes WebInstaller_*
Part of program to remove underscores from class names. Checked core and
675 extensions for occurrences. All uses are in core in core are updated
in this patch. There are no uses in Gerrit extensions.

Change-Id: I6150c2d3f5a18496da5bcdcadc5d8982b70bec7a
2014-05-12 18:36:55 +02:00
Aaron Schulz
28bed62ae6 Made TransactionProfiler handle nested transactions to the same server/DB
Change-Id: Ie4dfd4af88a9da76c76b21053bbd125c6ad3b193
2014-05-01 19:38:39 +00:00
Aaron Schulz
ac8c53583c Avoid fatal error if doing a DB query after close()
Change-Id: I606a3ec5a45136abf396f86f5a65db209128d5c9
2014-04-30 17:04:06 -07:00
jenkins-bot
b7352ae28d Merge "Made DB errors go to the exception log again" 2014-04-30 17:21:47 +00:00
jenkins-bot
13e33c2898 Merge "Fix some issues with Microsoft SQL Server support" 2014-04-29 20:15:31 +00:00
Aaron Schulz
8c6fca60f2 Made DB errors go to the exception log again
* Some DB errors are caught while others bubble up to users.
  It is useful to log the latter separately and it also provides
  more context. The exception logs have a backtrace where as the
  regular DB logs do not.

Change-Id: I7ef7693d96e0258119f714e678099e4813ca0c94
2014-04-28 10:53:16 -07:00
umherirrender
26f6c1797b Use strict array_search in DatabasePostgres.php
array_search( 'FOR UPDATE', array( 'OFFSET' => 0 ) ) gives 'OFFSET'
array_search( 'FOR UPDATE', array( 'OFFSET' => 0 ), true ) gives false

This avoids FOR UPDATE on QueryPage query like Special:BrokenRedirect.

Bug: 62104
Change-Id: Iaa6db6b3ce5eaf940e7a8afe459955f19ad0e01f
2014-04-27 09:24:25 +02:00
umherirrender
23bb3d1cb4 Follow-Ups to "Fixed some @params documentation"
Fix of inline comments of the following patch sets:
Follow-Up: I0056b4a8df243cfc0c5f25378de48f7a35170aca
Follow-Up: I7f605aa9e117b5fd80d9b1440864fe526d2b14a5
Follow-Up: I3622f216a2ca8ac1b5e51892be9f98665f65bc36
Follow-Up: I6627ba0e76d3577c40bf2473e0f78a5ad7368634
Follow-Up: Id75b5ecf648ca50f955b3bde3307c82c4366b102
Follow-Up: I4ca5231119f33039d91da3b57a41cd40719a576b

Change-Id: Id9bbe84b2820e9db44af5783411e955f55f643d4
2014-04-23 13:39:49 +02:00
jenkins-bot
ca895b7072 Merge "Add 'since <version>' to @deprecated annotations" 2014-04-22 19:46:38 +00:00
Skizzerz
1781729aa2 Fix some issues with Microsoft SQL Server support
- Add in missing schema update for 1.23
- Fix detection of table/field existence
- Fix INSERT IGNORE support for cases where the primary key was being duplicated

Change-Id: Ia15673c869c2cf732ffe96f1608cee884d106ccd
2014-04-22 01:08:45 -05:00
umherirrender
f5f1e38b9a Fixed some @params documentation (includes/[db|installer])
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I3595e9aac69ac42fbb74b0783fae0ad9bcc831aa
2014-04-19 13:55:27 +02:00
Bartosz Dziewoński
8c2599f23e Add 'since <version>' to @deprecated annotations
Change-Id: Ief96d55aa95f657a38a62ae3dde1ef7a415ff675
2014-04-15 22:30:01 +02:00
Bartosz Dziewoński
59002d8935 Consistently use '@deprecated since <version>'
Variants included 'in <version>', 'as of <version>' and just the
version number.

Some @deprecated annotations do not have the version number at all,
I want to hunt them down separately.

Change-Id: I8208c6097098f4735d4f51bc42254675f1f27f6d
2014-04-15 22:18:19 +02:00
Sergio Santoro
8117ab63f4 Fixing bug #63738: Debug msg not showing correctly
Change-Id: I49d826f63810d99aefa5b842cd3d6b88989ef086
2014-04-12 15:12:38 +02:00
jenkins-bot
cdd1b9ef34 Merge "Fix usage of $wgDebugDumpSql" 2014-04-07 21:22:02 +00:00
umherirrender
23fab68274 Fix spacing after @param and friends in comments
Searched for:
\@(param|return|throws|since|deprecated|access|todo|var)[ \t]{2,}

Change-Id: Icce22ba9fe0635455691ca58d9872d618151f346
2014-04-05 20:02:29 +00:00
Alexandre Emsenhuber
a0d178740a Fix usage of $wgDebugDumpSql
- In DatabaseMssql, use $this->debug() instead of $wgDebugDumpSql
  so that it takes into account the DBO_DEBUG flag
- Use the same construction to set the DBO_DEBUG flag in
  LBFactorySimple::newMainLB() as for the other flags so that
  it is easier to read the code

Change-Id: Ie775cdb3677739a97e0d64dabbf80fc685149337
2014-04-05 08:54:11 +02:00
jenkins-bot
57c4cd7ce5 Merge "Improve handling of uncommitted DB txns with "uncaught" exceptions" 2014-03-31 16:30:33 +00:00
Alexandre Emsenhuber
449ee32451 Add missing line breaks to wfDebug() calls
Also removed true as second parameter to it from CloneDatabase.php
since it is the default value of that parameter.

Change-Id: I727ebae2bd4df0e26019985ce8c7ce73381c5642
2014-03-29 11:52:07 +01:00
Brad Jorsch
dc7d342d93 Improve handling of uncommitted DB txns with "uncaught" exceptions
One of the causes (if not the cause) of bug 56269 is if something
manages to throw an exception that makes it to MediaWiki::run's
last-resort exception catcher while having an open database transaction:
the transaction never gets committed or rolled back, so it gets
implicitly rolled back and a warning is raised.

The API has the opposite problem in bug 63145: it catches the exception
but then does the normal DB shutdown which *commits* the transaction.
This is certainly the Wrong Thing to do.

Ideally, neither of these would ever happen because any code using
transactions would have its own try-catch that would catch any
exception, rollback the transaction, and then rethrow the exception. But
it happens anyway, so let's have both of these last-resort exception
handlers do the rollback, and also log the exception so the throwing
code has a better chance of being properly fixed.

Bug: 56269
Bug: 63145
Change-Id: I8f1da51187b281fe4afc0d5a0c49f5caf3612e92
2014-03-27 12:46:07 -04:00
jenkins-bot
d1f8fb08d4 Merge "Automatically add a new line at the end of wfLogDBError()" 2014-03-24 18:45:47 +00:00