immich-app / immich

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

Inconsistant number of items in album #8348

Open chengguangnan opened 3 months ago

chengguangnan commented 3 months ago

The bug

I have a album which immich reported has 6478 items, but when I click the Select All button, after a processing delay, the web UI shows about 33k items selected.

By browser the timeline, it seems that all items are selected. So maybe there is is a counting error in considering how many items in an album?

I suspect that this is related to counting stacked Live Photo but I'm not sure. Moreover, by adding all the 33k selected items to a new albumn, immich will correctly report the new albumn has 33k items.

Screenshot:

Screenshot 2024-03-29 at 11 16 49 AM

The OS that Immich Server is running on

MacOS

Version of Immich Server

v1.100.0

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.
2.
3.
...

Additional information

No response

danieldietzler commented 2 months ago

Hey, could you check if that's still an issue? :)

chengguangnan commented 2 months ago

I upgraded to v1.102.3. Still see this in some albums.

Screenshot 2024-04-28 at 12 54 05 PM
danieldietzler commented 2 months ago

Ok @chengguangnan it would be awesome if you could test something for us: Following the guide in the docs, connect to the database. Then, run the following query:

SELECT COUNT(*) FROM albums_assets_assets AS a, assets AS b WHERE "a"."assetsId" = "b"."id" AND NOT "b"."isVisible"

and share the result with us, please. Thanks! :)

chengguangnan commented 2 months ago

@danieldietzler

immich=# SELECT COUNT(*) FROM albums_assets_assets AS a, assets AS b WHERE "a"."assetsId" = "b"."id" AND NOT "b"."isVisible"
immich-# ;
 count
-------
 28644
(1 row)
danieldietzler commented 2 months ago

Oh sorry I missed something. Can you try

SELECT COUNT(*) FROM albums_assets_assets AS a, assets AS b WHERE "a"."assetsId" = "b"."id" AND "a"."albumsId" = '<album id>' AND NOT "b"."isVisible"

by replacing <album id> with the album id of the album that issue occurs in? (the album id should be part of the URL and look something like 0b0d5697-3347-4900-9d41-6679079fc218)

chengguangnan commented 2 months ago

Hey @danieldietzler , yes, those invisible assets adds up!

3215 selected + 198 invisible = 3413 items.

Screenshot 2024-05-05 at 11 00 45 AM
danieldietzler commented 2 months ago

Thanks! Can you remove the COUNT? My guess is that those are all the motion (video) part of motion assets, so I'd like to verify/disprove that.

SELECT * FROM albums_assets_assets AS a, assets AS b WHERE "a"."assetsId" = "b"."id" AND "a"."albumsId" = '<album id>' AND NOT "b"."isVisible"
chengguangnan commented 2 months ago

Those are all videos. Here are some sample rows:

               albumsId               |               assetsId               |                  id                  |        deviceAssetId        |               ownerId                | deviceId | type  |                                           originalPath                                            |                                            previewPath                                             |       fileCreatedAt        |     fileModifiedAt     | isFavorite |   duration   |                                           thumbnailPath                                            | encodedVideoPath |                  checksum                  | isVisible | livePhotoVideoId |           updatedAt           |           createdAt           | isArchived |  originalFileName   |                                            sidecarPath                                            | isReadOnly |                  thumbhash                   | isOffline |              libraryId               | isExternal | deletedAt |       localDateTime        | stackId
175ce61a-6e96-43a4-8327-792897e3d987 | 01b92bca-901e-41a2-a0af-d3a525b85fe8 | 01b92bca-901e-41a2-a0af-d3a525b85fe8 | IMG_6464_083160.mov-2703967 | 56bfd748-c422-438e-9305-947a8825e78c | CLI      | VIDEO | upload/upload/56bfd748-c422-438e-9305-947a8825e78c/48/ee/48ee9fee-66b1-428c-a202-d21cfe6680bc.mov | upload/thumbs/56bfd748-c422-438e-9305-947a8825e78c/01/b9/01b92bca-901e-41a2-a0af-d3a525b85fe8.jpeg | 2019-02-08 00:15:14+00     | 2024-01-17 10:10:17+00 | f          | 00:00:02.635 | upload/thumbs/56bfd748-c422-438e-9305-947a8825e78c/01/b9/01b92bca-901e-41a2-a0af-d3a525b85fe8.webp |                  | \x09a1dcabe06e292979f02dc6b19b9355b91fcf1e | f         |                  | 2024-03-20 20:21:55.65237+00  | 2024-03-20 17:32:17.165474+00 | f          | IMG_6464_083160.mov |                                                                                                   | f          | \xe0f70d0d828988787f78777e877788758770780877 | f         | 14c86692-7fc3-4c1a-bd1e-1e1a87dc78dd | f          |           | 2019-02-07 14:15:14+00     
 175ce61a-6e96-43a4-8327-792897e3d987 | 039851a0-21ae-4426-a3f6-3bda47a81995 | 039851a0-21ae-4426-a3f6-3bda47a81995 | IMG_4976_084393.mov-1837443 | 56bfd748-c422-438e-9305-947a8825e78c | CLI      | VIDEO | upload/upload/56bfd748-c422-438e-9305-947a8825e78c/a4/00/a40057e8-6bd1-409a-ab44-41978c78bd07.mov | upload/thumbs/56bfd748-c422-438e-9305-947a8825e78c/03/98/039851a0-21ae-4426-a3f6-3bda47a81995.jpeg | 2019-02-01 02:31:10+00     | 2024-01-17 09:36:25+00 | f          | 00:00:02.018 | upload/thumbs/56bfd748-c422-438e-9305-947a8825e78c/03/98/039851a0-21ae-4426-a3f6-3bda47a81995.webp |                  | \x1a0c1926ed1e21a17f0ee15433c7979b1ff80250 | f         |                  | 2024-03-20 19:48:54.553698+00 | 2024-03-20 17:09:05.137319+00 | f          | IMG_4976_084393.mov |                                                                                                   | f          | \x5cf8050d02bb60cd859949678ab45a68d09ae292f8 | f         | 14c86692-7fc3-4c1a-bd1e-1e1a87dc78dd | f          |           | 2019-01-31 16:31:10+00     |
danieldietzler commented 2 months ago

And they are not visible, ok. Thanks for input! I think we should be able to work with that now :)