immich-app / immich

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

Migration "AddFaceSearchRelation1718486162779" failed, error: access method "hnsw" does not exist #10984

Open docwisdom opened 3 months ago

docwisdom commented 3 months ago

The bug

Trying to start the container, logs present the following error Migration "AddFaceSearchRelation1718486162779" failed, error: access method "hnsw" does not exist

The OS that Immich Server is running on

Unraid

Version of Immich Server

v1.107.2

Version of Immich Mobile App

v1.107.1

Platform with the issue

Your docker-compose.yml content

I use unraid app version

Your .env content

docker run
  -d
  --name='immich'
  --net='bridge'
  --cpuset-cpus='5,6,7,19,20,21'
  -e TZ="America/Los_Angeles"
  -e HOST_OS="Unraid"
  -e HOST_HOSTNAME="NAS"
  -e HOST_CONTAINERNAME="immich"
  -e 'DB_HOSTNAME'='10.0.0.55'
  -e 'DB_USERNAME'='admin'
  -e 'DB_PASSWORD'=''
  -e 'DB_DATABASE_NAME'='immich'
  -e 'REDIS_HOSTNAME'='10.0.0.55'
  -e 'DISABLE_MACHINE_LEARNING'='false'
  -e 'DISABLE_TYPESENSE'='false'
  -e 'DB_PORT'='5432'
  -e 'REDIS_PORT'='6379'
  -e 'REDIS_PASSWORD'=''
  -e 'MACHINE_LEARNING_WORKERS'='1'
  -e 'MACHINE_LEARNING_WORKER_TIMEOUT'='120'
  -e 'PUID'='99'
  -e 'PGID'='100'
  -e 'UMASK'='022'
  -l net.unraid.docker.managed=dockerman
  -l net.unraid.docker.webui='http://[IP]:[PORT:8080]'
  -l net.unraid.docker.icon='https://raw.githubusercontent.com/imagegenius/templates/main/unraid/img/immich.png'
  -p '8787:8080/tcp'
  -v '/mnt/user/photos-immich/':'/photos':'rw'
  -v '/mnt/user/appdata/immich/machine':'/config/machine-learning':'rw'
  -v '/mnt/user/photos/':'/import':'ro'
  -v '/mnt/user/media/':'/media':'rw'
  -v '/mnt/user/appdata/immich':'/config':'rw' 'ghcr.io/imagegenius/immich'

Reproduction steps

1. Start container
2. Notice webUI doesnt work
3. Check logs

Relevant log output

Starting api worker
[Nest] 388  - 07/09/2024, 11:41:45 AM     LOG [Api:EventRepository] Initialized websocket server
Migration "AddFaceSearchRelation1718486162779" failed, error: access method "hnsw" does not exist
QueryFailedError: access method "hnsw" does not exist
    at PostgresQueryRunner.query (/app/immich/server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AddFaceSearchRelation1718486162779.up (/app/immich/server/dist/migrations/1718486162779-AddFaceSearchRelation.js:23: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:265:35)
    at async DatabaseRepository.runMigrations (/app/immich/server/dist/repositories/database.repository.js:169:9)
    at async /app/immich/server/dist/services/database.service.js:134:17
    at async /app/immich/server/dist/repositories/database.repository.js:177:23 {
  query: '\n' +
    '            CREATE INDEX face_index ON face_search\n' +
    '            USING hnsw (embedding vector_cosine_ops)\n' +
    '            WITH (ef_construction = 300, m = 16)',
  parameters: undefined,
  driverError: error: access method "hnsw" does not exist
      at /app/immich/server/node_modules/pg/lib/client.js:526:17
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async PostgresQueryRunner.query (/app/immich/server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:184:25)
      at async AddFaceSearchRelation1718486162779.up (/app/immich/server/dist/migrations/1718486162779-AddFaceSearchRelation.js:23: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:265:35)
      at async DatabaseRepository.runMigrations (/app/immich/server/dist/repositories/database.repository.js:169:9)
      at async /app/immich/server/dist/services/database.service.js:134:17
      at async /app/immich/server/dist/repositories/database.repository.js:177:23 {
    length: 94,
    severity: 'ERROR',
    code: '42704',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'indexcmds.c',
    line: '831',
    routine: 'DefineIndex'
  },
  length: 94,
  severity: 'ERROR',
  code: '42704',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'indexcmds.c',
  line: '831',
  routine: 'DefineIndex'
}
node:internal/process/promises:391
    triggerUncaughtException(err, true /* fromPromise */);
    ^

QueryFailedError: access method "hnsw" does not exist
    at PostgresQueryRunner.query (/app/immich/server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AddFaceSearchRelation1718486162779.up (/app/immich/server/dist/migrations/1718486162779-AddFaceSearchRelation.js:23: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:265:35)
    at async DatabaseRepository.runMigrations (/app/immich/server/dist/repositories/database.repository.js:169:9)
    at async /app/immich/server/dist/services/database.service.js:134:17
    at async /app/immich/server/dist/repositories/database.repository.js:177:23 {
  query: '\n' +
    '            CREATE INDEX face_index ON face_search\n' +
    '            USING hnsw (embedding vector_cosine_ops)\n' +
    '            WITH (ef_construction = 300, m = 16)',
  parameters: undefined,
  driverError: error: access method "hnsw" does not exist
      at /app/immich/server/node_modules/pg/lib/client.js:526:17
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async PostgresQueryRunner.query (/app/immich/server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:184:25)
      at async AddFaceSearchRelation1718486162779.up (/app/immich/server/dist/migrations/1718486162779-AddFaceSearchRelation.js:23: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:265:35)
      at async DatabaseRepository.runMigrations (/app/immich/server/dist/repositories/database.repository.js:169:9)
      at async /app/immich/server/dist/services/database.service.js:134:17
      at async /app/immich/server/dist/repositories/database.repository.js:177:23 {
    length: 94,
    severity: 'ERROR',
    code: '42704',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'indexcmds.c',
    line: '831',
    routine: 'DefineIndex'
  },
  length: 94,
  severity: 'ERROR',
  code: '42704',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'indexcmds.c',
  line: '831',
  routine: 'DefineIndex'
}

Node.js v20.15.0
api worker exited with code 1

Additional information

No response

alextran1502 commented 3 months ago

Can you take a look at this? https://github.com/immich-app/immich/discussions/7392#discussioncomment-8580344

Look like your database user is not superuser

docwisdom commented 3 months ago

I'm using postgres repository tensorchord/pgvecto-rs:pg15-v0.2.0 I have no idea how to check if the user account created is superuser or not.

I tried alter role admin with superuser; and UPDATE pg_catalog.pg_extension SET extversion = '0.2.0' WHERE extname = 'vectors'; with no luck. I now get the error Migration "AddFaceSearchRelation1718486162779" failed, error: could not find function "vector_typmod_in_wrapper" in file "/usr/lib/postgresql/15/lib/vectors.so"

mertalev commented 3 months ago

The command "upgrading" to 0.2.0 meant that it never tried to actually upgrade the extension. You should run UPDATE pg_catalog.pg_extension SET extversion = '0.1.11' WHERE extname = 'vectors';. If it still doesn't work after that, the commands in this comment solve most issues.

danieldietzler commented 1 month ago

Hey @docwisdom did mertalev's suggestions fix it?