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
[Docker-Compose] [Breaking] Postgres 9.6 is EOL (11th Nov 2021) - Migrate to 14 Stable #16947
Conversation
Some error logs here, hope them help:
|
And maybe pg_dumpall can be better? docker-compose exec -e PGPASSWORD=password db pg_dumpall -U postgres > dump.sql
psql -U postgres -f dump.sql postgres |
Yeah. I think dumpall is the better way. |
This is safe to ignore during the import.
This is bad. please try again using my steps?
This is bad. please try again using my steps?
This is bad. please try again using my steps?
This is safe to ignore during the import. |
Thanks, I'll try it later and give you feedback. PS. I'm upgradeing from pg 12 to pg 14. Just found there is a pg_upgrade, maybe we can have a try. |
Thanks for your assistance. The steps as described as confirmed as migrating successfully on my instance.
I'm happy to test and confirm using pg_upgrade if others have problems - but I'm currently confident in the current process. |
Can these errors be ignored? DETAIL: Key (account_id)=(128124) is not present in table "accounts".
|
None of the toots or user accounts transferred over after merging the two databases |
I did the upgrade again and succeed without error this time. (Postgres 12 -> 14) This time I did vacuum operation before dumping data: docker-compose exec -e PGPASSWORD=password db vacuumdb -d postgres -U postgres -fzv |
@mashirozx Great to hear (TBH I have no idea why vacuum should fix your problem but I'll put a comment in it guide that a vacuum might be required). |
Using the command |
Finally got it working properly! Thanks for all the help! |
…1) - Migrate to 14 Stable (mastodon#16947)" This reverts commit ac8ad78.
…1) - Migrate to 14 Stable (mastodon#16947)" temporary rollback pg version This reverts commit ac8ad78.
…rate to 14 Stable (mastodon#16947) * Update docker-compose.yml * Update docker-compose.yml * Update docker-compose.yml * Update docker-compose.yml
* Update .dockerignore * Update .gitignore
Somehow the import of the old database does not work. I see no new line in
I am missing my data in the postgres db. But why? (My workaround is to get a bash in that container and do the import command there. But it's so strange that the docker-compose command does not work) Additionally i also get the following problem:
What is the solution to this? |
You just need to specify what user vacummdb needs to run under by adding a |
I'll add that as a note on the top. |
The docker-compose psql import did not for me. With the -T option, literally nothing happens, it returns instantly. Without it, the process goes for a while, makes a lot of noise on screen, and eventually hangs. In this case the docker-compose logs show some syntax errors even after running vacuumdb. What did work was running a bash prompt inside the container, as another user suggested. In case anyone else is struggling with the import after switching over to v3.5.x, this is what I did:
This is the most obnoxious and time-consuming that a Mastodon update has been for me in a while--would be nice if this migration could have been automated somehow, and maybe tested by more people. As usual what works for one person doesn't work for everyone. I was wondering if maybe it had to do with different docker-compose versions on different OS versions--my server is on Ubuntu 20.04. |
Sorry for issues you've faced. I'm glad you got there in the end.... There are multiple ways to do this migration and I just wanted to offer one that I believed was pretty close to standard... as you said, I cant test all environments. That said, I've added a second method closer to your solution to the bottom of the migration notes. |
Sorry for the terse tone last night, I was frustrated after a few hours of struggling. I do appreciate the effort you put in to document your own process. The whole reason I've stuck with the docker deployment for the life of my instance is because it seemed like less of a headache (avoiding breakage from the OS updating packages in particular). Obviously nothing can be done about it now, but I wonder if there's a way to improve these rare but painful upgrades in the future. I'd guess in general most of us docker deployments are the less experienced sysadmins. |
Luckily the Postgres 14 End-of-life is November 12, 2026.... so we have a while to hopefully get the next migration plans sorted out :) |
For what it's worth, I recently did an upgrade from 3.3.0 -> 3.5.1 including the PostgreSQL upgrade from 9.6 -> 14. I used the vacuum db approach described above. All went seemingly without errors, but I ended up with subtle errors on the data import (pre-migration) into pg14. The end result was that I lost all the posts prior to the upgrade (user accounts, etc. seemed fine). I've described the problem in more detail here: #18303 I still need to work out if it's possible for me to merge the missing posts (toots) back into the dataset somehow. Sigh. Anyone ever tried that or have any insight into whether it might work (and how)? |
Upgrade path using docker-compose
For safety, Old PostgreSQL 9.6 data is kept in
./postgres/
, and new PostgreSQL 14 data is stored in./postgres14/
.Rollback: This PR will allow for a recovery path for those having problems migrating to PostgreSQL 14. They can quickly roll back the docker-compose.yml to PostgreSQL 9.6. - While also working with a backup file to cleanly migrate on a fresh directory so no changes are made to the original DB in case of emergency. (postgres14 can be deleted to restart the import process if required)
Please keep the existing
postgres
folder incase you need to roll back - Delete it after the upgrade is completed.Part 1 - Backup DB from PostgreSQL 9.6
Part 2 - Import DB to PostgreSQL 14.x
Part 3 - Confirm import of DB has no serious errors
$
docker-compose logs db
and confirm there are not any errors in the import stage. Below is a list of known errors, and their resolution.Error 1
These errors are bad and need to be investigated.
Running
vacuumdb
has apparently resolved these issues. Please read the optional command as an alternative to step 1.Error 2
These errors can be ignored.
Error 3
These errors can be ignored. https://pganalyze.com/docs/log-insights/autovacuum/A60
Part 4 - Upgrade Mastodon
Alternative Step 1 - Vacuum DB before backup
We recommend completing the vacuum on your 9.6 DB before dumping the backup file.
UPDATE:
We're become aware of a rare issue with the postgres backup dump causing segfaults when restoring. If you experience this issue... Please try this or similar
Ref: https://stackoverflow.com/questions/63934856/why-is-pg-restore-segfaulting-in-docker