Skip to content

Commit

Permalink
Add some debug information to _pg_ensure_database_not_connected
Browse files Browse the repository at this point in the history
When in dev/test mode, dump out all the info about the other
connections.  Hopefully this will let us figure out where they are
coming from.

See also #7904
  • Loading branch information
msullivan committed Oct 22, 2024
1 parent a131a2b commit 5519718
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions edb/server/tenant.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ async def _pg_ensure_database_not_connected(self, dbname: str) -> None:
conns = await pgcon.sql_fetch_col(
b"""
SELECT
pid
row_to_json(pg_stat_activity)
FROM
pg_stat_activity
WHERE
Expand All @@ -1003,8 +1003,14 @@ async def _pg_ensure_database_not_connected(self, dbname: str) -> None:
)

if conns:
debug_info = ""
if self.server.in_dev_mode() or self.server.in_test_mode():
jconns = [json.loads(conn) for conn in conns]
debug_info = ": " + json.dumps(jconns)

raise errors.ExecutionError(
f"database branch {dbname!r} is being accessed by other users"
f"database branch {dbname!r} is being accessed by "
f"other users{debug_info}"
)

@contextlib.asynccontextmanager
Expand Down

0 comments on commit 5519718

Please sign in to comment.