docker-immich icon indicating copy to clipboard operation
docker-immich copied to clipboard

cosine_ops does not exist for access method vectors

Open Scridgeon opened this issue 2 years ago • 11 comments

I upgraded to the latest release of immich and now it will not connect to my Postgres 14 container (tensorchord/pgvecto-rs:pg14-latest).

The Immich logs are filled with the following error message that keeps repeating.

ERROR [TypeOrmModule] Unable to connect to the database. Retrying (8)... QueryFailedError: operator class "cosine_ops" does not exist for access method "vectors" at PostgresQueryRunner.query (/app/immich/server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async AddCLIPEmbeddingIndex1700713994428.up (/app/immich/server/dist/infra/migrations/1700713994428-AddCLIPEmbeddingIndex.js:9:9) at async MigrationExecutor.executePendingMigrations (/app/immich/server/node_modules/typeorm/migration/MigrationExecutor.js:225:17) at async DataSource.runMigrations (/app/immich/server/node_modules/typeorm/data-source/DataSource.js:260:35) at async DataSource.initialize (/app/immich/server/node_modules/typeorm/data-source/DataSource.js:148:17)

Scridgeon avatar Dec 17 '23 20:12 Scridgeon

You have to use tensorchord/pgvecto-rs:pg14-v0.1.11

martabal avatar Dec 17 '23 20:12 martabal

Thanks, that worked! How do I ensure the PG version is correct moving forward if there are release changes?

Scridgeon avatar Dec 17 '23 23:12 Scridgeon

That's annoying, took me hours to figure out how to build from source on OpenSUSE (never used Rust before). Will do some testings tomorrow with the correct release this time rather than a git clone. Should be faster now that I went through all the potential barriers (that's after thinking pgvector and pgvecto.rs were the same, oopsies).

dnlldl avatar Dec 18 '23 07:12 dnlldl

that's after thinking pgvector and pgvecto.rs were the same, oopsies

I too had fun with that barrier

hydazz avatar Dec 18 '23 07:12 hydazz

Thanks, that worked! How do I ensure the PG version is correct moving forward if there are release changes?

I think you have to read Immich release notes which will say when to update your postgres container.

martabal avatar Dec 18 '23 10:12 martabal

ERROR [TypeOrmModule] Unable to connect to the database. Retrying (9)... QueryFailedError: could not open extension control file "/usr/share/postgresql/14/extension/vectors.control": No such file or directory

naxiemolv avatar Dec 18 '23 12:12 naxiemolv

ERROR [TypeOrmModule] Unable to connect to the database. Retrying (9)... QueryFailedError: could not open extension control file "/usr/share/postgresql/14/extension/vectors.control": No such file or directory

Are you using the tensorchord/pgvecto-rs:pg14-v0.1.11 image ?

martabal avatar Dec 18 '23 12:12 martabal

I downgraded to v0.1.11 and now have a new error:

[Nest] 831  - 12/18/2023, 1:46:49 PM   ERROR [ExceptionHandler] could not find function "typmod_in_wrapper" in file "/usr/lib/postgresql14/lib64/vectors.so"
QueryFailedError: could not find function "typmod_in_wrapper" in file "/usr/lib/postgresql14/lib64/vectors.so"
    at PostgresQueryRunner.query (/app/immich/server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async UsePgVectors1700713871511.up (/app/immich/server/dist/infra/migrations/1700713871511-UsePgVectors.js:19:9)
    at async MigrationExecutor.executePendingMigrations (/app/immich/server/node_modules/typeorm/migration/MigrationExecutor.js:225:17)
    at async DataSource.runMigrations (/app/immich/server/node_modules/typeorm/data-source/DataSource.js:260:35)
    at async DataSource.initialize (/app/immich/server/node_modules/typeorm/data-source/DataSource.js:148:17)

Edit: just noticed this: https://github.com/immich-app/immich/issues/5731#issuecomment-1858687776

I guess I'll try to clean things up as much as possible and restart from scratch.

So far without success.

vm-dev:~ # rm -rf /var/lib/pgsql/data/pg_vectors
vm-dev:~ # rm /usr/lib/postgresql14/lib64/vectors.so
vm-dev:~ # rm /usr/share/postgresql14/extension/vectors.control
vm-dev:~ # rm /usr/share/postgresql14/extension/vectors--0.1.1.sql
vm-dev:~ # rm /usr/share/postgresql14/extension/vectors--0.0.0.sql
vm-dev:~ # rm -rf /root/.rustup/toolchains/*
vm-dev:~ # rm -rf /var/lib/pgsql/.rustup/toolchains/*

dnlldl avatar Dec 18 '23 18:12 dnlldl

Fixed it through https://github.com/tensorchord/pgvecto.rs/issues/199.

dnlldl avatar Dec 19 '23 15:12 dnlldl

You have to use tensorchord/pgvecto-rs:pg14-v0.1.11

Where do I put this info?

dkerlee avatar Dec 30 '23 02:12 dkerlee

Where do I put this info?

https://github.com/imagegenius/docker-immich/issues/254

martabal avatar Dec 30 '23 09:12 martabal