Catrope has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399404 )

Change subject: Follow-up 36f4daf32c: allow no-write database connections to 
use transactions
......................................................................

Follow-up 36f4daf32c: allow no-write database connections to use transactions

After 36f4daf32c was merged, Aaron pointed out on Gerrit that:

    Transaction can be used on replicas for REPEATABLE-READ mode, so
    queries in that transaction see the same version of the DB. Those
    do not involve writes and things would probably break sometimes
    without it (like reads following foreign keys and reference in
    separate queries).

So allow no-write connections to call begin() and commit(), and only
throw an exception when a write query is attempted.

Bug: T183265
Change-Id: I138677a714df13ead08061c3e9ef794c3befbe9d
---
M includes/libs/rdbms/database/Database.php
1 file changed, 0 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/04/399404/1

diff --git a/includes/libs/rdbms/database/Database.php 
b/includes/libs/rdbms/database/Database.php
index 1c9cad5..3d40417 100644
--- a/includes/libs/rdbms/database/Database.php
+++ b/includes/libs/rdbms/database/Database.php
@@ -2965,13 +2965,6 @@
        }
 
        final public function begin( $fname = __METHOD__, $mode = 
self::TRANSACTION_EXPLICIT ) {
-               if ( !$this->allowWrite ) {
-                       throw new DBError(
-                               $this,
-                               'Write operations are not allowed on this 
database connection!'
-                       );
-               }
-
                // Protect against mismatched atomic section, transaction 
nesting, and snapshot loss
                if ( $this->mTrxLevel ) {
                        if ( $this->mTrxAtomicLevels ) {
@@ -3033,14 +3026,6 @@
        }
 
        final public function commit( $fname = __METHOD__, $flush = '' ) {
-               if ( !$this->allowWrite ) {
-                       // we should never get here, since begin() would 
already throw
-                       throw new DBError(
-                               $this,
-                               'Write operations are not allowed on this 
database connection!'
-                       );
-               }
-
                if ( $this->mTrxLevel && $this->mTrxAtomicLevels ) {
                        // There are still atomic sections open. This cannot be 
ignored
                        $levels = implode( ', ', $this->mTrxAtomicLevels );

-- 
To view, visit https://gerrit.wikimedia.org/r/399404
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I138677a714df13ead08061c3e9ef794c3befbe9d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to