diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2024-10-07 14:09:06 -0700 |
---|---|---|
committer | Aaron Schulz <aschulz@wikimedia.org> | 2024-10-23 23:25:09 -0700 |
commit | 4e21d7e8cf9d558bc96ee85153cb8c02806cca7f (patch) | |
tree | 763cc8852ccfee810ec4853f86f6f245fc8b08a7 /maintenance/includes/TextPassDumper.php | |
parent | a92f3be5695cdb32a9e8acf191db73a0a8d75d9c (diff) | |
download | mediawikicore-4e21d7e8cf9d558bc96ee85153cb8c02806cca7f.tar.gz mediawikicore-4e21d7e8cf9d558bc96ee85153cb8c02806cca7f.zip |
Cleanup connection handling in BackupDumper/TextPassDumper
* Avoid use of LBFactory::newMain(), which does not appear to be
needed and breaks $wgSharedTables since the table aliases are
not set on the copy LoadBalancer.
* Remove rotateDb() and db/lb fields since nothing using $this->db
anymore. The DB handle used to be called for SELECT queries from
getText() before bb880f74b1cd3e.
Bug: T351615
Change-Id: Idbeb76e088c324979c894de45d3be650182ea132
Diffstat (limited to 'maintenance/includes/TextPassDumper.php')
-rw-r--r-- | maintenance/includes/TextPassDumper.php | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/maintenance/includes/TextPassDumper.php b/maintenance/includes/TextPassDumper.php index c0c26b064ba3..7fffc7f1a338 100644 --- a/maintenance/includes/TextPassDumper.php +++ b/maintenance/includes/TextPassDumper.php @@ -48,7 +48,6 @@ use MWUnknownContentModelException; use RuntimeException; use WikiExporter; use Wikimedia\AtEase\AtEase; -use Wikimedia\Rdbms\IMaintainableDatabase; use XmlDumpWriter; /** @@ -136,11 +135,6 @@ class TextPassDumper extends BackupDumper { protected $checkpointFiles = []; /** - * @var IMaintainableDatabase - */ - protected $db; - - /** * @param array|null $args For backward compatibility */ public function __construct( $args = null ) { @@ -240,56 +234,6 @@ TEXT } } - /** - * Drop the database connection $this->db and try to get a new one. - * - * This function tries to get a /different/ connection if this is - * possible. Hence, (if this is possible) it switches to a different - * failover upon each call. - * - * This function resets $this->lb and closes all connections on it. - * - * @suppress PhanTypeObjectUnsetDeclaredProperty - */ - protected function rotateDb() { - // Cleaning up old connections - if ( isset( $this->lb ) ) { - $this->lb->closeAll( __METHOD__ ); - unset( $this->lb ); - } - - if ( $this->forcedDb !== null ) { - $this->db = $this->forcedDb; - - return; - } - - if ( isset( $this->db ) && $this->db->isOpen() ) { - throw new RuntimeException( 'DB is set and has not been closed by the Load Balancer' ); - } - - unset( $this->db ); - - // Trying to set up new connection. - // We do /not/ retry upon failure, but delegate to encapsulating logic, to avoid - // individually retrying at different layers of code. - - try { - $lbFactory = $this->getServiceContainer()->getDBLoadBalancerFactory(); - $this->lb = $lbFactory->newMainLB(); - } catch ( Exception $e ) { - throw new RuntimeException( __METHOD__ - . " rotating DB failed to obtain new load balancer (" . $e->getMessage() . ")" ); - } - - try { - $this->db = $this->lb->getMaintenanceConnectionRef( DB_REPLICA, 'dump' ); - } catch ( Exception $e ) { - throw new RuntimeException( __METHOD__ - . " rotating DB failed to obtain new database (" . $e->getMessage() . ")" ); - } - } - public function initProgress( $history = WikiExporter::FULL ) { parent::initProgress(); $this->timeOfCheckpoint = $this->startTime; @@ -304,20 +248,6 @@ TEXT $this->initProgress( $this->history ); - // We are trying to get an initial database connection to avoid that the - // first try of this request's first call to getText fails. However, if - // obtaining a good DB connection fails it's not a serious issue, as - // getText does retry upon failure and can start without having a working - // DB connection. - try { - $this->rotateDb(); - } catch ( Exception $e ) { - // We do not even count this as failure. Just let eventual - // watchdogs know. - $this->progress( "Getting initial DB connection failed (" . - $e->getMessage() . ")" ); - } - $this->egress = new ExportProgressFilter( $this->sink, $this ); // it would be nice to do it in the constructor, oh well. need egress set @@ -718,7 +648,6 @@ TEXT // parts sleep( $this->failureTimeout ); try { - $this->rotateDb(); if ( $this->spawn ) { $this->closeSpawn(); $this->openSpawn(); |