immich-app / immich

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

Issue with facial recognition of deleted images #6709

Closed mmomjian closed 9 months ago

mmomjian commented 9 months ago

The bug

This but is closely related to #1988 - deleted images cause an error during facial recogniton.

Error message:

[Nest] 8  - 01/28/2024, 7:44:38 PM   ERROR [JobService] Unable to run job handler (facialRecognition/facial-recognition): TypeError: Cannot read properties of null (reading 'ownerId')
[Nest] 8  - 01/28/2024, 7:44:38 PM   ERROR [JobService] TypeError: Cannot read properties of null (reading 'ownerId')
    at PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:297:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /usr/src/app/dist/domain/job/job.service.js:116:37
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)
[Nest] 8  - 01/28/2024, 7:44:38 PM   ERROR [JobService] Object:
{
  "id": "d34ff9e7-c2a6-4544-929f-348a0c44729e",
  "deferred": false
}

Postgres:

immich=# select "id","assetId" from asset_faces where "id" = 'd34ff9e7-c2a6-4544-929f-348a0c44729e';
                  id                  |               assetId
--------------------------------------+--------------------------------------
 d34ff9e7-c2a6-4544-929f-348a0c44729e | b14ebe91-3420-45be-ac78-86b56c791296
(1 row)

immich=# select "id","deletedAt" from assets where "id" = 'b14ebe91-3420-45be-ac78-86b56c791296';
                  id                  |           deletedAt
--------------------------------------+-------------------------------
 b14ebe91-3420-45be-ac78-86b56c791296 | 2024-01-28 13:15:43.272135-05
(1 row)

immich=#

Similar to #1988 , I believe we need to check if the image is deleted when looking for facial recognition.

The OS that Immich Server is running on

Debian 12 on docker

Version of Immich Server

v1.93.3

Version of Immich Mobile App

n/a

Platform with the issue

Your docker-compose.yml content

n/a

Your .env content

n/a

Reproduction steps

1. Delete an image
2. Run facial recognition

Additional information

No response

mmomjian commented 9 months ago

Just providing some more logs here:

[Nest] 7  - 01/28/2024, 9:05:48 PM   ERROR [JobService] Unable to run job handler (facialRecognition/facial-recognition): TypeError: Cannot read properties of null (reading 'ownerId')
[Nest] 7  - 01/28/2024, 9:05:48 PM   ERROR [JobService] TypeError: Cannot read properties of null (reading 'ownerId')
    at PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:297:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /usr/src/app/dist/domain/job/job.service.js:116:37
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)
[Nest] 7  - 01/28/2024, 9:05:48 PM   ERROR [JobService] Object:
{
  "id": "43ef169c-af5c-4748-82a8-5e7ba28dc572",
  "deferred": false
}

[Nest] 7  - 01/28/2024, 9:11:20 PM     LOG [PersonService] Creating new person for face 569b21a0-5f64-46c4-bf6e-46a2f5db0306
[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] Unable to run job handler (facialRecognition/facial-recognition): TypeError: Cannot read properties of null (reading 'ownerId')
[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] TypeError: Cannot read properties of null (reading 'ownerId')
    at PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:297:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /usr/src/app/dist/domain/job/job.service.js:116:37
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)
[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] Object:
{
  "id": "b3120de4-058e-46b0-951b-f2ac6ae0d5b3",
  "deferred": false
}

[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] Unable to run job handler (facialRecognition/facial-recognition): TypeError: Cannot read properties of null (reading 'ownerId')
[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] TypeError: Cannot read properties of null (reading 'ownerId')
    at PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:297:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /usr/src/app/dist/domain/job/job.service.js:116:37
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)
[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] Object:
{
  "id": "d34ff9e7-c2a6-4544-929f-348a0c44729e",
  "deferred": false
}

[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] Unable to run job handler (facialRecognition/facial-recognition): TypeError: Cannot read properties of null (reading 'ownerId')
[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] TypeError: Cannot read properties of null (reading 'ownerId')
    at PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:297:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /usr/src/app/dist/domain/job/job.service.js:116:37
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)
[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] Object:
{
  "id": "d0b908de-72b6-4b2d-bb8e-f163ba5e1c4a",
  "deferred": false
}

[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] Unable to run job handler (facialRecognition/facial-recognition): TypeError: Cannot read properties of null (reading 'ownerId')
[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] TypeError: Cannot read properties of null (reading 'ownerId')
    at PersonService.handleRecognizeFaces (/usr/src/app/dist/domain/person/person.service.js:297:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /usr/src/app/dist/domain/job/job.service.js:116:37
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)
[Nest] 7  - 01/28/2024, 9:11:33 PM   ERROR [JobService] Object:
{
  "id": "1a91c052-960d-4576-b867-f230bae52cb2",
  "deferred": false

Postgres output:

immich=# select assets.id, asset_faces."assetId",assets."deletedAt",asset_faces.id from assets join asset_faces on assets.id=asset_faces."assetId" where asset_faces.id = '43ef169c-af5c-4748-82a8-5e7ba28dc572' or asset_faces.id = 'b3120de4-058e-46b0-951b-f2ac6ae0d5b3' or asset_faces.id='d34ff9e7-c2a6-4544-929f-348a0c44729e' or asset_faces.id='d0b908de-72b6-4b2d-bb8e-f163ba5e1c4a' or asset_faces.id='1a91c052-960d-4576-b867-f230bae52cb2';
                  id                  |               assetId                |           deletedAt           |                  id
--------------------------------------+--------------------------------------+-------------------------------+--------------------------------------
 e23345c2-2cba-4499-a17f-4153f4ad103a | e23345c2-2cba-4499-a17f-4153f4ad103a | 2024-01-28 13:09:33.909605-05 | 43ef169c-af5c-4748-82a8-5e7ba28dc572
 b14ebe91-3420-45be-ac78-86b56c791296 | b14ebe91-3420-45be-ac78-86b56c791296 | 2024-01-28 13:15:43.272135-05 | b3120de4-058e-46b0-951b-f2ac6ae0d5b3
 b14ebe91-3420-45be-ac78-86b56c791296 | b14ebe91-3420-45be-ac78-86b56c791296 | 2024-01-28 13:15:43.272135-05 | d34ff9e7-c2a6-4544-929f-348a0c44729e
 b14ebe91-3420-45be-ac78-86b56c791296 | b14ebe91-3420-45be-ac78-86b56c791296 | 2024-01-28 13:15:43.272135-05 | d0b908de-72b6-4b2d-bb8e-f163ba5e1c4a
 b14ebe91-3420-45be-ac78-86b56c791296 | b14ebe91-3420-45be-ac78-86b56c791296 | 2024-01-28 13:15:43.272135-05 | 1a91c052-960d-4576-b867-f230bae52cb2
(5 rows)

immich=#