diff --git a/src/main.py b/src/main.py index 99103e3..8ff21ef 100644 --- a/src/main.py +++ b/src/main.py @@ -120,7 +120,8 @@ def startup_checks(self): sys.exit(1) if self.db.is_alive() and not self.zk.is_alive(): - if self.db.role == 'primary' and self.db.pgpooler('status')[1]: + _, pooler_service_running = self.db.pgpooler('status') + if self.db.role == 'primary' and pooler_service_running: self.db.pgpooler('stop') if not self.db.is_alive() and self.zk.is_alive(): @@ -340,12 +341,12 @@ def single_node_primary_iter(self, db_state, zk_state): self.zk.write(self.zk.TIMELINE_INFO_PATH, db_state['timeline']) - pooler_status, pooler_service_status = self.db.pgpooler('status') - if pooler_service_status and not pooler_status: + pooler_port_available, pooler_service_running = self.db.pgpooler('status') + if pooler_service_running and not pooler_port_available: logging.warning('Service alive, but pooler not accepting connections, restarting.') self.db.pgpooler('stop') self.db.pgpooler('start') - elif not pooler_service_status: + elif not pooler_service_running: logging.debug('Here we should open for load.') self.db.pgpooler('start') @@ -417,12 +418,12 @@ def primary_iter(self, db_state, zk_state): self._drop_stale_switchover(db_state) - pooler_status, pooler_service_status = self.db.pgpooler('status') - if pooler_service_status and not pooler_status: + pooler_port_available, pooler_service_running = self.db.pgpooler('status') + if pooler_service_running and not pooler_port_available: logging.warning('Service alive, but pooler not accepting connections, restarting.') self.db.pgpooler('stop') self.db.pgpooler('start') - elif not pooler_service_status: + elif not pooler_service_running: logging.debug('Here we should open for load.') self.db.pgpooler('start') @@ -549,7 +550,8 @@ def remove_stale_operation(self, hostname): def start_pooler(self): start_pooler = self.config.getboolean('replica', 'start_pooler') - if not self.db.pgpooler('status')[1] and start_pooler: + _, pooler_service_running = self.db.pgpooler('status') + if not pooler_service_running and start_pooler: self.db.pgpooler('start') def get_replics_info(self, zk_state):