immich-app / immich

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

Failed do delete large albumns (more than 32k items) #9132

Open chengguangnan opened 2 weeks ago

chengguangnan commented 2 weeks ago

The bug

I have a few large albumns with more than 32k items each, created by cli.

I'm trying to delete them but failed to do so. See the error log below.

The OS that Immich Server is running on

MacOS

Version of Immich Server

1.102.3

Version of Immich Mobile App

n/a

Platform with the issue

Your docker-compose.yml content

default

Your .env content

default

Reproduction steps

Web UI -> Albumns -> Try to delete an large albumn

Relevant log output

("albumsId" = $77805 AND "assetsId" = $77806) OR ("albumsId" = $77807 AND "assetsId" = $77808) OR ("albumsId" = $77809 AND "assetsId" = $77810) OR ("albumsId" = $77811 AND "assetsId" = $77812) OR ("albumsId" = $77813 AND "assetsId" = $77814) OR ("albumsId" = $77815 AND "assetsId" = $77816) OR ("albumsId" = $77817 AND "assetsId" = $77818) OR ("albumsId" = $77819 AND "assetsId" = $77820) OR ("albumsId" = $77821 AND "assetsId" = $77822) OR ("albumsId" = $77823 AND "assetsId" = $77824) OR ("albumsId" = $77825 AND "assetsId" = $77826) OR ("albumsId" = $77827 AND "assetsId" = $77828) OR ("albumsId" = $77829 AND "assetsId" = $77830) OR ("albumsId" = $77831 AND "assetsId" = $77832) OR ("albumsId" = $77833 AND "assetsId" = $77834) OR ("albumsId" = $77835 AND "assetsId" = $77836) OR ("albumsId" = $77837 AND "assetsId" = $77838) OR ("albumsId" = $77839 AND "assetsId" = $77840) OR ("albumsId" = $77841 AND "assetsId" = $77842) OR ("albumsId" = $77843 AND "assetsId" = $77844) OR ("albumsId" = $77845 AND "assetsId" = $77846) OR ("albumsId" = $77847 AND "assetsId" = $77848) OR ("albumsId" = $77849 AND "assetsId" = $77850) OR ("albumsId" = $77851 AND "assetsId" = $77852) OR ("albumsId" = $77853 AND "assetsId" = $77854) OR ("albumsId" = $77855 AND "assetsId" = $77856) OR ("albumsId" = $77857 AND "assetsId" = $77858) OR ("albumsId" = $77859 AND "assetsId" = $77860) OR ("albumsId" = $77861 AND "assetsId" = $77862) OR ("albumsId" = $77863 AND "assetsId" = $77864))
immich_server            | [Nest] 7  - 04/28/2024, 5:53:29 AM   ERROR [QueryFailedError: bind message has 12328 parameter formats but 0 parameters
immich_server            |     at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
immich_server            |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
immich_server            |     at async DeleteQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/DeleteQueryBuilder.js:52:33)
immich_server            |     at async SubjectExecutor.executeRemoveOperations (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:461:17)
immich_server            |     at async SubjectExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:104:9)
immich_server            |     at async EntityPersistExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21)
immich_server            |     at async AlbumRepository.delete (/usr/src/app/dist/repositories/album.repository.js:219:9)
immich_server            |     at async AlbumService.delete (/usr/src/app/dist/services/album.service.js:145:9)] Failed to delete album
immich_server            | [Nest] 7  - 04/28/2024, 5:53:29 AM   ERROR [QueryFailedError: bind message has 12328 parameter formats but 0 parameters
immich_server            |     at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
immich_server            |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
immich_server            |     at async DeleteQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/DeleteQueryBuilder.js:52:33)
immich_server            |     at async SubjectExecutor.executeRemoveOperations (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:461:17)
immich_server            |     at async SubjectExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/SubjectExecutor.js:104:9)
immich_server            |     at async EntityPersistExecutor.execute (/usr/src/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21)
immich_server            |     at async AlbumRepository.delete (/usr/src/app/dist/repositories/album.repository.js:219:9)
immich_server            |     at async AlbumService.delete (/usr/src/app/dist/services/album.service.js:145:9)] QueryFailedError: bind message has 12328 parameter formats but 0 parameters
bo0tzz commented 2 weeks ago

Are you trying to delete the album itself, or did you select all the files and try to remove them from the album?

bo0tzz commented 2 weeks ago

The album service delete passes in a complete album object to the repository https://github.com/immich-app/immich/blob/2648032163806222c8c221ef5f822dc06568b9fd/server/src/services/album.service.ts#L162-L168 Perhaps this should just pass in the album ID and let the delete cascade properly?

chengguangnan commented 2 weeks ago

Are you trying to delete the album itself, or did you select all the files and try to remove them from the album?

I wasy trying to delete the album itself.