Skip to content

fix(postgresql_ext): Reconnect before upgrade#689

Merged
Andersson007 merged 1 commit intoansible-collections:mainfrom
jouir:timescaledb
May 13, 2024
Merged

fix(postgresql_ext): Reconnect before upgrade#689
Andersson007 merged 1 commit intoansible-collections:mainfrom
jouir:timescaledb

Conversation

@jouir
Copy link

@jouir jouir commented Apr 26, 2024

SUMMARY

The TimescaleDB extension needs a fresh connection at upgrade because the extension might be accidentally loaded. The upgrade procedure recommends using the -X flag of psql to ignore .psqlrc file that might execute some queries and load the extension.

This commit reconnects before performing the extension upgrade to fix the following error:

Traceback (most recent call last):
  File "/tmp/ansible_community.postgresql.postgresql_ext_payload_yi1aki7a/ansible_community.postgresql.postgresql_ext_payload.zip/ansible_collections/community/postgresql/plugins/modules/postgresql_ext.py", line 428, in main
  File "/tmp/ansible_community.postgresql.postgresql_ext_payload_yi1aki7a/ansible_community.postgresql.postgresql_ext_payload.zip/ansible_collections/community/postgresql/plugins/modules/postgresql_ext.py", line 246, in ext_update_version
  File "/usr/lib/python3/dist-packages/psycopg2/extras.py", line 146, in execute
    return super().execute(query, vars)
psycopg2.errors.FeatureNotSupported: extension "timescaledb" cannot be updated after the old version has already been loaded
HINT:  Start a new session and execute ALTER EXTENSION as the first command. Make sure to pass the "-X" flag to psql.
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

postgresql_ext

@Andersson007
Copy link
Collaborator

@jouir hello, thanks for the pull request! Could you please add a changelog fragment (under bugfixes:, i think)

Copy link
Collaborator

@hunleyd hunleyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, will approve w/ a changelog fragment

@Andersson007
Copy link
Collaborator

@jouir any updates on ^ ?

@jouir
Copy link
Author

jouir commented May 2, 2024 via email

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 <julien@riou.xyz>
@jouir
Copy link
Author

jouir commented May 10, 2024

I've added the changelog fragment as requested.

@hunleyd hunleyd self-requested a review May 10, 2024 12:00
@Andersson007 Andersson007 merged commit 7fa0c4a into ansible-collections:main May 13, 2024
@ansible-collections ansible-collections deleted a comment from patchback bot May 13, 2024
@Andersson007
Copy link
Collaborator

@jouir thanks for the contribution! @hunleyd thanks for reviewing!

@jouir could you please backport the changes to stable-2 ? <- the process in the guide is about ansible-core but what you need is to replace devel with main branch in your mind when applying it.

@jouir jouir deleted the timescaledb branch May 13, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants