immich icon indicating copy to clipboard operation
immich copied to clipboard

[BUG] Uploading to a new album misses a few images/videos

Open Caian opened this issue 1 year ago • 3 comments

The bug

When uploading a large number of files (600+) to a newly created album, Immich fails to add some of the files to the album.

The files were uploaded successfully, as they appear in the "Photos" section, they just weren't added to the album itself.

The OS that Immich Server is running on

TrueNAS-SCALE-22.12.3.2, Intel N500, 16 GB LPDDR5 RAM

Version of Immich Server

v1.66.1

Version of Immich Mobile App

v1.66.1

Platform with the issue

  • [ ] Server
  • [X] Web
  • [ ] Mobile

Your docker-compose.yml content

Not using docker-compose

Your .env content

TYPESENSE_ENABLED=false
IMMICH_WEB_URL=http://immich_web:3000
IMMICH_SERVER_URL=http://immich_server:3001
IMMICH_MACHINE_LEARNING_URL=http://immich_machine_learning:3003
TZ=America/Sao_Paulo

Reproduction steps

1. Click "create new album"
2. On the new album panel, drag and drop (or choose to upload from computer) a large number of files (600+)
3. Wait for the upload to finish
4. Refresh and check the number of files in the album
...

Additional information

No response

Caian avatar Jul 11 '23 13:07 Caian

I think this is an issue with using the web app to upload many photos at the same time. For bulk upload I suggest to use the CLI as it is more resource friendly

alextran1502 avatar Jul 11 '23 21:07 alextran1502

related to #3166. Thank you for reporting

alextran1502 avatar Jul 11 '23 21:07 alextran1502

I started uploading a few images at a time (around 10) and every once in a while, one or two images are not added to the album, so I have to open the full timeline and go look for it.

I see that upload notifications quickly pile up when uploading, so maybe the server is being overrun? I looked at the postgres logs, but haven't noticed anything wrong.

Caian avatar Jul 11 '23 22:07 Caian

This is most likely a race condition in immich/server/src/domain/album/album.service.ts > addAssets. Found this while looking for a way to batch requests to add assets to an album. You can easily reproduce this:

  1. Send a PUT request to the album endpoint with the following payload {"ids":[<VALID_ASSET_ID_HERE>, <10_THOUSAND_RANDOM_UUIDS_HERE>]}
  2. Add to album normally immediately after

When Nº 1 finishes, reload the album, you should see now that only 1 or 2 assets appear in the album.

The endpoint first loads the album with the assets, then processes the incoming IDs to then finally save the changes with the new album assets. If the album assets change because of another request during this period those changes will get overwritten. The easiest fix is to send a single request to the album with all asset IDs after uploading them all but if the upload stops midway for whatever reason no assets will get added.

valonsodev avatar Aug 30 '23 23:08 valonsodev

Same issue, some assets are often missing from the album when uploading from the web. They are correctly uploaded (visible in the photos) but not added correctly to the album.

olyrius avatar Sep 04 '23 18:09 olyrius

That's a good find. This endpoint isn't designed very well and needs to be reworked.

jrasm91 avatar Sep 04 '23 23:09 jrasm91