I
Immichβ€’3mo ago
ysmfwns3

Move to new database vector extension

Hi there πŸ™‚ I've been struggling to understand how to migrate to the new database vector extension as I don't have a super standard setup πŸ˜‰ Could one of you help me with this migration process? Setup: - OS: TrueNAS Scale (23.10.2) - Deployment: Integrated Kubernetes (k3s) - Configuration: https://github.com/v3DJG6GL/truecharts_archive/blob/main/stable/immich/15.18.3/ix_values.yaml - DB: CNPG This is the .yaml part that configures the CNPG currently:
cnpg:
main:
enabled: true
user: immich
database: immich
type: vectors
cluster:
initdb:
postInitApplicationSQL:
- CREATE EXTENSION IF NOT EXISTS cube;
- CREATE EXTENSION IF NOT EXISTS earthdistance;
- CREATE SCHEMA IF NOT EXISTS vectors;
- ALTER DATABASE immich SET search_path TO "immich", public, vectors;
- SET search_path TO "immich", public, vectors;
- GRANT SELECT ON TABLE pg_vector_index_stat TO PUBLIC;
- ALTER SCHEMA vectors OWNER TO immich;
cnpg:
main:
enabled: true
user: immich
database: immich
type: vectors
cluster:
initdb:
postInitApplicationSQL:
- CREATE EXTENSION IF NOT EXISTS cube;
- CREATE EXTENSION IF NOT EXISTS earthdistance;
- CREATE SCHEMA IF NOT EXISTS vectors;
- ALTER DATABASE immich SET search_path TO "immich", public, vectors;
- SET search_path TO "immich", public, vectors;
- GRANT SELECT ON TABLE pg_vector_index_stat TO PUBLIC;
- ALTER SCHEMA vectors OWNER TO immich;
Note: I am the maintainer this repository because the initial maintainers dropped support for TrueNAS SCALE a year ago.
9 Replies
Immich
Immichβ€’3mo ago
:wave: Hey @ysmfwns3, 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. Successfully submitted, a tag has been added to inform contributors. :white_check_mark:
ysmfwns3
ysmfwns3OPβ€’3mo ago
I have looked into this a little more closely: 1. It seems that I have to modify common/templates/class/cnpg/_cluster.tpl to preload needed libraries: - Currently, this code loads the needed vectors.so library if objectData.type is vectors:
{{- if eq $objectData.type "vectors" -}}
{{- $preloadLibraries = mustAppend $preloadLibraries "vectors.so" -}}
{{- end -}}
{{- if eq $objectData.type "vectors" -}}
{{- $preloadLibraries = mustAppend $preloadLibraries "vectors.so" -}}
{{- end -}}
- I suppose this modification would additionally load vchord.so library during transition:
{{- if eq $objectData.type "vectors" -}}
{{- $preloadLibraries = mustAppend $preloadLibraries "vectors.so" -}}
{{- $preloadLibraries = mustAppend $preloadLibraries "vchord.so" -}}
{{- end -}}
{{- if eq $objectData.type "vectors" -}}
{{- $preloadLibraries = mustAppend $preloadLibraries "vectors.so" -}}
{{- $preloadLibraries = mustAppend $preloadLibraries "vchord.so" -}}
{{- end -}}
But I suppose the objectData.type will change too with the new library, right? But I haven't found which objectData.type is used for vchord.so 2. Additionally, I suppose I need to modify common/templates/lib/cnpg/cluster/_bootstrapStandalone.tpl: - As of now, this code creates the extension vectors if objectData.type is vectors:
{{- if eq $objectData.type "vectors" -}}
{{- $postInitApplicationSQL = concat $postInitApplicationSQL (list
"CREATE EXTENSION IF NOT EXISTS vectors;") -}}
{{- end -}}
{{- if eq $objectData.type "vectors" -}}
{{- $postInitApplicationSQL = concat $postInitApplicationSQL (list
"CREATE EXTENSION IF NOT EXISTS vectors;") -}}
{{- end -}}
- This modification would also create the extension vchord during transition:
{{- if eq $objectData.type "vectors" -}}
{{- $postInitApplicationSQL = concat $postInitApplicationSQL (list
"CREATE EXTENSION IF NOT EXISTS vectors;"
"CREATE EXTENSION IF NOT EXISTS vchord CASCADE;") -}}
{{- end -}}
{{- if eq $objectData.type "vectors" -}}
{{- $postInitApplicationSQL = concat $postInitApplicationSQL (list
"CREATE EXTENSION IF NOT EXISTS vectors;"
"CREATE EXTENSION IF NOT EXISTS vchord CASCADE;") -}}
{{- end -}}
But I am facing the same issue here: what objectData.type is used for the new extension? Or is this a value something which the initial maintainers set by themself? If that's the case, I just could set a new type; e.g. vchord...πŸ€”
bo0tzz
bo0tzzβ€’3mo ago
https://github.com/immich-app/immich-charts/issues/149 has some discussion on how to run the new db extension with cnpg I can't help with any of that truecharts mess
mertalev
mertalevβ€’3mo ago
objectData.type seems like some custom value used to only run certain sql conditionally during the cluster booststrap. I can’t say if there’s a deeper meaning behind the specific name (like if it’s interpolated into a command somewhere)
ysmfwns3
ysmfwns3OPβ€’3mo ago
thanks for your replies πŸ™‚ I am trying to setup a new immich chart with the new vector extension configured. Seems saver to first get a new installation running than migrate my current installation. I think I have found almost all the parts that have to be modified inside common. But I am currently struggling wit this error when deploying the chart:
[EFAULT] Failed to install App: Container - Expected [.Values.postgresVectorchord16Image] to exist
[EFAULT] Failed to install App: Container - Expected [.Values.postgresVectorchord16Image] to exist
I have added these containers to common/values.yaml:
postgresVector15Image:
repository: ghcr.io/pgvector/pgvector
tag: "0.8.0-pg15"
pullPolicy: IfNotPresent

