[BUG] EntityNotFoundError: Could not find any entity of type "AssetEntity" matching #490

Closed
opened 2026-02-04 20:49:22 +03:00 by OVERLORD · 11 comments
Owner

Originally created by @xxyzz on GitHub (Dec 19, 2022).

Describe the bug
I use the IOS app to backup photo but the app stuck at 154 assets, then I check the "immich-app_immich-server_1" container log and find many "EntityNotFoundError":

EntityNotFoundError: Could not find any entity of type "AssetEntity" matching:
    "where": {
        "userId": "x",
        "checksum": {
            "type": "Buffer",
             "data": [
                235,
                5,
                134,
                1,              
                233,
                113,            
                9,              
                187,            
                112,
                101,
                218,            
                118,            
                219,         
                120,
                148,
                110,
                80,
                62,
                10,
                59
            ]
        }
    },
    "relations": [
        "exifInfo"
    ]
}
    at /usr/src/app/node_modules/typeorm/entity-manager/EntityManager.js:590:39
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async AssetService.handleUploadedAsset (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/asset/asset.service.js:95:38)

And the "immich_postgres" container log has many duplicate key errors:

2022-12-19 07:09:31.441 UTC [66] ERROR:  duplicate key value violates unique constraint "UQ_userid_checksum"
2022-12-19 07:09:31.441 UTC [66] DETAIL:  Key ("userId", checksum)=(543e65cc-5df3-47f6-80bc-0110c0c195c8, \xebd2cfb5386e7cfca3016e6ef6ebf6851fa57544) already exists.
2022-12-19 07:09:31.441 UTC [66] STATEMENT:  INSERT INTO "assets"("id", "deviceAssetId", "userId", "deviceId", "type", "originalPath", "resizePath", "webpPath", "encodedVideoPath", "createdAt", "modifiedAt", "isFavorite", "mimeType", "checksum", "duration", "isVisible", "livePhotoVideoId") VALUES (DEFAULT, $1, $2, $3, $4, $5, DEFAULT, DEFAULT, DEFAULT, $6, $7, $8, $9, $10, $11, $12, $13) RETURNING "id", "webpPath", "encodedVideoPath", "isFavorite", "isVisible"

I didn't changed the docker-compose file and I only change the UPLOAD_LOCATION and JWT_SECRET variables in .env file. Before backup file on my phone, I used the cli to upload some files and one file got 504 error then I rerun the command it was uploaded successfully.

Server OS: Arch Linux
Podman version: 4.3.1

Task List

Please complete the task list below. We need this information to help us reproduce the bug or point out problems in your setup. You are not providing enough info may delay our effort to help you.

  • I have read thoroughly the README setup and installation instructions.
  • I have included my docker-compose file.
  • I have included my redacted .env file.
  • I have included information on my machine, and environment.

To Reproduce
Steps to reproduce the behavior:

  1. Use immich cli to upload some files.
  2. Backup photos from phone.

Expected behavior
Backup all photos.

Screenshots

System

  • Phone OS [iOS]: 16.2
  • Server Version: v1.38.2
  • Mobile App Version: v1.38.0

Additional context
Add any other context about the problem here.

