[BUG] "asset_faces" violates foreign key constraint #1509

Closed
opened 2026-02-05 02:08:58 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @travelr on GitHub (Oct 25, 2023).

The bug

Hi,

the face recognition job is causing foreign key constraint violations with the table persons

[Nest] 8  - 10/25/2023, 4:42:29 AM   ERROR [JobService] Unable to run job handler (recognizeFaces/recognize-faces): QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9"
[Nest] 8  - 10/25/2023, 4:42:29 AM   ERROR [JobService] QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9"
    at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33)
    at async SubjectExecutor.executeInsertOperations (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42)
    at async SubjectExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9)
    at async EntityPersistExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21)
    at async PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:222:13)
    at async /usr/src/app/dist/domain/job/job.service.js:108:37
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:350:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:535:24)
[Nest] 8  - 10/25/2023, 4:42:29 AM   ERROR [JobService] Object:
{
  "id": "2d060d78-2e2c-40c3-8d25-5d9cb74dadb8"
}

[Nest] 8  - 10/25/2023, 4:42:29 AM   ERROR [JobService] Unable to run job handler (recognizeFaces/recognize-faces): QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9"
[Nest] 8  - 10/25/2023, 4:42:29 AM   ERROR [JobService] QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9"
    at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33)
    at async SubjectExecutor.executeInsertOperations (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42)
    at async SubjectExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9)
    at async EntityPersistExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21)
    at async PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:222:13)
    at async /usr/src/app/dist/domain/job/job.service.js:108:37
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:350:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:535:24)
[Nest] 8  - 10/25/2023, 4:42:29 AM   ERROR [JobService] Object:
{
  "id": "6a994937-d9e0-4f59-b015-b975ca547f32"
}

[Nest] 8  - 10/25/2023, 4:42:29 AM   ERROR [JobService] Unable to run job handler (recognizeFaces/recognize-faces): QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9"
[Nest] 8  - 10/25/2023, 4:42:29 AM   ERROR [JobService] QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9"
    at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33)
    at async SubjectExecutor.executeInsertOperations (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42)
    at async SubjectExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9)
    at async EntityPersistExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21)
    at async PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:222:13)
    at async /usr/src/app/dist/domain/job/job.service.js:108:37
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:350:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:535:24)
[Nest] 8  - 10/25/2023, 4:42:29 AM   ERROR [JobService] Object:
{
  "id": "d63a0967-f74c-4c29-a87e-ea936a8d51fa"
}

The OS that Immich Server is running on

Ubuntu 22

Version of Immich Server

v1.8.2.1

Version of Immich Mobile App

latest

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

-

Your .env content

-

Reproduction steps

Reproduction is unclear, in previous runs facial recognition worked. Various faces are already identified in the database.

Now after adding a bunch of photos to the external library, facial recognition always fails with the constraint violation.

Additional information

Please advise what further information is required.

