Upgrade to postgres 15. (#2659)

ci-enable-arm-tests
Dessalines 2023-01-20 12:15:07 -05:00 committed by GitHub
parent b5d45fa826
commit ac56504291
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 15 deletions

View File

@ -86,10 +86,36 @@ services:
restart: always restart: always
postgres: postgres:
image: postgres:14-alpine image: postgres:15-alpine
# this needs to match the database host in lemmy.hson # this needs to match the database host in lemmy.hson
# Tune your settings via
# https://pgtune.leopard.in.ua/#/
# You can use this technique to add them here
# https://stackoverflow.com/a/30850095/1655478
hostname: postgres hostname: postgres
command: ["postgres", "-c", "session_preload_libraries=auto_explain", "-c", "auto_explain.log_min_duration=5ms", "-c", "auto_explain.log_analyze=true"] command: [
"postgres",
"-c", "session_preload_libraries=auto_explain",
"-c", "auto_explain.log_min_duration=5ms",
"-c", "auto_explain.log_analyze=true"
# Tuning config
# "-c", "max_connections=200",
# "-c", "shared_buffers=3GB",
# "-c", "effective_cache_size=9GB",
# "-c", "maintenance_work_mem=768MB",
# "-c", "checkpoint_completion_target=0.9",
# "-c", "wal_buffers=16MB",
# "-c", "default_statistics_target=100",
# "-c", "random_page_cost=4",
# "-c", "effective_io_concurrency=2",
# "-c", "work_mem=7864kB",
# "-c", "min_wal_size=1GB",
# "-c", "max_wal_size=4GB",
# "-c", "max_worker_processes=4",
# "-c", "max_parallel_workers_per_gather=2",
# "-c", "max_parallel_workers=4",
# "-c", "max_parallel_maintenance_workers=2",
]
networks: networks:
- lemmyinternal - lemmyinternal
# adding the external facing network to allow direct db access for devs # adding the external facing network to allow direct db access for devs

View File

@ -47,7 +47,7 @@ services:
ports: ports:
- "8541:8541" - "8541:8541"
postgres_alpha: postgres_alpha:
image: postgres:14-alpine image: postgres:15-alpine
environment: environment:
- POSTGRES_USER=lemmy - POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password - POSTGRES_PASSWORD=password
@ -75,7 +75,7 @@ services:
ports: ports:
- "8551:8551" - "8551:8551"
postgres_beta: postgres_beta:
image: postgres:14-alpine image: postgres:15-alpine
environment: environment:
- POSTGRES_USER=lemmy - POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password - POSTGRES_PASSWORD=password
@ -103,7 +103,7 @@ services:
ports: ports:
- "8561:8561" - "8561:8561"
postgres_gamma: postgres_gamma:
image: postgres:14-alpine image: postgres:15-alpine
environment: environment:
- POSTGRES_USER=lemmy - POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password - POSTGRES_PASSWORD=password
@ -132,7 +132,7 @@ services:
ports: ports:
- "8571:8571" - "8571:8571"
postgres_delta: postgres_delta:
image: postgres:14-alpine image: postgres:15-alpine
environment: environment:
- POSTGRES_USER=lemmy - POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password - POSTGRES_PASSWORD=password
@ -161,7 +161,7 @@ services:
ports: ports:
- "8581:8581" - "8581:8581"
postgres_epsilon: postgres_epsilon:
image: postgres:14-alpine image: postgres:15-alpine
environment: environment:
- POSTGRES_USER=lemmy - POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password - POSTGRES_PASSWORD=password

View File

@ -72,7 +72,7 @@ services:
restart: always restart: always
postgres: postgres:
image: postgres:14-alpine image: postgres:15-alpine
# this needs to match the database host in lemmy.hson # this needs to match the database host in lemmy.hson
hostname: postgres hostname: postgres
networks: networks:

View File

@ -3,12 +3,15 @@ set -e
echo "Do not stop in the middle of this upgrade, wait until you see the message: Upgrade complete." echo "Do not stop in the middle of this upgrade, wait until you see the message: Upgrade complete."
echo "Stopping lemmy and all services..."
sudo docker-compose stop
echo "Make sure postgres is started..." echo "Make sure postgres is started..."
sudo docker-compose up -d postgres sudo docker-compose up -d postgres
sleep 20s sleep 20s
echo "Exporting the Database to 12_14.dump.sql ..." echo "Exporting the Database to 12_15.dump.sql ..."
sudo docker-compose exec -T postgres pg_dumpall -c -U lemmy > 12_14_dump.sql sudo docker-compose exec -T postgres pg_dumpall -c -U lemmy > 12_15_dump.sql
echo "Done." echo "Done."
echo "Stopping postgres..." echo "Stopping postgres..."
@ -18,20 +21,20 @@ sleep 20s
echo "Removing the old postgres folder" echo "Removing the old postgres folder"
sudo rm -rf volumes/postgres sudo rm -rf volumes/postgres
echo "Updating docker-compose to use postgres version 14." echo "Updating docker-compose to use postgres version 15."
sed -i "s/postgres:12-alpine/postgres:14-alpine/" ./docker-compose.yml sed -i "s/image: postgres:.*/image: postgres:15-alpine/" ./docker-compose.yml
echo "Starting up new postgres..." echo "Starting up new postgres..."
sudo docker-compose up -d postgres sudo docker-compose up -d postgres
sleep 20s sleep 20s
echo "Importing the database...." echo "Importing the database...."
cat 12_14_dump.sql | sudo docker-compose exec -T postgres psql -U lemmy cat 12_15_dump.sql | sudo docker-compose exec -T postgres psql -U lemmy
echo "Done." echo "Done."
POSTGRES_PASSWORD=$(grep "POSTGRES_PASSWORD" ./docker-compose.yml | cut -d"=" -f2) POSTGRES_PASSWORD=$(grep "POSTGRES_PASSWORD" ./docker-compose.yml | cut -d"=" -f2)
echo "Fixing a weird password issue with postgres 14" echo "Fixing a weird password issue with postgres 15"
sudo docker-compose exec -T postgres psql -U lemmy -c "alter user lemmy with password '$POSTGRES_PASSWORD'" sudo docker-compose exec -T postgres psql -U lemmy -c "alter user lemmy with password '$POSTGRES_PASSWORD'"
sudo docker-compose restart postgres sudo docker-compose restart postgres
@ -41,5 +44,5 @@ sudo chown -R 991:991 volumes/pictrs
echo "Starting up lemmy..." echo "Starting up lemmy..."
sudo docker-compose up -d sudo docker-compose up -d
echo "A copy of your old database is at 12_14.dump.sql . You can delete this file if the upgrade went smoothly." echo "A copy of your old database is at 12_15.dump.sql . You can delete this file if the upgrade went smoothly."
echo "Upgrade complete." echo "Upgrade complete."