Remove Atomic methods from ConnectionManagers
authoraddshore <addshorewiki@gmail.com>
Thu, 1 Dec 2016 00:13:16 +0000 (00:13 +0000)
committerKrinkle <krinklemail@gmail.com>
Fri, 2 Dec 2016 04:50:29 +0000 (04:50 +0000)
Change-Id: I697f63f45975b13af52bc22fced6e4d07e35115f
Depends-On: I4341a1b4ff6a67e4c1770faae38e9b126f1bf0bf

includes/libs/rdbms/connectionmanager/ConnectionManager.php
includes/libs/rdbms/connectionmanager/SessionConsistentConnectionManager.php
tests/phpunit/includes/libs/rdbms/connectionmanager/SessionConsistentConnectionManagerTest.php

index 6d5d8ab..4f72f77 100644 (file)
@@ -138,43 +138,4 @@ class ConnectionManager {
                return $this->getConnectionRef( DB_REPLICA, $groups );
        }
 
                return $this->getConnectionRef( DB_REPLICA, $groups );
        }
 
-       /**
-        * Begins an atomic section and returns a database connection to the master DB, for updating.
-        *
-        * @since 1.29
-        *
-        * @param string $fname
-        *
-        * @return Database
-        */
-       public function beginAtomicSection( $fname ) {
-               $db = $this->getWriteConnection();
-               $db->startAtomic( $fname );
-
-               return $db;
-       }
-
-       /**
-        * @since 1.29
-        *
-        * @param IDatabase $db
-        * @param string $fname
-        */
-       public function commitAtomicSection( IDatabase $db, $fname ) {
-               $db->endAtomic( $fname );
-               $this->releaseConnection( $db );
-       }
-
-       /**
-        * @since 1.29
-        *
-        * @param IDatabase $db
-        * @param string $fname
-        */
-       public function rollbackAtomicSection( IDatabase $db, $fname ) {
-               // FIXME: there does not seem to be a clean way to roll back an atomic section?!
-               $db->rollback( $fname, 'flush' );
-               $this->releaseConnection( $db );
-       }
-
 }
 }
index 02972e5..e183823 100644 (file)
@@ -37,7 +37,6 @@ class SessionConsistentConnectionManager extends ConnectionManager {
        /**
         * Forces all future calls to getReadConnection() to return a write connection.
         * Use this before performing read operations that are critical for a future update.
        /**
         * Forces all future calls to getReadConnection() to return a write connection.
         * Use this before performing read operations that are critical for a future update.
-        * Calling beginAtomicSection() implies a call to prepareForUpdates().
         *
         * @since 1.29
         */
         *
         * @since 1.29
         */
@@ -95,24 +94,4 @@ class SessionConsistentConnectionManager extends ConnectionManager {
                return parent::getWriteConnectionRef();
        }
 
                return parent::getWriteConnectionRef();
        }
 
-       /**
-        * Begins an atomic section and returns a database connection to the master DB, for updating.
-        *
-        * @since 1.29
-        *
-        * @note: This causes all future calls to getReadConnection() to return a connection
-        * to the master DB, even after commitAtomicSection() or rollbackAtomicSection() have
-        * been called.
-        *
-        * @param string $fname
-        *
-        * @return Database
-        */
-       public function beginAtomicSection( $fname ) {
-               // Once we have written to master, do not read from replica.
-               $this->prepareForUpdates();
-
-               return parent::beginAtomicSection( $fname );
-       }
-
 }
 }
index 4dcab82..0d54659 100644 (file)
@@ -105,60 +105,4 @@ class SessionConsistentConnectionManagerTest extends \PHPUnit_Framework_TestCase
                $manager = new SessionConsistentConnectionManager( $lb );
                $manager->releaseConnection( $database );
        }
                $manager = new SessionConsistentConnectionManager( $lb );
                $manager->releaseConnection( $database );
        }
-
-       public function testBeginAtomicSection() {
-               $database = $this->getIDatabaseMock();
-               $lb = $this->getLoadBalancerMock();
-
-               $lb->expects( $this->exactly( 2 ) )
-                       ->method( 'getConnection' )
-                       ->with( DB_MASTER )
-                       ->will( $this->returnValue( $database ) );
-
-               $database->expects( $this->once() )
-                       ->method( 'startAtomic' )
-                       ->will( $this->returnValue( null ) );
-
-               $manager = new SessionConsistentConnectionManager( $lb );
-               $manager->beginAtomicSection( 'TEST' );
-
-               // Should also ask for a DB_MASTER connection.
-               // This is asserted by the $lb mock.
-               $manager->getReadConnection();
-       }
-
-       public function testCommitAtomicSection() {
-               $database = $this->getIDatabaseMock();
-               $lb = $this->getLoadBalancerMock();
-
-               $lb->expects( $this->once() )
-                       ->method( 'reuseConnection' )
-                       ->with( $database )
-                       ->will( $this->returnValue( null ) );
-
-               $database->expects( $this->once() )
-                       ->method( 'endAtomic' )
-                       ->will( $this->returnValue( null ) );
-
-               $manager = new SessionConsistentConnectionManager( $lb );
-               $manager->commitAtomicSection( $database, 'TEST' );
-       }
-
-       public function testRollbackAtomicSection() {
-               $database = $this->getIDatabaseMock();
-               $lb = $this->getLoadBalancerMock();
-
-               $lb->expects( $this->once() )
-                       ->method( 'reuseConnection' )
-                       ->with( $database )
-                       ->will( $this->returnValue( null ) );
-
-               $database->expects( $this->once() )
-                       ->method( 'rollback' )
-                       ->will( $this->returnValue( null ) );
-
-               $manager = new SessionConsistentConnectionManager( $lb );
-               $manager->rollbackAtomicSection( $database, 'TEST' );
-       }
-
 }
 }