Currently, foreign and local domain connections always use different handles. Also, the foreign connection logic does not support reuse of handles while one is already in use, e.g.:
$cMain = $lb->getConnection( DB_MASTER ); // some queries $conn1 = $lb->getConnection( DB_MASTER, [], 'x' ); // some queries $conn2 = $lb->getConnection( DB_MASTER, [], 'y' ); // some queries $lb->reuseConnection( $conn1 ); // some queries $lb->reuseConnection( $conn2 );
...will acquire three connections. If everything used connection references, and those DBConnRef instance checked and corrected the domain in each proxy method (implementing IDatabase), then the above scenario could just use a single connection and one atomic transaction. E.g.:
$cMain = $lb->getConnectionRef( DB_MASTER ); // some queries $conn1 = $lb->getConnectionRef( DB_MASTER, [], 'x' ); // some queries $conn2 = $lb->getConnectionRef( DB_MASTER, [], 'y' ); // some queries // $conn2 falls out of scope // some queries // $conn1 falls out of scope // $cMain falls out of scope
Connections acquired by raw getConnection() calls would still use a separate pool for backwards compatibility (no sudden domain changes from DBConnRef instances proxying them).