Merge "Use LB server configuration to force DB domains in ExternalStorageDB"
[lhc/web/wiklou.git] / includes / libs / rdbms / loadbalancer / ILoadBalancer.php
index 04a553c..9f7d050 100644 (file)
@@ -86,8 +86,6 @@ interface ILoadBalancer {
 
        /** @var int DB handle should have DBO_TRX disabled and the caller will leave it as such */
        const CONN_TRX_AUTOCOMMIT = 1;
-       /** @var int Alias for CONN_TRX_AUTOCOMMIT for b/c; deprecated since 1.31 */
-       const CONN_TRX_AUTO = 1;
 
        /** @var string Manager of ILoadBalancer instances is running post-commit callbacks */
        const STAGE_POSTCOMMIT_CALLBACKS = 'stage-postcommit-callbacks';
@@ -122,6 +120,22 @@ interface ILoadBalancer {
         */
        public function __construct( array $params );
 
+       /**
+        * Get the local (and default) database domain ID of connection handles
+        *
+        * @see DatabaseDomain
+        * @return string Database domain ID; this specifies DB name, schema, and table prefix
+        * @since 1.31
+        */
+       public function getLocalDomainID();
+
+       /**
+        * @param DatabaseDomain|string|bool $domain Database domain
+        * @return string Value of $domain if provided or the local domain otherwise
+        * @since 1.32
+        */
+       public function resolveDomainID( $domain );
+
        /**
         * Get the index of the reader connection, which may be a replica DB
         *
@@ -156,7 +170,7 @@ interface ILoadBalancer {
         * This can be used a faster proxy for waitForAll()
         *
         * @param DBMasterPos|bool $pos Master position or false
-        * @param int $timeout Max seconds to wait; default is mWaitTimeout
+        * @param int|null $timeout Max seconds to wait; default is mWaitTimeout
         * @return bool Success (able to connect and no timeouts reached)
         */
        public function waitForOne( $pos, $timeout = null );
@@ -165,7 +179,7 @@ interface ILoadBalancer {
         * Set the master wait position and wait for ALL replica DBs to catch up to it
         *
         * @param DBMasterPos|bool $pos Master position or false
-        * @param int $timeout Max seconds to wait; default is mWaitTimeout
+        * @param int|null $timeout Max seconds to wait; default is mWaitTimeout
         * @return bool Success (able to connect and no timeouts reached)
         */
        public function waitForAll( $pos, $timeout = null );
@@ -173,7 +187,8 @@ interface ILoadBalancer {
        /**
         * Get any open connection to a given server index, local or foreign
         *
-        * Use CONN_TRX_AUTOCOMMIT to only look for connections opened with that flag
+        * Use CONN_TRX_AUTOCOMMIT to only look for connections opened with that flag.
+        * Avoid the use of begin() or startAtomic() on any such connections.
         *
         * @param int $i Server index or DB_MASTER/DB_REPLICA
         * @param int $flags Bitfield of CONN_* class constants
@@ -188,9 +203,10 @@ interface ILoadBalancer {
         * (e.g. sqlite) in order to avoid deadlocks. ILoadBalancer::getServerAttributes()
         * can be used to check such flags beforehand.
         *
-        * If the caller uses $domain or sets CONN_TRX_AUTOCOMMIT in $flags, then it must also
-        * call ILoadBalancer::reuseConnection() on the handle when finished using it.
+        * If the caller uses $domain or sets CONN_TRX_AUTOCOMMIT in $flags, then it must
+        * also call ILoadBalancer::reuseConnection() on the handle when finished using it.
         * In all other cases, this is not necessary, though not harmful either.
+        * Avoid the use of begin() or startAtomic() on any such connections.
         *
         * @param int $i Server index (overrides $groups) or DB_MASTER/DB_REPLICA
         * @param array|string|bool $groups Query group(s), or false for the generic reader
@@ -222,7 +238,8 @@ interface ILoadBalancer {
         *
         * The CONN_TRX_AUTOCOMMIT flag is ignored for databases with ATTR_DB_LEVEL_LOCKING
         * (e.g. sqlite) in order to avoid deadlocks. ILoadBalancer::getServerAttributes()
-        * can be used to check such flags beforehand.
+        * can be used to check such flags beforehand. Avoid the use of begin() or startAtomic()
+        * on any CONN_TRX_AUTOCOMMIT connections.
         *
         * @see ILoadBalancer::getConnection() for parameter information
         *
@@ -241,7 +258,8 @@ interface ILoadBalancer {
         *
         * The CONN_TRX_AUTOCOMMIT flag is ignored for databases with ATTR_DB_LEVEL_LOCKING
         * (e.g. sqlite) in order to avoid deadlocks. ILoadBalancer::getServerAttributes()
-        * can be used to check such flags beforehand.
+        * can be used to check such flags beforehand. Avoid the use of begin() or startAtomic()
+        * on any CONN_TRX_AUTOCOMMIT connections.
         *
         * @see ILoadBalancer::getConnection() for parameter information
         *
@@ -260,7 +278,8 @@ interface ILoadBalancer {
         *
         * The CONN_TRX_AUTOCOMMIT flag is ignored for databases with ATTR_DB_LEVEL_LOCKING
         * (e.g. sqlite) in order to avoid deadlocks. ILoadBalancer::getServerAttributes()
-        * can be used to check such flags beforehand.
+        * can be used to check such flags beforehand. Avoid the use of begin() or startAtomic()
+        * on any CONN_TRX_AUTOCOMMIT connections.
         *
         * @see ILoadBalancer::getConnection() for parameter information
         *
@@ -278,13 +297,14 @@ interface ILoadBalancer {
         * The index must be an actual index into the array. If a connection to the server is
         * already open and not considered an "in use" foreign connection, this simply returns it.
         *
-        * Avoid using CONN_TRX_AUTOCOMMIT for databases with ATTR_DB_LEVEL_LOCKING (e.g. sqlite) in
-        * order to avoid deadlocks. ILoadBalancer::getServerAttributes() can be used to check
+        * Avoid using CONN_TRX_AUTOCOMMIT for databases with ATTR_DB_LEVEL_LOCKING (e.g. sqlite)
+        * in order to avoid deadlocks. ILoadBalancer::getServerAttributes() can be used to check
         * such flags beforehand.
         *
-        * If the caller uses $domain or sets CONN_TRX_AUTOCOMMIT in $flags, then it must also
-        * call ILoadBalancer::reuseConnection() on the handle when finished using it.
+        * If the caller uses $domain or sets CONN_TRX_AUTOCOMMIT in $flags, then it must
+        * also call ILoadBalancer::reuseConnection() on the handle when finished using it.
         * In all other cases, this is not necessary, though not harmful either.
+        * Avoid the use of begin() or startAtomic() on any such connections.
         *
         * @note This method throws DBAccessError if ILoadBalancer::disable() was called
         *
@@ -336,6 +356,7 @@ interface ILoadBalancer {
         * Return the server info structure for a given index, or false if the index is invalid.
         * @param int $i
         * @return array|bool
+        * @since 1.31
         */
        public function getServerInfo( $i );
 
@@ -488,7 +509,7 @@ interface ILoadBalancer {
         * Check if this load balancer object had any recent or still
         * pending writes issued against it by this PHP thread
         *
-        * @param float $age How many seconds ago is "recent" [defaults to mWaitTimeout]
+        * @param float|null $age How many seconds ago is "recent" [defaults to mWaitTimeout]
         * @return bool
         */
        public function hasOrMadeRecentMasterChanges( $age = null );