Originally created by @xxyzz on GitHub (Dec 19, 2022). <!-- Note: Please search to see if an issue already exists for the bug you encountered. --> **Describe the bug** I use the IOS app to backup photo but the app stuck at 154 assets, then I check the "immich-app_immich-server_1" container log and find many "EntityNotFoundError": ``` EntityNotFoundError: Could not find any entity of type "AssetEntity" matching: "where": { "userId": "x", "checksum": { "type": "Buffer", "data": [ 235, 5, 134, 1, 233, 113, 9, 187, 112, 101, 218, 118, 219, 120, 148, 110, 80, 62, 10, 59 ] } }, "relations": [ "exifInfo" ] } at /usr/src/app/node_modules/typeorm/entity-manager/EntityManager.js:590:39 at runMicrotasks (<anonymous>) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async AssetService.handleUploadedAsset (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/asset/asset.service.js:95:38) ``` And the "immich_postgres" container log has many duplicate key errors: ``` 2022-12-19 07:09:31.441 UTC [66] ERROR: duplicate key value violates unique constraint "UQ_userid_checksum" 2022-12-19 07:09:31.441 UTC [66] DETAIL: Key ("userId", checksum)=(543e65cc-5df3-47f6-80bc-0110c0c195c8, \xebd2cfb5386e7cfca3016e6ef6ebf6851fa57544) already exists. 2022-12-19 07:09:31.441 UTC [66] STATEMENT: INSERT INTO "assets"("id", "deviceAssetId", "userId", "deviceId", "type", "originalPath", "resizePath", "webpPath", "encodedVideoPath", "createdAt", "modifiedAt", "isFavorite", "mimeType", "checksum", "duration", "isVisible", "livePhotoVideoId") VALUES (DEFAULT, $1, $2, $3, $4, $5, DEFAULT, DEFAULT, DEFAULT, $6, $7, $8, $9, $10, $11, $12, $13) RETURNING "id", "webpPath", "encodedVideoPath", "isFavorite", "isVisible" ``` I didn't changed the `docker-compose` file and I only change the `UPLOAD_LOCATION` and `JWT_SECRET` variables in `.env` file. Before backup file on my phone, I used the cli to upload some files and one file got 504 error then I rerun the command it was uploaded successfully. Server OS: Arch Linux Podman version: 4.3.1 **Task List** *Please complete the task list below. We need this information to help us reproduce the bug or point out problems in your setup. You are not providing enough info may delay our effort to help you.* - [x] I have read thoroughly the README setup and installation instructions. - [x] I have included my `docker-compose` file. - [x] I have included my redacted `.env` file. - [x] I have included information on my machine, and environment. **To Reproduce** Steps to reproduce the behavior: 1. Use immich cli to upload some files. 2. Backup photos from phone. **Expected behavior** Backup all photos. **Screenshots** **System** - Phone OS [iOS]: `16.2` - Server Version: `v1.38.2` - Mobile App Version: `v1.38.0` **Additional context** Add any other context about the problem here.
Author
Owner

@bo0tzz commented on GitHub (Dec 19, 2022):

It seems like you're on a very old version of Immich. Please update both the server and the app.

@bo0tzz commented on GitHub (Dec 19, 2022): It seems like you're on a very old version of Immich. Please update both the server and the app.
Author
Owner

@xxyzz commented on GitHub (Dec 19, 2022):

Oh I type the wrong version number... I'm using the latest version.

@xxyzz commented on GitHub (Dec 19, 2022): Oh I type the wrong version number... I'm using the latest version.
Author
Owner

@alextran1502 commented on GitHub (Dec 19, 2022):

If you restart the upload, would it still get stuck at that specific file? Are you accesing Immich through your local IP or through a reverse proxy?

The duplication error can be ignored assuming that the files you uploaded from the CLI are the exact same files from your phone, or you have duplicated files when uploading from either the CLI or your phone.

The AssetEntity not found perhaps not related to the issue you are facing, can you try uploading again while looking at the server log to make sure the timestamp of the log matches the upload operation

@alextran1502 commented on GitHub (Dec 19, 2022): If you restart the upload, would it still get stuck at that specific file? Are you accesing Immich through your local IP or through a reverse proxy? The duplication error can be ignored assuming that the files you uploaded from the CLI are the exact same files from your phone, or you have duplicated files when uploading from either the CLI or your phone. The AssetEntity not found perhaps not related to the issue you are facing, can you try uploading again while looking at the server log to make sure the timestamp of the log matches the upload operation
Author
Owner

@xxyzz commented on GitHub (Dec 19, 2022):

The remainder assets number is always 154 and the uploading file info stops at the same file. I have some photos backed up by Nextcloud before, but Nextcloud breaks the HEIC file to jpeg and mov file. I add those Nextcloud photos via the immch cli command before using the app, maybe the server think they are the same but not the app?

I access immich though local IP.

I'm still seeing the same errors in the logs.

@xxyzz commented on GitHub (Dec 19, 2022): The remainder assets number is always 154 and the uploading file info stops at the same file. I have some photos backed up by Nextcloud before, but Nextcloud breaks the HEIC file to jpeg and mov file. I add those Nextcloud photos via the immch cli command before using the app, maybe the server think they are the same but not the app? I access immich though local IP. I'm still seeing the same errors in the logs.
Author
Owner

@alextran1502 commented on GitHub (Dec 19, 2022):

