Skip to content

Commit 7fa0c4a

Browse files
author
Julien Riou
authored
fix(postgresql_ext): Reconnect before upgrade (#689)
Some extensions like timescaledb need a fresh connection to be upgraded. See https://docs.timescale.com/self-hosted/latest/upgrades/minor-upgrade/. Signed-off-by: Julien Riou <[email protected]>
1 parent 09fec84 commit 7fa0c4a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bugfixes:
2+
- postgresql_ext - Reconnect before upgrade to avoid accidental load of the upgraded extension
3+
(https://github.com/ansible-collections/community.postgresql/pull/689).

plugins/modules/postgresql_ext.py

+5
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,11 @@ def main():
469469
else:
470470
valid_update_path = ext_valid_update_path(cursor, ext, curr_version, real_version)
471471
if valid_update_path:
472+
# Reconnect (required by some extensions like timescaledb)
473+
if not module.check_mode:
474+
db_connection.close()
475+
db_connection, dummy = connect_to_db(module, conn_params, autocommit=True)
476+
cursor = db_connection.cursor(**pg_cursor_args)
472477
changed = ext_update_version(module.check_mode, cursor, ext, version)
473478
else:
474479
if version == 'latest':

0 commit comments

Comments
 (0)