Originally created by @travelr on GitHub (Oct 25, 2023). ### The bug Hi, the face recognition job is causing foreign key constraint violations with the table persons ``` [Nest] 8 - 10/25/2023, 4:42:29 AM ERROR [JobService] Unable to run job handler (recognizeFaces/recognize-faces): QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9" [Nest] 8 - 10/25/2023, 4:42:29 AM ERROR [JobService] QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9" at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33) at async SubjectExecutor.executeInsertOperations (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42) at async SubjectExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9) at async EntityPersistExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21) at async PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:222:13) at async /usr/src/app/dist/domain/job/job.service.js:108:37 at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:350:28) at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:535:24) [Nest] 8 - 10/25/2023, 4:42:29 AM ERROR [JobService] Object: { "id": "2d060d78-2e2c-40c3-8d25-5d9cb74dadb8" } [Nest] 8 - 10/25/2023, 4:42:29 AM ERROR [JobService] Unable to run job handler (recognizeFaces/recognize-faces): QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9" [Nest] 8 - 10/25/2023, 4:42:29 AM ERROR [JobService] QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9" at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33) at async SubjectExecutor.executeInsertOperations (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42) at async SubjectExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9) at async EntityPersistExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21) at async PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:222:13) at async /usr/src/app/dist/domain/job/job.service.js:108:37 at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:350:28) at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:535:24) [Nest] 8 - 10/25/2023, 4:42:29 AM ERROR [JobService] Object: { "id": "6a994937-d9e0-4f59-b015-b975ca547f32" } [Nest] 8 - 10/25/2023, 4:42:29 AM ERROR [JobService] Unable to run job handler (recognizeFaces/recognize-faces): QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9" [Nest] 8 - 10/25/2023, 4:42:29 AM ERROR [JobService] QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9" at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33) at async SubjectExecutor.executeInsertOperations (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42) at async SubjectExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9) at async EntityPersistExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21) at async PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:222:13) at async /usr/src/app/dist/domain/job/job.service.js:108:37 at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:350:28) at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:535:24) [Nest] 8 - 10/25/2023, 4:42:29 AM ERROR [JobService] Object: { "id": "d63a0967-f74c-4c29-a87e-ea936a8d51fa" } ``` ### The OS that Immich Server is running on Ubuntu 22 ### Version of Immich Server v1.8.2.1 ### Version of Immich Mobile App latest ### Platform with the issue - [X] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML - ``` ### Your .env content ```Shell - ``` ### Reproduction steps Reproduction is unclear, in previous runs facial recognition worked. Various faces are already identified in the database. Now after adding a bunch of photos to the external library, facial recognition always fails with the constraint violation. ### Additional information Please advise what further information is required.
Author
Owner

@jrasm91 commented on GitHub (Oct 25, 2023):

There is a current limitation where the same person cannot appear in the same photo not than once, otherwise it throws this error. This is a limitation we're looking to remove soon.

@jrasm91 commented on GitHub (Oct 25, 2023): There is a current limitation where the same person cannot appear in the same photo not than once, otherwise it throws this error. This is a limitation we're looking to remove soon.
Author
Owner

@jrasm91 commented on GitHub (Oct 25, 2023):

This actually should be fixed once #4474 is released.

@jrasm91 commented on GitHub (Oct 25, 2023): This actually should be fixed once #4474 is released.
Author
Owner

@travelr commented on GitHub (Nov 5, 2023):

This issue still occurs with some photos using version 1.8.4. But the errors are now occurring less compared to 1.8.2

[Nest] 7  - 11/05/2023, 10:00:47 AM   ERROR [JobService] Unable to run job handler (recognizeFaces/recognize-faces): QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9"
[Nest] 7  - 11/05/2023, 10:00:47 AM   ERROR [JobService] QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9"
    at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33)
    at async SubjectExecutor.executeInsertOperations (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42)
    at async SubjectExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9)
    at async EntityPersistExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21)
    at async PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:194:13)
    at async /usr/src/app/dist/domain/job/job.service.js:108:37
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:350:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:535:24)
[Nest] 7  - 11/05/2023, 10:00:47 AM   ERROR [JobService] Object:
{
  "id": "02144ef9-fc32-4ebd-b78a-8fd1a5701db4"
}
}
@travelr commented on GitHub (Nov 5, 2023): This issue still occurs with some photos using version 1.8.4. But the errors are now occurring less compared to 1.8.2 ``` [Nest] 7 - 11/05/2023, 10:00:47 AM ERROR [JobService] Unable to run job handler (recognizeFaces/recognize-faces): QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9" [Nest] 7 - 11/05/2023, 10:00:47 AM ERROR [JobService] QueryFailedError: insert or update on table "asset_faces" violates foreign key constraint "FK_95ad7106dd7b484275443f580f9" at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33) at async SubjectExecutor.executeInsertOperations (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42) at async SubjectExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9) at async EntityPersistExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21) at async PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:194:13) at async /usr/src/app/dist/domain/job/job.service.js:108:37 at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:350:28) at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:535:24) [Nest] 7 - 11/05/2023, 10:00:47 AM ERROR [JobService] Object: { "id": "02144ef9-fc32-4ebd-b78a-8fd1a5701db4" } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#1509