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

chore: Update base postgres to version 15 #17159

Merged
merged 4 commits into from
Sep 13, 2023
Merged

Conversation

danielxnj
Copy link
Contributor

Problem

POstgres 12 is an old version and will lose support on AWS, so we are upgrading to pg 15.

Changes

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

How did you test this code?

@danielxnj danielxnj requested review from a team August 23, 2023 14:19
@xvello
Copy link
Contributor

xvello commented Aug 23, 2023

We do need to land this before upgrading cloud, but this will require a manual call to pg_upgrade for both the devenv and the hobby deploy, that we do need to document. Right now, the posthog-db-1 container is failing with:

2023-08-23 14:30:25.062 UTC [1] FATAL: database files are incompatible with server
2023-08-23 14:30:25.062 UTC [1] DETAIL: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 15.4.

There are third-party postgres images that do automatically run pg_upgrade, but I'm not sure we want to go there.

@danielxnj
Copy link
Contributor Author

2023-08-23 14:30:25.062 UTC [1] FATAL: database files are incompatible with server
2023-08-23 14:30:25.062 UTC [1] DETAIL: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 15.4.

This is getting really hard i have tried different approaches and the issue is that for the pg_upgrade we need both pg12 and pg15 binaries, and the alpine image does not let me have both versions.

Is this something we need to support and can people recreate the hobby deployment again?

cc @ellie @frankh

@danielxnj
Copy link
Contributor Author

2023-08-23 14:30:25.062 UTC [1] FATAL: database files are incompatible with server
2023-08-23 14:30:25.062 UTC [1] DETAIL: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 15.4.

This is getting really hard i have tried different approaches and the issue is that for the pg_upgrade we need both pg12 and pg15 binaries, and the alpine image does not let me have both versions.

Is this something we need to support and can people recreate the hobby deployment again?

cc @ellie @frankh

Another option is to have two containers running one for pg12 and another for pg15 and do the upgrade and switch the volumes, if is worth having this process i can try it tomorrow.

@xvello
Copy link
Contributor

xvello commented Aug 25, 2023

We could move forward for now by overriding the image in docker-compose.hobby.yml to pin hobby to 12 while we figure it out, but still run our tests on 15.

One low-effort way forward would be to switch to using the pgautoupgrade image that's a drop-in replacement image that runs pg_upgrade if needed. Running with pgautoupgrade/pgautoupgrade:15-alpine3.8 for the db container got me a smooth upgrade path on a local devenv.

Ideally we could run it once in the upgrade-hobby script, or add a warning to run it manually with a one-liner example. cc @fuziontech as the person with the most context on the hobby deploy and the upgrade script.

@danielxnj
Copy link
Contributor Author

We could move forward for now by overriding the image in docker-compose.hobby.yml to pin hobby to 12 while we figure it out, but still run our tests on 15.

One low-effort way forward would be to switch to using the pgautoupgrade image that's a drop-in replacement image that runs pg_upgrade if needed. Running with pgautoupgrade/pgautoupgrade:15-alpine3.8 for the db container got me a smooth upgrade path on a local devenv.

Ideally we could run it once in the upgrade-hobby script, or add a warning to run it manually with a one-liner example. cc @fuziontech as the person with the most context on the hobby deploy and the upgrade script.

I have pinned pg12 for the hobby deployment, please let me know how it looks for you.

@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

docker-compose.hobby.yml Outdated Show resolved Hide resolved
@posthog-bot posthog-bot removed the stale label Sep 5, 2023
@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@danielxnj danielxnj merged commit 2e1a48b into master Sep 13, 2023
@danielxnj danielxnj deleted the danielj-upgrade-pg-15 branch September 13, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants