diff --git a/pgbelt/cmd/teardown.py b/pgbelt/cmd/teardown.py index 29115d6..4a3aacb 100644 --- a/pgbelt/cmd/teardown.py +++ b/pgbelt/cmd/teardown.py @@ -83,16 +83,15 @@ async def teardown( if full: await sleep(15) - await gather( - revoke_pgl(src_root_pool, conf.tables, src_logger), - revoke_pgl(dst_root_pool, conf.tables, dst_logger), - ) - await gather( teardown_pgl(src_root_pool, src_logger), teardown_pgl(dst_root_pool, dst_logger), ) finally: + await gather( + revoke_pgl(src_root_pool, conf.tables, src_logger), + revoke_pgl(dst_root_pool, conf.tables, dst_logger), + ) await gather(*[p.close() for p in pools]) diff --git a/pgbelt/config/remote.py b/pgbelt/config/remote.py index d3f76f9..45b030d 100644 --- a/pgbelt/config/remote.py +++ b/pgbelt/config/remote.py @@ -154,7 +154,9 @@ async def resolve_remote_config( ) return None except RemoteConfigError as e: - logger.error(f"Failed to resolve remote configuration for {db} {dc}. RemoteConfigError {e}") + logger.error( + f"Failed to resolve remote configuration for {db} {dc}. RemoteConfigError {e}" + ) return None except ValidationError: logger.error( diff --git a/pgbelt/util/pglogical.py b/pgbelt/util/pglogical.py index 9734221..1431bbf 100644 --- a/pgbelt/util/pglogical.py +++ b/pgbelt/util/pglogical.py @@ -233,6 +233,12 @@ async def revoke_pgl(pool: Pool, tables: list[str], logger: Logger) -> None: else: raise e + logger.info("Dropping pglogical user...") + async with pool.acquire() as conn: + async with conn.transaction(): + await conn.execute("DROP ROLE IF EXISTS pglogical;") + logger.debug("Pglogical user dropped") + async def teardown_pgl(pool: Pool, logger: Logger) -> None: """ @@ -244,12 +250,6 @@ async def teardown_pgl(pool: Pool, logger: Logger) -> None: await conn.execute("DROP EXTENSION IF EXISTS pglogical;") logger.debug("Pglogical extension dropped") - logger.info("Dropping pglogical user...") - async with pool.acquire() as conn: - async with conn.transaction(): - await conn.execute("DROP ROLE IF EXISTS pglogical;") - logger.debug("Pglogical user dropped") - async def subscription_status(pool: Pool, logger: Logger) -> str: """ diff --git a/pgbelt/util/postgres.py b/pgbelt/util/postgres.py index 1531788..3ec5c84 100644 --- a/pgbelt/util/postgres.py +++ b/pgbelt/util/postgres.py @@ -74,7 +74,6 @@ async def compare_data( await dst_pool.execute("SET extra_float_digits TO 0;") for table in set(pkeys): - # If specific table list is defined and iterated table is not in that list, skip. if tables and (table not in tables): continue