postgresVector16Image:
repository: docker.io/pgvector/pgvector
tag: "0.8.0-pg16"
pullPolicy: IfNotPresent

postgresVectorChord15Image:
repository: ghcr.io/tensorchord/vchord-postgres
tag: "pg15-v0.2.2"
pullPolicy: IfNotPresent

postgresVectorChord16Image:
repository: ghcr.io/tensorchord/vchord-postgres
tag: "pg16-v0.2.2"
pullPolicy: IfNotPresent
postgresVector15Image:
repository: ghcr.io/pgvector/pgvector
tag: "0.8.0-pg15"
pullPolicy: IfNotPresent

postgresVector16Image:
repository: docker.io/pgvector/pgvector
tag: "0.8.0-pg16"
pullPolicy: IfNotPresent

postgresVectorChord15Image:
repository: ghcr.io/tensorchord/vchord-postgres
tag: "pg15-v0.2.2"
pullPolicy: IfNotPresent

postgresVectorChord16Image:
repository: ghcr.io/tensorchord/vchord-postgres
tag: "pg16-v0.2.2"
pullPolicy: IfNotPresent
And it seems as if the deployment finds the value postgresVectorchord16Image but the image is not pulled...? πŸ€” tbh, I definitely should move to a real kubernetes deployment and stop messing around with that. it's terrible - but I don't have the time for that currently πŸ˜… alright, test instance is running πŸ˜„ it was a typo: I had to set postgresVectorchord16Image instead of postgresVectorChord16Image Furthermore I changed the repository and had to use at least v0.3.0:
postgresVector15Image:
repository: ghcr.io/pgvector/pgvector
tag: "0.8.0-pg15"
pullPolicy: IfNotPresent

postgresVector16Image:
repository: docker.io/pgvector/pgvector
tag: "0.8.0-pg16"
pullPolicy: IfNotPresent

postgresVectorchord15Image:
repository: ghcr.io/tensorchord/cloudnative-vectorchord
tag: "15.12-0.3.0"
pullPolicy: IfNotPresent

postgresVectorchord16Image:
repository: ghcr.io/tensorchord/cloudnative-vectorchord
tag: "16.8-0.3.0"
pullPolicy: IfNotPresent
postgresVector15Image:
repository: ghcr.io/pgvector/pgvector
tag: "0.8.0-pg15"
pullPolicy: IfNotPresent

postgresVector16Image:
repository: docker.io/pgvector/pgvector
tag: "0.8.0-pg16"
pullPolicy: IfNotPresent

postgresVectorchord15Image:
repository: ghcr.io/tensorchord/cloudnative-vectorchord
tag: "15.12-0.3.0"
pullPolicy: IfNotPresent

