I
Immich3w ago
Cguijt

Huge update, DB upgrade gives errors

I've been running Immich for quite a while now without issues, but I've been unable to keep up with the updates due to reasons. I'm running on a Kubernetes cluster and just migrated the database to cnpg using this (since the postgres subchart is being deprecated). Connection is fine, but the migrations keep running into the same error, which is:
query: 'INSERT INTO "migrations"("timestamp", "name") VALUES ($1, $2)',
parameters: [ 1718486162779, 'AddFaceSearchRelation1718486162779' ],
driverError: error: duplicate key value violates unique constraint "PK_8c82d7f526340ab734260ea46be"
query: 'INSERT INTO "migrations"("timestamp", "name") VALUES ($1, $2)',
parameters: [ 1718486162779, 'AddFaceSearchRelation1718486162779' ],
driverError: error: duplicate key value violates unique constraint "PK_8c82d7f526340ab734260ea46be"
I must say; my probes did make my pod reboot mid migration, I'm not sut if that could've caused this issue. I've walked through all releases for any breaking changes and I've searched the GitHub issue list for similair errors, but couldn't find anything relevant. I'm upgrading from 1.106.4 to 1.132.3 - a huge leap, I know...
Gist
Immich: migrate postgres to CloudNativePG
Immich: migrate postgres to CloudNativePG. GitHub Gist: instantly share code, notes, and snippets.
8 Replies
Immich
Immich3w ago
:wave: Hey @Cguijt, Thanks for reaching out to us. Please carefully read this message and follow the recommended actions. This will help us be more effective in our support effort and leave more time for building Immich :immich:. References - Container Logs: docker compose logs docs - Container Status: docker ps -a docs - Reverse Proxy: https://immich.app/docs/administration/reverse-proxy - Code Formatting https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline#h_01GY0DAKGXDEHE263BCAYEGFJA Checklist I have... 1. :ballot_box_with_check: verified I'm on the latest release(note that mobile app releases may take some time). 2. :ballot_box_with_check: read applicable release notes. 3. :ballot_box_with_check: reviewed the FAQs for known issues. 4. :ballot_box_with_check: reviewed Github for known issues. 5. :ballot_box_with_check: tried accessing Immich via local ip (without a custom reverse proxy). 6. :ballot_box_with_check: uploaded the relevant information (see below). 7. :ballot_box_with_check: tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable (an item can be marked as "complete" by reacting with the appropriate number) Information In order to be able to effectively help you, we need you to provide clear information to show what the problem is. The exact details needed vary per case, but here is a list of things to consider: - Your docker-compose.yml and .env files. - Logs from all the containers and their status (see above). - All the troubleshooting steps you've tried so far. - Any recent changes you've made to Immich or your system. - Details about your system (both software/OS and hardware). - Details about your storage (filesystems, type of disks, output of commands like fdisk -l and df -h). - The version of the Immich server, mobile app, and other relevant pieces. - Any other information that you think might be relevant. Please paste files and logs with proper code formatting, and especially avoid blurry screenshots. Without the right information we can't work out what the problem is. Help us help you ;) If this ticket can be closed you can use the /close command, and re-open it later if needed.
Cguijt
CguijtOP3w ago
values.yaml for Helm chart version 0.9.3:
env:
REDIS_HOSTNAME: 'immich-redis-master.immich.svc.cluster.local'
DB_HOSTNAME: "immich-rw.cnpg"
DB_USERNAME: "immich"
DB_DATABASE_NAME: "immich"
# -- You should provide your own secret outside of this helm-chart and use `postgresql.global.postgresql.auth.existingSecret` to provide credentials to the postgresql instance
DB_PASSWORD: [redacted]
#DB_HOSTNAME: "{{ .Release.Name }}-postgresql"
#DB_USERNAME: "{{ .Values.postgresql.global.postgresql.auth.username }}"
#DB_DATABASE_NAME: "{{ .Values.postgresql.global.postgresql.auth.database }}"
IMMICH_MACHINE_LEARNING_URL: '{{ printf "http://%s-machine-learning:3003" .Release.Name }}'

