immich-app / immich

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

Problem with thumbnail #14252

Open pulsar895 opened 2 days ago

pulsar895 commented 2 days ago

The bug

Hello,

I'm having a problem generating thumbnails for some of my photos.

For an jpg photo:

2024-11-20 13:39:47.413898+00:00[Nest] 16  - 11/20/2024, 2:39:47 PM   ERROR [Api:GlobalExceptionFilter~o0yus5d8] Unknown error: Error: ENOENT: no such file or directory, access 'upload/thumbs/1477367d-2781-40d0-9724-51da334a6900/44/47/4447b703-2123-4a36-98ea-965684bf8081-thumbnail.jpeg'
2024-11-20 13:39:47.413914+00:00Error: ENOENT: no such file or directory, access 'upload/thumbs/1477367d-2781-40d0-9724-51da334a6900/44/47/4447b703-2123-4a36-98ea-965684bf8081-thumbnail.jpeg'
2024-11-20 13:39:47.413928+00:00at async access (node:internal/fs/promises:605:10)
2024-11-20 13:39:47.413943+00:00at async sendFile (/usr/src/app/dist/utils/file.js:50:9)
2024-11-20 13:39:47.413958+00:00at async AssetMediaController.viewAsset (/usr/src/app/dist/controllers/asset-media.controller.js:58:9)
2024-11-20 13:39:47.413835+00:00Error: ENOENT: no such file or directory, access 'upload/thumbs/1477367d-2781-40d0-9724-51da334a6900/44/47/4447b703-2123-4a36-98ea-965684bf8081-thumbnail.jpeg'
2024-11-20 13:39:47.413854+00:00at async access (node:internal/fs/promises:605:10)
2024-11-20 13:39:47.413869+00:00at async sendFile (/usr/src/app/dist/utils/file.js:50:9)
2024-11-20 13:39:47.413883+00:00at async AssetMediaController.viewAsset (/usr/src/app/dist/controllers/asset-media.controller.js:58:9)

On filesystem:

# find . -name "*4447b703-2123-4a36-98ea-965684bf8081*"
./library/<user>/2020-10/4447b703-2123-4a36-98ea-965684bf8081.jpg

For an heic photo:

2024-11-20 13:48:41.784942+00:00[Nest] 16  - 11/20/2024, 2:48:41 PM   ERROR [Api:GlobalExceptionFilter~56x4v0pd] Unknown error: Error: ENOENT: no such file or directory, access 'upload/thumbs/1477367d-2781-40d0-9724-51da334a6900/33/34/3334d6bb-514b-406a-88b6-7bec19d4e368-thumbnail.jpeg'
2024-11-20 13:48:41.785025+00:00Error: ENOENT: no such file or directory, access 'upload/thumbs/1477367d-2781-40d0-9724-51da334a6900/33/34/3334d6bb-514b-406a-88b6-7bec19d4e368-thumbnail.jpeg'
2024-11-20 13:48:41.785052+00:00at async access (node:internal/fs/promises:605:10)
2024-11-20 13:48:41.785080+00:00at async sendFile (/usr/src/app/dist/utils/file.js:50:9)
2024-11-20 13:48:41.785114+00:00at async AssetMediaController.viewAsset (/usr/src/app/dist/controllers/asset-media.controller.js:58:9)

Here too I can find all the files in the filesystem :

# find . -name "*3334d6bb-514b-406a-88b6-7bec19d4e368*"
./library/<user>/2023-07/3334d6bb-514b-406a-88b6-7bec19d4e368.heic

I've already tried to regenerate the thumbnails by deleting the current folders and running the task via the webUI, but that didn't solve the problem.

Thank you for your help.

May the force be with you.

The OS that Immich Server is running on

TrueNAS 24.10/apps (docker)

Version of Immich Server

v1.120.2

Version of Immich Mobile App

v1.120.2build.2167

Platform with the issue

pulsar895 commented 1 day ago

I've just seen that when generating thumbnails, it fetches certain images from the upload/library/admin folder instead of upload/library/<user> :

[Nest] 7  - 11/20/2024, 3:19:33 PM   ERROR [Microservices:JobService] Unable to run job handler (thumbnailGeneration/generate-thumbnails): Error: Input file is missing: upload/library/admin/2024-05/7743609a-4911-418f-bcc6-30593ed3d425.png
[Nest] 7  - 11/20/2024, 3:19:33 PM   ERROR [Microservices:JobService] Error: Input file is missing: upload/library/admin/2024-05/7743609a-4911-418f-bcc6-30593ed3d425.png
    at Sharp.toBuffer (/usr/src/app/node_modules/sharp/lib/output.js:163:17)
    at MediaRepository.decodeImage (/usr/src/app/dist/repositories/media.repository.js:57:68)
    at MediaService.generateImageThumbnails (/usr/src/app/dist/services/media.service.js:158:63)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async MediaService.handleGenerateThumbnails (/usr/src/app/dist/services/media.service.js:108:25)
    at async JobService.onJobStart (/usr/src/app/dist/services/job.service.js:151:28)
    at async EventRepository.onEvent (/usr/src/app/dist/repositories/event.repository.js:122:13)
    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  - 11/20/2024, 3:19:33 PM   ERROR [Microservices:JobService] Object:
{
  "id": "7743609a-4911-418f-bcc6-30593ed3d425"
}
bo0tzz commented 1 day ago

