Skip to content

Commit adc214e

Browse files
committed
Log count and names of temp tablespaces
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
1 parent 8a6a7b7 commit adc214e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

single_kernel_postgresql/utils/postgresql.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,17 @@ def set_up_database(self, temp_location: Optional[str] = None) -> None:
10891089
new_name = f"temp_{datetime.now(timezone.utc).strftime('%Y%m%d%H%M%S')}"
10901090
cursor.execute(f"ALTER TABLESPACE temp RENAME TO {new_name};")
10911091

1092+
# List temp tablespaces with suffix for operator follow-up cleanup and log them.
1093+
cursor.execute(
1094+
"SELECT spcname FROM pg_tablespace WHERE spcname LIKE 'temp_%';"
1095+
)
1096+
temp_tbls = sorted([row[0] for row in cursor.fetchall()])
1097+
logger.info(
1098+
"There are %d temp tablespaces that should be checked and removed: %s",
1099+
len(temp_tbls),
1100+
", ".join(temp_tbls),
1101+
)
1102+
10921103
# Ensure a fresh temp tablespace exists at the expected location.
10931104
cursor.execute("SELECT TRUE FROM pg_tablespace WHERE spcname='temp';")
10941105
if cursor.fetchone() is None:

0 commit comments

Comments
 (0)