Make Database disconnect and error suppression more robust
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 10 Aug 2016 02:15:05 +0000 (19:15 -0700)
committerKrinkle <krinklemail@gmail.com>
Thu, 11 Aug 2016 07:26:33 +0000 (07:26 +0000)
commit3675f1d447204dc07d87cefc9a6015e67f33798e
treebb83a031416139c22669e6a71c3d9b708d32fd7f
parenta2242913b2e27e46f616b8885102d4bf1b8583f2
Make Database disconnect and error suppression more robust

* 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
includes/db/Database.php
includes/db/DatabaseMysql.php
includes/db/DatabaseMysqlBase.php
includes/db/DatabaseMysqli.php
includes/jobqueue/JobRunner.php
tests/phpunit/includes/db/DatabaseMysqlBaseTest.php