Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pgbelt] Refactor Teardown Command due to DROP EXTENSION wOES #321

Closed
wants to merge 12 commits into from
9 changes: 4 additions & 5 deletions pgbelt/cmd/teardown.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])


Expand Down
4 changes: 3 additions & 1 deletion pgbelt/config/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions pgbelt/util/pglogical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand All @@ -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:
"""
Expand Down
1 change: 0 additions & 1 deletion pgbelt/util/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down