On the initial post, the errors were about files in thumbs/ while the files you were showing to exist were in library/. For the second post, I assume you ran the job to regenerate all thumbnails? So it would be expected to also see jobs run for the admin user.

pulsar895 commented 1 day ago

I've actually restarted thumbnail generation but I'm getting several errors. I think there was a problem applying the Storage Template configuration. Some elements are still being searched for in the wrong places. Example:

[Nest] 7  - 11/20/2024, 3:48:53 PM   ERROR [Microservices:JobService] Unable to run job handler (thumbnailGeneration/generate-thumbnails): Error: Input file is missing: upload/library/alegall/2015/2015-10/4275a9e4-5110-47dc-b5cf-9e39053fd42b.jpg

The file is actually in another folder:

# find . -name "*4275a9e4-5110-47dc-b5cf-9e39053fd42b*"
./library/alegall/2015-10/4275a9e4-5110-47dc-b5cf-9e39053fd42b.jpg

Maybe I'll play with the database to fix that. Unless there's a better solution...

pulsar895 commented 1 day ago

I solved problem with some photos by doing a lot of DIY.

Display container logs during template migration:

$ sudo docker logs 7fadcf48b0c7 --follow --tail 0 | grep --line-buffered -i -E --color "Attempting to finish incomplete move:" | tee /tmp/immich.log

Use a script to correct the problem on SQL dump (dump create like that):

while read line; do
  origin=$(echo $line | awk -F'move: ' '{print $2}' | awk -F' => ' '{print $1}')
  target=$(echo $line | awk -F'move: ' '{print $2}' | awk -F' => ' '{print $2}')
  sed -i "s#${origin}#${target}#g" /mnt/immich/pgbackup/immich_2024-11-20_15-02-34.sql
done < /tmp/immich.log

Import dump into database. Display container logs during a new template migration:

$ sudo docker logs 7fadcf48b0c7 --follow --tail 0
[Nest] 66  - 11/20/2024, 4:08:57 PM     LOG [Api:EventRepository] Websocket Disconnect: qOeyku7_qXKNK7toAAAF
[Nest] 66  - 11/20/2024, 4:08:57 PM     LOG [Api:EventRepository] Websocket Connect:    esgNrBuKWPFNZrKuAAAH
[Nest] 7  - 11/20/2024, 4:09:00 PM     LOG [Microservices:StorageTemplateService] Starting storage template migration
[Nest] 7  - 11/20/2024, 4:09:16 PM     LOG [Microservices:StorageTemplateService] Finished storage template migration

This fixes many of the problems associated with thumbnail creation. I'll keep you posted.

pulsar895 commented 1 day ago

Others errors concern files that I cannot find on my filesystem with +1 suffix and some preview:

$ sudo docker logs 7fadcf48b0c7 --since 2024-11-20T16:27:00 2>&1 | grep "[Microservices:JobService] Error: Input file is missing:" | awk '{print $NF}' | tee /tmp/immich.log
[sudo] password for alegall: 
upload/library/alegall/2013-07/ada5d46b-ce6e-4ee2-8934-ab5308a5a200+1.JPG
upload/library/alegall/2024-05/a629c71e-149a-485e-9050-6cdf484c9636+1.jpeg
[...]
upload/thumbs/bde8ed12-7146-4421-aaf2-3176b461ae40/b5/11/b511ae5d-2e93-4609-8556-f2f43c7325f2-preview.jpeg
upload/thumbs/bde8ed12-7146-4421-aaf2-3176b461ae40/b5/11/b511ae5d-2e93-4609-8556-f2f43c7325f2-preview.jpeg
bo0tzz commented 1 day ago

This is all pretty odd. Have you messed with the database in the past?

pulsar895 commented 1 day ago

This is all pretty odd. Have you messed with the database in the past?

I had to restore the database not long ago, but I didn't have any errors at the time.


I've tried to generate thumbnails again and I'm still having problems with files that I can't find on my filesystem:

$ sudo docker logs 7fadcf48b0c7 --since 2024-11-20T16:27:00 2>&1 | grep "[Microservices:JobService] Error: Input file is missing:" | awk '{print $NF}' | tee /tmp/immich.log
[sudo] password for <user>: 
upload/library/<user>/2013-07/ada5d46b-ce6e-4ee2-8934-ab5308a5a200+1.JPG
upload/library/<user>/2024-05/a629c71e-149a-485e-9050-6cdf484c9636+1.jpeg
[...]
upload/thumbs/bde8ed12-7146-4421-aaf2-3176b461ae40/b5/11/b511ae5d-2e93-4609-8556-f2f43c7325f2-preview.jpeg
upload/thumbs/bde8ed12-7146-4421-aaf2-3176b461ae40/b5/11/b511ae5d-2e93-4609-8556-f2f43c7325f2-preview.jpeg