@xxyzz Hmm, Immich handles LivePhotos by uploading the HEIC and the MOV portion to the server. I think this might conflict with the MOV files you are backing up from NextCloud.

Can you help me test the hypothesis by creating a new instance, then uploading the photos from your mobile phone before running the CLI?

@alextran1502 commented on GitHub (Dec 19, 2022): @xxyzz Hmm, Immich handles LivePhotos by uploading the HEIC and the MOV portion to the server. I think this *might* conflict with the MOV files you are backing up from NextCloud. Can you help me test the hypothesis by creating a new instance, then uploading the photos from your mobile phone before running the CLI?
Author
Owner

@alextran1502 commented on GitHub (Dec 19, 2022):

Note for me. This might be the source of the problem. There is no catch block for this awaiting call. Ideally, this should not fail because there is a duplicated with the same hash

8998a79ff9/server/apps/immich/src/api-v1/asset/asset.service.ts (L171-L175)

@alextran1502 commented on GitHub (Dec 19, 2022): Note for me. This might be the source of the problem. There is no catch block for this awaiting call. Ideally, this should not fail because there is a duplicated with the same hash https://github.com/immich-app/immich/blob/8998a79ff9c33bd71d7c81107874bb6a7a845d22/server/apps/immich/src/api-v1/asset/asset.service.ts#L171-L175
Author
Owner

@xxyzz commented on GitHub (Dec 19, 2022):

I delete those jpeg and mov files from immich's web page and the app uploads all the photos successfully. I'm pretty sure the Nextcloud's mov files cause the error. I'll consider the issue resolved since it's caused by previous backup files from Nextcloud.

@xxyzz commented on GitHub (Dec 19, 2022): I delete those jpeg and mov files from immich's web page and the app uploads all the photos successfully. I'm pretty sure the Nextcloud's mov files cause the error. I'll consider the issue resolved since it's caused by previous backup files from Nextcloud.
Author
Owner

@xxyzz commented on GitHub (Dec 19, 2022):

I find another bug in the app. Click a thumbnail then swift to the right from the left of the screen to return to the grid view. The app will turn to a black screen when I repeat this the third time.

Please ignore this comment, I can't reproduce this anymore.

And thank you for maintaining this amazing project, keep up the good work!

@xxyzz commented on GitHub (Dec 19, 2022): ~I find another bug in the app. Click a thumbnail then swift to the right from the left of the screen to return to the grid view. The app will turn to a black screen when I repeat this the third time.~ Please ignore this comment, I can't reproduce this anymore. And thank you for maintaining this amazing project, keep up the good work!
Author
Owner

@JustAmply commented on GitHub (Feb 21, 2023):

I've got the same issue after importing (around 150.000) images from my nextcloud library via the cli tool.
Already imported images are stuck in the upload queue of the iOS app.
They are repeatedly being uploaded, as they don't get marked as a duplicate when the error is thrown.

@JustAmply commented on GitHub (Feb 21, 2023): I've got the same issue after importing (around 150.000) images from my nextcloud library via the cli tool. Already imported images are stuck in the upload queue of the iOS app. They are repeatedly being uploaded, as they don't get marked as a duplicate when the error is thrown.
Author
Owner

@gemagomez commented on GitHub (Mar 4, 2023):

We've seen this same issue as well, but with a regular import from the iOS app, on a freshly installed v1.50.1 server. It happened when the microservices container (I believe) was OOM killed. Immich doesn't seem to cope too gracefully with temporary failures, and that seems to result in corruption in the database vs filesystem/object storage.

@gemagomez commented on GitHub (Mar 4, 2023): We've seen this same issue as well, but with a regular import from the iOS app, on a freshly installed v1.50.1 server. It happened when the microservices container (I believe) was OOM killed. Immich doesn't seem to cope too gracefully with temporary failures, and that seems to result in corruption in the database vs filesystem/object storage.
Author
Owner

@SMAW commented on GitHub (Mar 14, 2023):

Having the same issue also, cannot even delete pictures anymore on webpage. Also the pictures that aren't uploaded yet, because of the error are not visable...

@SMAW commented on GitHub (Mar 14, 2023): Having the same issue also, cannot even delete pictures anymore on webpage. Also the pictures that aren't uploaded yet, because of the error are not visable...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#490