immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
44.56k stars 2.17k forks source link

[BUG] PostgreSQL Version Incompatibility Post Upgrade from Immich 1.90.0 to 1.91.0 #5819

Closed eeezae closed 8 months ago

eeezae commented 8 months ago

The bug

I encountered a PostgreSQL version compatibility issue after attempting to upgrade Immich from version 1.90.0 to 1.91.0. Below are the details of the error message:

chmod: changing permissions of '/var/run/postgresql': Operation not permitted
PostgreSQL Database directory appears to contain a database; Skipping initialization
2023-12-18 16:47:51.537 CST [1] FATAL: database files are incompatible with server
2023-12-18 16:47:51.537 CST [1] DETAIL: The data directory was initialized by PostgreSQL version 16, which is not compatible with this version 14.10 (Debian 14.10-1.pgdg120+1).

This suggests that the current PostgreSQL data directory, which was initialized with PostgreSQL version 16, is not compatible with the version 14.10 that Immich is expecting to use post-upgrade.

Expected Behavior: The upgrade process should complete without critical errors, or there should be clear documentation on how to handle PostgreSQL version changes during the upgrade.

Actual Behavior: Received a fatal error stating that the database files are incompatible with the server due to different PostgreSQL versions.

I would greatly appreciate any assistance or guidance the development team can offer concerning this issue.

Thank you for your support.

The OS that Immich Server is running on

Synology 7.1

Version of Immich Server

v1.91.0

Version of Immich Mobile App

v1.91.0

Platform with the issue

Your docker-compose.yml content

version: "3.9"
services:
  immich-redis:
    image: redis
    container_name: Immich-REDIS
    hostname: immich_redis
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping || exit 1"]
    user: 1026:101
    environment:
      - TZ=Europe/Bucharest
    volumes:
      - /volume1/docker/immich/redis:/data
    restart: on-failure:5

  immich-db:
    image: tensorchord/pgvecto-rs:pg14-v0.1.11
    container_name: Immich-DB
    hostname: immich_postgres
    security_opt:
      - no-new-privileges:true
    user: 1026:101
    volumes:
      - ${DATABASE_LOCATION}:/var/lib/postgresql/data
    environment:
      - TZ=Europe/Bucharest
      - POSTGRES_DB=immich
      - POSTGRES_USER=immichuser
      - POSTGRES_PASSWORD=immichpw
    restart: on-failure:5

  immich-server:
    image: altran1502/immich-server:release
    command: ["start-server.sh"]
    container_name: Immich-SERVER
    hostname: immich-server
    user: 1026:101
    security_opt:
      - no-new-privileges:true
    env_file:
      - stack.env
    ports:
      - 2283:3001
    volumes:
      - /volume1/docker/immich/upload:/usr/src/app/upload
      - /volume1/homes:/volume1/homes:ro
    restart: on-failure:5
    depends_on:
      immich-redis:
        condition: service_healthy
      immich-db:
        condition: service_started

  immich-microservices:
    image: altran1502/immich-server:release
    command: ["start-microservices.sh"]
    container_name: Immich-MICROSERVICES
    hostname: immich-microservices
    user: 1026:101
    security_opt:
      - no-new-privileges:true
    env_file:
      - stack.env
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /volume1/docker/immich/micro:/usr/src/app/.reverse-geocoding-dump
      - /volume1/homes:/volume1/homes:ro
    restart: on-failure:5
    depends_on:
      immich-redis:
        condition: service_healthy
      immich-db:
        condition: service_started

  immich-machine-learning:
    image: altran1502/immich-machine-learning:release
    container_name: Immich-LEARNING
    hostname: immich-machine-learning
    user: 1026:101
    security_opt:
      - no-new-privileges:true
    env_file:
      - stack.env
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - ${CACHE_LOCATION}:/cache
    restart: on-failure:5
    depends_on:
      immich-db:
        condition: service_started

Your .env content

# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables
NODE_ENV=production
TZ=Asia/Shanghai

UPLOAD_LOCATION=/volume1/docker/immich/upload
CACHE_LOCATION=/volume1/docker/immich/cache
DATABASE_LOCATION=/volume1/docker/immich/db
REDIS_LOCATION=/volume1/docker/immich/redis
TYPESENSE_LOCATION=/volume1/docker/immich/typesense

IMMICH_VERSION=release

TYPESENSE_API_KEY=0ctlBmPcsGfFpKE9u9vbFZSq7ODptEVf
DB_PASSWORD=immichDB000

# The values below this line do not need to be changed
###################################################################################
DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

REDIS_HOSTNAME=immich_redis

Reproduction steps

1. Start with Immich installation at version 1.90.0.
2. Upgrade Immich to version 1.91.0.
3. Observe the error during the startup sequence.

Additional information

No response

bo0tzz commented 8 months ago

The default Immich setup uses postgres 14, and so the new database image does too as postgres doesn't support online upgrades. If you chose to use postgres 16 before then you should also use the appropriate pg16 tag here.