postgresVectorchord16Image:
repository: ghcr.io/tensorchord/cloudnative-vectorchord
tag: "16.8-0.3.0"
pullPolicy: IfNotPresent
Now I only need to figure out how to flawlessly migrate old instances to the new vector extension 🫠 update: I managed it by manually importing & exporting all tables to the new instance with new DB vector extension. Seems to work so far πŸ™‚ is there a reference how the db should look like? some tables were not present on the new setup - typeorm_metadata - migrations I suppose the first table is related to TypeORM that was dropped with immich v1.132.0 and thus not used anymore but I am not sure whether the second table should exist... πŸ€”
mertalev
mertalevβ€’3mo ago
I think the second one is also a typeorm table
lborv
lborvβ€’3mo ago
Hi! I have a problem. Trying to migrate to new vector things. But image is always rebooting. Here is some logs
immich_server | [Nest] 17 - 06/11/2025, 9:38:36 AM LOG [Api:Bootstrap] Immich Server is listening on http://[::1]:2283 [v1.134.0] [production]
immich_server | [Nest] 7 - 06/11/2025, 9:38:38 AM LOG [Microservices:MapRepository] 10000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:38 AM LOG [Microservices:MapRepository] 20000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:38 AM LOG [Microservices:MapRepository] 30000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:38 AM LOG [Microservices:MapRepository] 40000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:39 AM LOG [Microservices:MapRepository] 50000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:39 AM LOG [Microservices:MapRepository] 60000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:39 AM LOG [Microservices:MapRepository] 70000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:39 AM LOG [Microservices:MapRepository] 80000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:39 AM LOG [Microservices:MapRepository] 90000 geodata records imported
immich_postgres | 2025-06-11 06:38:40.753 UTC [419] LOG: unexpected EOF on client connection with an open transaction
immich_postgres | 2025-06-11 06:38:40.762 UTC [405] LOG: could not receive data from client: Connection reset by peer
immich_postgres | 2025-06-11 06:38:40.762 UTC [405] LOG: unexpected EOF on client connection with an open transaction
immich_server exited with code 0
immich_server | Starting api worker
immich_server | Starting microservices worker
immich_server | [Nest] 17 - 06/11/2025, 9:38:36 AM LOG [Api:Bootstrap] Immich Server is listening on http://[::1]:2283 [v1.134.0] [production]
immich_server | [Nest] 7 - 06/11/2025, 9:38:38 AM LOG [Microservices:MapRepository] 10000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:38 AM LOG [Microservices:MapRepository] 20000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:38 AM LOG [Microservices:MapRepository] 30000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:38 AM LOG [Microservices:MapRepository] 40000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:39 AM LOG [Microservices:MapRepository] 50000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:39 AM LOG [Microservices:MapRepository] 60000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:39 AM LOG [Microservices:MapRepository] 70000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:39 AM LOG [Microservices:MapRepository] 80000 geodata records imported
immich_server | [Nest] 7 - 06/11/2025, 9:38:39 AM LOG [Microservices:MapRepository] 90000 geodata records imported
immich_postgres | 2025-06-11 06:38:40.753 UTC [419] LOG: unexpected EOF on client connection with an open transaction
immich_postgres | 2025-06-11 06:38:40.762 UTC [405] LOG: could not receive data from client: Connection reset by peer
immich_postgres | 2025-06-11 06:38:40.762 UTC [405] LOG: unexpected EOF on client connection with an open transaction
immich_server exited with code 0
immich_server | Starting api worker
immich_server | Starting microservices worker
ysmfwns3
ysmfwns3OPβ€’3mo ago
ok, good to know! And I suppose that immich somehow checks the database integrity and would report/log if there are irregularities? that's the content of the migrations table btw:
1,1645130759468,CreateUserTable1645130759468
2,1645130777674,CreateDeviceInfoTable1645130777674
3,1645130805273,CreateAssetsTable1645130805273
4,1645130817965,CreateExifTable1645130817965
5,1645130870184,CreateSmartInfoTable1645130870184
6,1646249209023,AddExifTextSearchColumn1646249209023
7,1646249734844,CreateExifTextSearchIndex1646249734844
8,1646709533213,AddRegionCityToExIf1646709533213
[...]
1,1645130759468,CreateUserTable1645130759468
2,1645130777674,CreateDeviceInfoTable1645130777674
3,1645130805273,CreateAssetsTable1645130805273
4,1645130817965,CreateExifTable1645130817965
5,1645130870184,CreateSmartInfoTable1645130870184
6,1646249209023,AddExifTextSearchColumn1646249209023
7,1646249734844,CreateExifTextSearchIndex1646249734844
8,1646709533213,AddRegionCityToExIf1646709533213
[...]
mertalev
mertalevβ€’3mo ago
Yes, it checks the migrations and kysely_migrations tables among others and will abort if there’s anything unexpected

Did you find this page helpful?