immich-app / immich

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

Errors after Upgrading to 1.94.1 and running MetaData Extraction for Samsung Live Photos #6829

Closed deiop closed 9 months ago

deiop commented 9 months ago

The bug

on example log extraction:

immich_microservices | [Nest] 7 - 02/01/2024, 8:18:51 AM LOG [MetadataService] Removed old motion photo video asset (981df849-9b5d-43c4-8e0f-7da9276a11a5) immich_microservices | [Nest] 7 - 02/01/2024, 8:18:51 AM LOG [MetadataService] Removed old motion photo video asset (981df849-9b5d-43c4-8e0f-7da9276a11a5) immich_microservices | [Nest] 7 - 02/01/2024, 8:18:52 AM LOG [MetadataService] Removed old motion photo video asset (5b32fc7b-191a-429b-9fc7-9df335a3da44) immich_microservices | [Nest] 7 - 02/01/2024, 8:18:52 AM LOG [MetadataService] Removed old motion photo video asset (5b32fc7b-191a-429b-9fc7-9df335a3da44) immich_microservices | [Nest] 7 - 02/01/2024, 8:18:52 AM LOG [MetadataService] Removed old motion photo video asset (29291517-abbc-4c45-a67a-a5589b65efe9) immich_microservices | [Nest] 7 - 02/01/2024, 8:18:52 AM LOG [MetadataService] Removed old motion photo video asset (29291517-abbc-4c45-a67a-a5589b65efe9) immich_postgres | 2024-02-01 08:18:52.482 UTC [524] ERROR: insert or update on table "exif" violates foreign key constraint "FK_c0117fdbc50b917ef9067740c44" immich_postgres | 2024-02-01 08:18:52.482 UTC [524] DETAIL: Key (assetId)=(29291517-abbc-4c45-a67a-a5589b65efe9) is not present in table "assets". immich_postgres | 2024-02-01 08:18:52.482 UTC [524] STATEMENT: INSERT INTO "exif"("assetId", "description", "exifImageWidth", "exifImageHeight", "fileSizeInByte", "orientation", "dateTimeOriginal", "modifyDate", "timeZone", "latitude", "longitude", "projectionType", "city", "livePhotoCID", "autoStackId", "state", "country", "make", "model", "lensModel", "fNumber", "focalLength", "iso", "exposureTime", "profileDescription", "colorspace", "bitsPerSample", "fps", "exifTextSearchableColumn") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, DEFAULT) ON CONFLICT ( "assetId" ) DO UPDATE SET "assetId" = EXCLUDED."assetId", "description" = EXCLUDED."description", "exifImageWidth" = EXCLUDED."exifImageWidth", "exifImageHeight" = EXCLUDED."exifImageHeight", "fileSizeInByte" = EXCLUDED."fileSizeInByte", "orientation" = EXCLUDED."orientation", "dateTimeOriginal" = EXCLUDED."dateTimeOriginal", "modifyDate" = EXCLUDED."modifyDate", "timeZone" = EXCLUDED."timeZone", "latitude" = EXCLUDED."latitude", "longitude" = EXCLUDED."longitude", "projectionType" = EXCLUDED."projectionType", "city" = EXCLUDED."city", "livePhotoCID" = EXCLUDED."livePhotoCID", "autoStackId" = EXCLUDED."autoStackId", "state" = EXCLUDED."state", "country" = EXCLUDED."country", "make" = EXCLUDED."make", "model" = EXCLUDED."model", "lensModel" = EXCLUDED."lensModel", "fNumber" = EXCLUDED."fNumber", "focalLength" = EXCLUDED."focalLength", "iso" = EXCLUDED."iso", "exposureTime" = EXCLUDED."exposureTime", "profileDescription" = EXCLUDED."profileDescription", "colorspace" = EXCLUDED."colorspace", "bitsPerSample" = EXCLUDED."bitsPerSample", "fps" = EXCLUDED."fps" RETURNING "description" immich_microservices | [Nest] 7 - 02/01/2024, 8:18:52 AM ERROR [JobService] Unable to run job handler (metadataExtraction/metadata-extraction): QueryFailedError: insert or update on table "exif" violates foreign key constraint "FK_c0117fdbc50b917ef9067740c44" immich_microservices | [Nest] 7 - 02/01/2024, 8:18:52 AM ERROR [JobService] QueryFailedError: insert or update on table "exif" violates foreign key constraint "FK_c0117fdbc50b917ef9067740c44" immich_microservices | at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19) immich_microservices | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) immich_microservices | at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33) immich_microservices | at async AssetRepository.upsertExif (/usr/src/app/dist/infra/repositories/asset.repository.js:43:9) immich_microservices | at async MetadataService.handleMetadataExtraction (/usr/src/app/dist/domain/metadata/metadata.service.js:172:9) immich_microservices | at async /usr/src/app/dist/domain/job/job.service.js:116:37 immich_microservices | at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28) immich_microservices | at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24) immich_microservices | [Nest] 7 - 02/01/2024, 8:18:52 AM ERROR [JobService] Object: immich_microservices | { immich_microservices | "id": "29291517-abbc-4c45-a67a-a5589b65efe9" immich_microservices | } immich_microservices | immich_microservices | [Nest] 7 - 02/01/2024, 8:18:52 AM ERROR [JobService] Unable to run job handler (metadataExtraction/metadata-extraction): QueryFailedError: insert or update on table "exif" violates foreign key constraint "FK_c0117fdbc50b917ef9067740c44" immich_microservices | [Nest] 7 - 02/01/2024, 8:18:52 AM ERROR [JobService] QueryFailedError: insert or update on table "exif" violates foreign key constraint "FK_c0117fdbc50b917ef9067740c44" immich_microservices | at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19) immich_microservices | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) immich_microservices | at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33) immich_microservices | at async AssetRepository.upsertExif (/usr/src/app/dist/infra/repositories/asset.repository.js:43:9) immich_microservices | at async MetadataService.handleMetadataExtraction (/usr/src/app/dist/domain/metadata/metadata.service.js:172:9) immich_microservices | at async /usr/src/app/dist/domain/job/job.service.js:116:37 immich_microservices | at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28) immich_microservices | at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24) immich_microservices | [Nest] 7 - 02/01/2024, 8:18:52 AM ERROR [JobService] Object: immich_microservices | { immich_microservices | "id": "29291517-abbc-4c45-a67a-a5589b65efe9" immich_microservices | }