image:
tag: v1.132.3

immich:
persistence:
# Main data store for all photos shared between different components.
library:
# Automatically creating the library volume is not supported by this chart
# You have to specify an existing PVC to use
existingClaim: immich-pvc

redis:
enabled: false
architecture: standalone
auth:
enabled: false

# Immich components

server:
enabled: true
image:
repository: ghcr.io/immich-app/immich-server
pullPolicy: IfNotPresent

probes:
readiness:
custom: true
spec:
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
startup:
custom: true
spec:
initialDelaySeconds: 60
timeoutSeconds: 5
## This means it has a maximum of 5*30=150 seconds to start up before it fails
periodSeconds: 60
failureThreshold: 60

persistence:
external:
existingClaim: immich-photos-pvc
enabled: true
readOnly: true

ingress:
main:
enabled: true
annotations:
# proxy-body-size is set to 0 to remove the body limit on file uploads
nginx.ingress.kubernetes.io/proxy-body-size: "0"
env:
REDIS_HOSTNAME: 'immich-redis-master.immich.svc.cluster.local'
DB_HOSTNAME: "immich-rw.cnpg"
DB_USERNAME: "immich"
DB_DATABASE_NAME: "immich"
# -- You should provide your own secret outside of this helm-chart and use `postgresql.global.postgresql.auth.existingSecret` to provide credentials to the postgresql instance
DB_PASSWORD: [redacted]
#DB_HOSTNAME: "{{ .Release.Name }}-postgresql"
#DB_USERNAME: "{{ .Values.postgresql.global.postgresql.auth.username }}"
#DB_DATABASE_NAME: "{{ .Values.postgresql.global.postgresql.auth.database }}"
IMMICH_MACHINE_LEARNING_URL: '{{ printf "http://%s-machine-learning:3003" .Release.Name }}'

image:
tag: v1.132.3

immich:
persistence:
# Main data store for all photos shared between different components.
library:
# Automatically creating the library volume is not supported by this chart
# You have to specify an existing PVC to use
existingClaim: immich-pvc

redis:
enabled: false
architecture: standalone
auth:
enabled: false

# Immich components

server:
enabled: true
image:
repository: ghcr.io/immich-app/immich-server
pullPolicy: IfNotPresent

probes:
readiness:
custom: true
spec:
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
startup:
custom: true
spec:
initialDelaySeconds: 60
timeoutSeconds: 5
## This means it has a maximum of 5*30=150 seconds to start up before it fails
periodSeconds: 60
failureThreshold: 60

persistence:
external:
existingClaim: immich-photos-pvc
enabled: true
readOnly: true

ingress:
main:
enabled: true
annotations:
# proxy-body-size is set to 0 to remove the body limit on file uploads
nginx.ingress.kubernetes.io/proxy-body-size: "0"
Immich
Immich3w ago
Successfully submitted, a tag has been added to inform contributors. :white_check_mark:
Cguijt
CguijtOP3w ago
Hmm, there are no matches if I run SELECT * FROM migrations WHERE name = 'AddFaceSearchRelation1718486162779'; The error seems to be originating from detail: 'Key (id)=(264) already exists.',
Cguijt
CguijtOP3w ago
Just to be complete, the full error: https://pastebin.com/CfKMzA8H
Pastebin
QueryFailedError: duplicate key value violates unique constraint "P...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
sogan
sogan3w ago
This is weird. Could you try upgrading to a lower version first, like 1.124.2?
Cguijt
CguijtOP3w ago
Logs aren't progressing past this, probe just cause a first reset:
Initializing Immich v1.124.2
Detected CPU Cores: 4
Starting api worker
Starting microservices worker
Initializing Immich v1.124.2
Detected CPU Cores: 4
Starting api worker
Starting microservices worker
No errors on the database node Hmm, even though I haven't changed the database details, v1.124.2 throws ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
sogan
sogan3w ago
IIRC there were some k8s setups that had trouble because of very low default cpu and ram limits for postgres. I’m not sure how to help increase them, but that might be something to look into

Did you find this page helpful?