rdbms: upgrade transaction misuse warnings to exceptions
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 9 Mar 2018 00:58:48 +0000 (16:58 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 20 Mar 2018 17:44:54 +0000 (10:44 -0700)
The last warnings in logstash for WMF have been cleaned up

Change-Id: I7d5bb624bc583191c3a0c95aa4e99322d6d5008c

RELEASE-NOTES-1.31
includes/libs/rdbms/database/Database.php

index e5226ec..899f8b3 100644 (file)
@@ -297,6 +297,11 @@ changes to languages because of Phabricator reports.
   wikitext table captions, wikitext table headings, wikitext table cells. HTML
   headings, HTML list items, HTML table captions, HTML table headings, HTML table cells
   will not have this trimming behavior.
   wikitext table captions, wikitext table headings, wikitext table cells. HTML
   headings, HTML list items, HTML table captions, HTML table headings, HTML table cells
   will not have this trimming behavior.
+* Calling Database::begin() explicitly during an implicit transaction or when DBO_TRX
+  is set results in an exception. Calling Database::commit() explicitly for an implicit
+  transaction also results in an exception. Previously these were logged as errors.
+  The startAtomic() and endAtomic() methods, or AtomicSectionUpdate should be used
+  instead.
 
 == Compatibility ==
 MediaWiki 1.31 requires PHP 5.5.9 or later. Although HHVM 3.18.5 or later is supported,
 
 == Compatibility ==
 MediaWiki 1.31 requires PHP 5.5.9 or later. Although HHVM 3.18.5 or later is supported,
index 2d90be6..8cb726e 100644 (file)
@@ -3185,16 +3185,12 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                                $msg = "$fname: Explicit transaction already active (from {$this->trxFname}).";
                                throw new DBUnexpectedError( $this, $msg );
                        } else {
                                $msg = "$fname: Explicit transaction already active (from {$this->trxFname}).";
                                throw new DBUnexpectedError( $this, $msg );
                        } else {
-                               // @TODO: make this an exception at some point
                                $msg = "$fname: Implicit transaction already active (from {$this->trxFname}).";
                                $msg = "$fname: Implicit transaction already active (from {$this->trxFname}).";
-                               $this->queryLogger->error( $msg );
-                               return; // join the main transaction set
+                               throw new DBUnexpectedError( $this, $msg );
                        }
                } elseif ( $this->getFlag( self::DBO_TRX ) && $mode !== self::TRANSACTION_INTERNAL ) {
                        }
                } elseif ( $this->getFlag( self::DBO_TRX ) && $mode !== self::TRANSACTION_INTERNAL ) {
-                       // @TODO: make this an exception at some point
                        $msg = "$fname: Implicit transaction expected (DBO_TRX set).";
                        $msg = "$fname: Implicit transaction expected (DBO_TRX set).";
-                       $this->queryLogger->error( $msg );
-                       return; // let any writes be in the main transaction
+                       throw new DBUnexpectedError( $this, $msg );
                }
 
                // Avoid fatals if close() was called
                }
 
                // Avoid fatals if close() was called
@@ -3260,10 +3256,10 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                                        "$fname: No transaction to commit, something got out of sync." );
                                return; // nothing to do
                        } elseif ( $this->trxAutomatic ) {
                                        "$fname: No transaction to commit, something got out of sync." );
                                return; // nothing to do
                        } elseif ( $this->trxAutomatic ) {
-                               // @TODO: make this an exception at some point
-                               $msg = "$fname: Explicit commit of implicit transaction.";
-                               $this->queryLogger->error( $msg );
-                               return; // wait for the main transaction set commit round
+                               throw new DBUnexpectedError(
+                                       $this,
+                                       "$fname: Expected mass commit of all peer transactions (DBO_TRX set)."
+                               );
                        }
                }
 
                        }
                }
 
@@ -3314,7 +3310,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                        } elseif ( $this->getFlag( self::DBO_TRX ) ) {
                                throw new DBUnexpectedError(
                                        $this,
                        } elseif ( $this->getFlag( self::DBO_TRX ) ) {
                                throw new DBUnexpectedError(
                                        $this,
-                                       "$fname: Expected mass rollback of all peer databases (DBO_TRX set)."
+                                       "$fname: Expected mass rollback of all peer transactions (DBO_TRX set)."
                                );
                        }
                }
                                );
                        }
                }