Files stuck in upload directory...?

Hey, so full disclosure, I was testing Immich and had just set it up on the laptop, and someone accidentally moved the harddisk that has all the data, temporarily unmounting it. I did the most reasonable thing and restarted the containers; my backups in the mobile app restarted and there were no weird error logs like I'd have expected given the entire drive was suddenly invisible to Immich.... great! But I noticed a huge discrepancy in the used storage (108 GB in Server Stats and 149 GB in the left sidebar). I checked and saw ~18GB of images and videos still in /upload/<uuid>/ folders. I tried manually starting the "encode videos" task from the UI as well as others, and left the server running for a day, and then restarted the server again... no dice. Any clue what's going on?
21 Replies
leaks-repaired
leaks-repairedOP2y ago
Bumping this, the issue still persists.
thomas
thomas2y ago
Have you looked at the jobs? Is anything marked as failed? Could you try running the storage migration job manually?
leaks-repaired
leaks-repairedOP2y ago
No job was marked as failed, and I still reran everything with the "pending" button. If there's a way to ensure Immich isn't planning to touch those files now, could I just move them somewhere else and import with the cli?
thomas
thomas2y ago
Sorry, did you rerun the "storage migration" job manually?
leaks-repaired
leaks-repairedOP2y ago
Yes.
jrasm91
jrasm912y ago
Any logs in the Immich microservices container when you run the job?
leaks-repaired
leaks-repairedOP2y ago
Sorry for the delay, but did manage to run the job again. Here's the only log I see: I ran the microservice twice.
Node.js v18.16.0
[Nest] 7 - 06/25/2023, 5:07:49 AM LOG [NestFactory] Starting Nest application...
[Nest] 7 - 06/25/2023, 5:07:49 AM LOG [InstanceLoader] TypeOrmModule dependencies initialized +36ms
{trimmed more initialization messages}
[Nest] 7 - 06/25/2023, 5:07:49 AM LOG [InstanceLoader] MicroservicesModule dependencies initialized +0ms
[Nest] 7 - 06/25/2023, 5:07:49 AM WARN [MetadataExtractionProcessor] Reverse geocoding is enabled
[Nest] 7 - 06/25/2023, 5:07:49 AM LOG [MetadataExtractionProcessor] Initializing Reverse Geocoding
[Nest] 7 - 06/25/2023, 5:08:16 AM LOG [MetadataExtractionProcessor] Reverse Geocoding Initialized
[Nest] 7 - 06/25/2023, 5:08:17 AM LOG [NestApplication] Nest application successfully started +73ms
[Nest] 7 - 06/25/2023, 5:08:17 AM LOG [ImmichMicroservice] Immich Microservices is listening on 3002 [v1.62.1] [PRODUCTION]
migrating-time: 25.069s
migrating-time: 25.545s
Node.js v18.16.0
[Nest] 7 - 06/25/2023, 5:07:49 AM LOG [NestFactory] Starting Nest application...
[Nest] 7 - 06/25/2023, 5:07:49 AM LOG [InstanceLoader] TypeOrmModule dependencies initialized +36ms
{trimmed more initialization messages}
[Nest] 7 - 06/25/2023, 5:07:49 AM LOG [InstanceLoader] MicroservicesModule dependencies initialized +0ms
[Nest] 7 - 06/25/2023, 5:07:49 AM WARN [MetadataExtractionProcessor] Reverse geocoding is enabled
[Nest] 7 - 06/25/2023, 5:07:49 AM LOG [MetadataExtractionProcessor] Initializing Reverse Geocoding
[Nest] 7 - 06/25/2023, 5:08:16 AM LOG [MetadataExtractionProcessor] Reverse Geocoding Initialized
[Nest] 7 - 06/25/2023, 5:08:17 AM LOG [NestApplication] Nest application successfully started +73ms
[Nest] 7 - 06/25/2023, 5:08:17 AM LOG [ImmichMicroservice] Immich Microservices is listening on 3002 [v1.62.1] [PRODUCTION]
migrating-time: 25.069s
migrating-time: 25.545s
leaks-repaired
leaks-repairedOP2y ago
Output of tree immich-app/data/
$ diff before-rerun.txt after-rerun.txt
{blank; no change in files}
$ diff before-rerun.txt after-rerun.txt
{blank; no change in files}
Clearly, this didn't help. :/
leaks-repaired
leaks-repairedOP2y ago
Should I attempt copying one of these files and then making the CLI 'bulk-upload' it? The hash would match, and that might trigger the entire import process again... I went ahead and did that. Here's what I've found so far: I copied 6 files to a temp-upload directory and ran immich upload --key {} --server {} temp-upload, which seemingly succeeded. Then, I checked the logs for the microservices container, which had a bunch of ffmpeg errors. These are the files I uploaded:
temp-upload
├── 18ffe1c7-61d1-4c3f-9cc8-bc97538f1e7b.jpg
├── 1a92f03b-c5e7-426f-8f3e-233b633a4e0f.mp4
├── 24b77981-e81c-4f92-98cb-9e7fd01c615d.mp4
├── 25a7e922-eb5f-4733-a66c-eec0001585dd.jpg
├── 2caf1cca-6a1e-4db1-9f53-ddd8335f47a1.jpg
└── 7a094ebc-aa57-4173-8478-bd471f115ffd.jpg