The OS that Immich Server is running on

Ubuntu 22.04.3 LTS

Version of Immich Server

1.94.1

Version of Immich Mobile App

1.94.1

Platform with the issue

Your docker-compose.yml content

version: "3.8"

services:
  immich-caddy:
    container_name: caddy
    image: caddy:2-alpine
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile
      - ./caddy/data:/data
      - ./caddy/config:/config
    environment:
      ACME_AGREE: 'true'
      DOMAIN: 'pics.deiop.de'
      EMAIL: 'tobi@deiop.de'

  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: [ "start.sh", "immich" ]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    ports:
      - 127.0.0.1:2283:3001
    depends_on:
      - redis
      - database
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends:
    #   file: hwaccel.yml
    #   service: hwaccel
    command: [ "start.sh", "microservices" ]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    depends_on:
      - redis
      - database
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2-alpine@sha256:70a7a5b641117670beae0d80658430853896b5ef269ccf00d1827427e3263fa3
    restart: always

  database:
    container_name: immich_postgres
    image: tensorchord/pgvecto-rs:pg14-v0.1.11
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always

volumes:
  pgdata:
  model-cache:

Your .env content

# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=./data

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

# Connection secrets for postgres and typesense. You should change these to random passwords
TYPESENSE_API_KEY=
DB_PASSWORD=

# 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. Upgrading to 1.94.1 docker compose pull
2. Running MetaData Extraction job on all media
3. Lots of errors in docker compose logs -f
...

Additional information

No response

agross commented 9 months ago

I get this beauty when upgrading from 1.93.latest to 1.94.1

Migration "AddAutoStackId1703035138085" failed, error: column "autoStackId" of relation "exif" already exists
/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219
            throw new QueryFailedError_1.QueryFailedError(query, parameters, err);
                  ^

QueryFailedError: column "autoStackId" of relation "exif" already exists
    at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AddAutoStackId1703035138085.up (/usr/src/app/dist/infra/migrations/1703035138085-AddAutoStackId.js:9:9)
    at async MigrationExecutor.executePendingMigrations (/usr/src/app/node_modules/typeorm/migration/MigrationExecutor.js:225:17)
    at async DataSource.runMigrations (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:263:35)
    at async DatabaseRepository.runMigrations (/usr/src/app/dist/infra/repositories/database.repository.js:42:9)
    at async DatabaseService.init (/usr/src/app/dist/domain/database/database.service.js:33:9)
    at async AppService.init (/usr/src/app/dist/immich/app.service.js:56:9)
    at async AppModule.onModuleInit (/usr/src/app/dist/immich/app.module.js:32:9)
    at async callModuleInitHook (/usr/src/app/node_modules/@nestjs/core/hooks/on-module-init.hook.js:51:9) {
  query: 'ALTER TABLE "exif" ADD "autoStackId" character varying',
  parameters: undefined,
  driverError: error: column "autoStackId" of relation "exif" already exists
      at /usr/src/app/node_modules/pg/lib/client.js:526:17
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:184:25)
      at async AddAutoStackId1703035138085.up (/usr/src/app/dist/infra/migrations/1703035138085-AddAutoStackId.js:9:9)
      at async MigrationExecutor.executePendingMigrations (/usr/src/app/node_modules/typeorm/migration/MigrationExecutor.js:225:17)
      at async DataSource.runMigrations (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:263:35)
      at async DatabaseRepository.runMigrations (/usr/src/app/dist/infra/repositories/database.repository.js:42:9)
      at async DatabaseService.init (/usr/src/app/dist/domain/database/database.service.js:33:9)
      at async AppService.init (/usr/src/app/dist/immich/app.service.js:56:9)
      at async AppModule.onModuleInit (/usr/src/app/dist/immich/app.module.js:32:9) {
    length: 134,
    severity: 'ERROR',
    code: '42701',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'tablecmds.c',
    line: '7242',
    routine: 'check_for_column_name_collision'
  },
  length: 134,
  severity: 'ERROR',
  code: '42701',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'tablecmds.c',
  line: '7242',
  routine: 'check_for_column_name_collision'
}