1 directory, 6 files
temp-upload
├── 18ffe1c7-61d1-4c3f-9cc8-bc97538f1e7b.jpg
├── 1a92f03b-c5e7-426f-8f3e-233b633a4e0f.mp4
├── 24b77981-e81c-4f92-98cb-9e7fd01c615d.mp4
├── 25a7e922-eb5f-4733-a66c-eec0001585dd.jpg
├── 2caf1cca-6a1e-4db1-9f53-ddd8335f47a1.jpg
└── 7a094ebc-aa57-4173-8478-bd471f115ffd.jpg

1 directory, 6 files
The ffmpeg errors were of the variety "moov atom not found", but crucially, they were on two files:
$ cat microservices-log.txt | grep "Invalid data"
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/54e67079-4120-4930-8971-4b9704de3a43.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/54e67079-4120-4930-8971-4b9704de3a43.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/efef0a1f-ced7-4b10-b477-dff92a033863.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/efef0a1f-ced7-4b10-b477-dff92a033863.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/54e67079-4120-4930-8971-4b9704de3a43.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/54e67079-4120-4930-8971-4b9704de3a43.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/efef0a1f-ced7-4b10-b477-dff92a033863.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/efef0a1f-ced7-4b10-b477-dff92a033863.mp4: Invalid data found when processing input
$ cat microservices-log.txt | grep "Invalid data"
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/54e67079-4120-4930-8971-4b9704de3a43.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/54e67079-4120-4930-8971-4b9704de3a43.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/efef0a1f-ced7-4b10-b477-dff92a033863.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/efef0a1f-ced7-4b10-b477-dff92a033863.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/54e67079-4120-4930-8971-4b9704de3a43.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/54e67079-4120-4930-8971-4b9704de3a43.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/efef0a1f-ced7-4b10-b477-dff92a033863.mp4: Invalid data found when processing input
upload/upload/9fdac9c2-c71a-468c-91f4-534d98ee1231/efef0a1f-ced7-4b10-b477-dff92a033863.mp4: Invalid data found when processing input
leaks-repaired
leaks-repairedOP2y ago
I'm slightly worried now cause there are some partially uploaded jpegs in there too:
leaks-repaired
leaks-repairedOP2y ago
No description
No description
leaks-repaired
leaks-repairedOP2y ago
Huh, this is very weird. So, all the images out of the 127 files in /upload that I randomly picked (~10ish), are all actually uploaded and showing up properly in the app, and their partially uploaded/currupt versions seem to be left here. In my test-upload experiment, this is what the identify check and the uploaded file look like:
$ identify -regard-warnings 18ffe1c7-61d1-4c3f-9cc8-bc97538f1e7b.jpg
18ffe1c7-61d1-4c3f-9cc8-bc97538f1e7b.jpg JPEG 4032x3024 4032x3024+0+0 8-bit sRGB 382227B 0.100u 0:00.102
identify: Premature end of JPEG file `18ffe1c7-61d1-4c3f-9cc8-bc97538f1e7b.jpg' @ warning/jpeg.c/JPEGWarningHandler/403.
identify: Corrupt JPEG data: premature end of data segment `18ffe1c7-61d1-4c3f-9cc8-bc97538f1e7b.jpg' @ warning/jpeg.c/JPEGWarningHandler/403.
$ identify -regard-warnings 18ffe1c7-61d1-4c3f-9cc8-bc97538f1e7b.jpg
18ffe1c7-61d1-4c3f-9cc8-bc97538f1e7b.jpg JPEG 4032x3024 4032x3024+0+0 8-bit sRGB 382227B 0.100u 0:00.102
identify: Premature end of JPEG file `18ffe1c7-61d1-4c3f-9cc8-bc97538f1e7b.jpg' @ warning/jpeg.c/JPEGWarningHandler/403.
identify: Corrupt JPEG data: premature end of data segment `18ffe1c7-61d1-4c3f-9cc8-bc97538f1e7b.jpg' @ warning/jpeg.c/JPEGWarningHandler/403.
leaks-repaired
leaks-repairedOP2y ago
No description
leaks-repaired
leaks-repairedOP2y ago
I'm totally hypothesizing here, but it seems that for some reason uploads failed, Immich correctly determined that those uploads didn't complete and then restarted the uploads. Then the new upload got a new UUID associated with it, but for some reason the app didn't clean-up the partially uploaded content. If I then forcefully reupload one of those partial files, it does get uploaded (as it should). Thus, the bug appears to be only in the clean-up process when for whatever reason an upload didn't complete. Thus, I can safely remove all the pending files in /upload Gonna wait now for you folks' input. /end
jrasm91
jrasm912y ago
Yes that makes sense. The app should delete files when they fail to upload. Although, I could see this happening if the server was restarted during an upload or something like that.
leaks-repaired
leaks-repairedOP2y ago
Hmm, maybe a start-up task to look for pending cleanups?
jrasm91
jrasm912y ago
Although it is hard to know for certain if you can ever auto delete anything
leaks-repaired
leaks-repairedOP2y ago
Correct me if I'm wrong but there is partial filtering support already.. exifInfo.make|model or smartInfo.objects|tags in the /api/search endpoint, when used with clip:true should essentially filter clip results with those exif filters?
jrasm91
jrasm912y ago
Yup there is API support for a lot of filtering already.
leaks-repaired
leaks-repairedOP2y ago
Oops, no clue how this ended up here. multiple discord windows lol

Did you find this page helpful?