I
Immich•4w ago
Zeus

Files not being deleted despite > 30 days

Example file UUID: 0dc60527-2d1d-451c-89ba-106be84e3d45 visiting at https://immich.domain.tld/photos/0dc60527-2d1d-451c-89ba-106be84e3d45 shows the proper photos The original is able to be downloaded The filename in the sidebar does match the path on disk: upload/library/usernamehere/IMAGE/2022/04_partner_images_Apr/2022-04-16_T221817_IMG_5978__0dc60527-2d1d-451c-89ba-106be84e3d45.PNG Template runs with no errors:
[Nest] 7 - 04/02/2025, 4:13:50 PM LOG [Microservices:StorageTemplateService] Starting storage template migration
[Nest] 7 - 04/02/2025, 4:38:33 PM LOG [Microservices:StorageTemplateService] Finished storage template migration
[Nest] 7 - 04/02/2025, 4:44:21 PM LOG [Microservices:StorageTemplateService] Starting storage template migration
[Nest] 7 - 04/02/2025, 4:49:01 PM LOG [Microservices:StorageTemplateService] Finished storage template migration
[Nest] 7 - 04/02/2025, 4:13:50 PM LOG [Microservices:StorageTemplateService] Starting storage template migration
[Nest] 7 - 04/02/2025, 4:38:33 PM LOG [Microservices:StorageTemplateService] Finished storage template migration
[Nest] 7 - 04/02/2025, 4:44:21 PM LOG [Microservices:StorageTemplateService] Starting storage template migration
[Nest] 7 - 04/02/2025, 4:49:01 PM LOG [Microservices:StorageTemplateService] Finished storage template migration
/admin/repair page shows no offline or untracked files Storage template: {{filetypefull}}/{{y}}/{{#if album}}{{{album}}}{{else}}{{MM}}_{{MMM}}{{/if}}/{{y}}-{{MM}}-{{dd}}_T{{HH}}{{mm}}{{ss}}_{{{filename}}}__{{assetIdShort}}
60 Replies
Immich
Immich•4w ago
:wave: Hey @Zeus, Thanks for reaching out to us. Please carefully read this message and follow the recommended actions. This will help us be more effective in our support effort and leave more time for building Immich :immich:. References - Container Logs: docker compose logs docs - Container Status: docker ps -a docs - Reverse Proxy: https://immich.app/docs/administration/reverse-proxy - Code Formatting https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline#h_01GY0DAKGXDEHE263BCAYEGFJA Checklist I have... 1. :blue_square: verified I'm on the latest release(note that mobile app releases may take some time). 2. :blue_square: read applicable release notes. 3. :blue_square: reviewed the FAQs for known issues. 4. :blue_square: reviewed Github for known issues. 5. :blue_square: tried accessing Immich via local ip (without a custom reverse proxy). 6. :blue_square: uploaded the relevant information (see below). 7. :blue_square: tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable (an item can be marked as "complete" by reacting with the appropriate number) Information In order to be able to effectively help you, we need you to provide clear information to show what the problem is. The exact details needed vary per case, but here is a list of things to consider: - Your docker-compose.yml and .env files. - Logs from all the containers and their status (see above). - All the troubleshooting steps you've tried so far. - Any recent changes you've made to Immich or your system. - Details about your system (both software/OS and hardware). - Details about your storage (filesystems, type of disks, output of commands like fdisk -l and df -h). - The version of the Immich server, mobile app, and other relevant pieces. - Any other information that you think might be relevant. Please paste files and logs with proper code formatting, and especially avoid blurry screenshots. Without the right information we can't work out what the problem is. Help us help you ;) If this ticket can be closed you can use the /close command, and re-open it later if needed.
Daniel
Daniel•4w ago
Can you check the moves table?
Zeus
ZeusOP•4w ago
oooh wait they might be deleted šŸ™‚
Daniel
Daniel•4w ago
šŸ‘€
Zeus
ZeusOP•4w ago
wait why is the trash not emptying though? deletedAt | 2024-03-28 15:18:48.264227-04
Daniel
Daniel•4w ago
30 days At least by default
Zeus
ZeusOP•4w ago
yes.... that's about 370 days šŸ™‚
Daniel
Daniel•4w ago
Oh, 2024 Woops
Zeus
ZeusOP•4w ago
No description
Zeus
ZeusOP•4w ago
No description
Daniel
Daniel•4w ago
I overlooked the year, sorry
Zeus
ZeusOP•4w ago
you're good.
Daniel
Daniel•4w ago
Other nightly jobs are running? E.g. memory stuff?
Zeus
ZeusOP•4w ago
yep memories look good does the trashing command look for > 30 days or specifically 30? is it possible it got missed and now it's too old to find?
Daniel
Daniel•4w ago
We only filter on deletedAT
No description
Daniel
Daniel•4w ago
<= Just to verify; not a ro external lib?
Zeus
ZeusOP•4w ago
no, all internal
Daniel
Daniel•4w ago
Can you try manually deleting one? Ideally keeping an eye on logs
Zeus
ZeusOP•4w ago
immich=# select * from assets where id = '27771a44-ca9f-4baf-9041-a4fcbe3bdf33';
-[ RECORD 1 ]----+------------------------------------------------------------------------------------------------------------------------------
immich=# select * from assets where id = '27771a44-ca9f-4baf-9041-a4fcbe3bdf33';
(0 rows)
immich=# select * from assets where id = '27771a44-ca9f-4baf-9041-a4fcbe3bdf33';
-[ RECORD 1 ]----+------------------------------------------------------------------------------------------------------------------------------
immich=# select * from assets where id = '27771a44-ca9f-4baf-9041-a4fcbe3bdf33';
(0 rows)
it worked, no issues gone from disk as well
Daniel
Daniel•4w ago
And it's also gone from the fs now? Hmmm
Zeus
ZeusOP•4w ago
pre deletion DB, isOffline is false
immich=# select * from assets where id = '27771a44-ca9f-4baf-9041-a4fcbe3bdf33';
-[ RECORD 1 ]----+------------------------------------------------------------------------------------------------------------------------------
id | 27771a44-ca9f-4baf-9041-a4fcbe3bdf33
deviceAssetId | IMG_6030.PNG-114351
ownerId | c36ed9e6-26c9-4b89-b457-5b078897482d
deviceId | username---01-29
type | IMAGE
originalPath | upload/library/usernamehere/IMAGE/2022/05_partner_images_May/2022-05-13_T100803_IMG_6030__27771a44-ca9f-4baf-9041-a4fcbe3bdf33.PNG
fileCreatedAt | 2022-05-13 10:08:03-04
fileModifiedAt | 2022-05-13 10:08:03-04
isFavorite | f
duration |
encodedVideoPath |
checksum | \xd268c893a1533e36fb43bb9a40ed5c64fe4b5ba1
isVisible | t
livePhotoVideoId |
updatedAt | 2024-03-28 15:18:23.386854-04
createdAt | 2024-01-31 11:38:50.052137-05
isArchived | t
originalFileName | IMG_6030.PNG
sidecarPath |
thumbhash | \REDACTED
isOffline | f
libraryId |
isExternal | f
deletedAt | 2024-03-28 15:18:23.386854-04
localDateTime | 2022-05-13 10:08:03-04
stackId |
duplicateId |
status | active
updateId | 018e867f-c19a-75de-8c2e-de9b47191f98
immich=# select * from assets where id = '27771a44-ca9f-4baf-9041-a4fcbe3bdf33';
-[ RECORD 1 ]----+------------------------------------------------------------------------------------------------------------------------------
id | 27771a44-ca9f-4baf-9041-a4fcbe3bdf33
deviceAssetId | IMG_6030.PNG-114351
ownerId | c36ed9e6-26c9-4b89-b457-5b078897482d
deviceId | username---01-29
type | IMAGE
originalPath | upload/library/usernamehere/IMAGE/2022/05_partner_images_May/2022-05-13_T100803_IMG_6030__27771a44-ca9f-4baf-9041-a4fcbe3bdf33.PNG
fileCreatedAt | 2022-05-13 10:08:03-04
fileModifiedAt | 2022-05-13 10:08:03-04
isFavorite | f
duration |
encodedVideoPath |
checksum | \xd268c893a1533e36fb43bb9a40ed5c64fe4b5ba1
isVisible | t
livePhotoVideoId |
updatedAt | 2024-03-28 15:18:23.386854-04
createdAt | 2024-01-31 11:38:50.052137-05
isArchived | t
originalFileName | IMG_6030.PNG
sidecarPath |
thumbhash | \REDACTED
isOffline | f
libraryId |
isExternal | f
deletedAt | 2024-03-28 15:18:23.386854-04
localDateTime | 2022-05-13 10:08:03-04
stackId |
duplicateId |
status | active
updateId | 018e867f-c19a-75de-8c2e-de9b47191f98
this is the only log I got: [Nest] 7 - 04/02/2025, 5:13:11 PM LOG [Microservices:TrashService] Queued 1 asset(s) for deletion from the trash
Daniel
Daniel•4w ago
That's the one that worked successfully then, right? Can you verify if some of your assets get cleared from trash? Or is it just not clearing at all?
Zeus
ZeusOP•4w ago
that's the one that worked just now when I manually did it I think the trash overall is working fine.. it's mostly stuff I recognize from < 30 days can I mock the query to select the items? where does trashedBefore come from?
Daniel
Daniel•4w ago
We
const trashedBefore = DateTime.now()
.minus(Duration.fromObject({ days: trashedDays }))
.toJSDate();
const trashedBefore = DateTime.now()
.minus(Duration.fromObject({ days: trashedDays }))
.toJSDate();
which is then used in the
...
.where('assets.deletedAt', '<=', trashedBefore)
...
.where('assets.deletedAt', '<=', trashedBefore)
query Ah there you go lol trashedDays is the database config
Zeus
ZeusOP•4w ago
select * from assets where "deletedAt" <= '2024-12-31' and "isOffline" = 'f'; returns the 8 rows of interest so I think we might have an actual bug here
Daniel
Daniel•4w ago
Hmmm Let's walk through this https://github.com/immich-app/immich/blob/main/server/src/services/asset.service.ts So we get those assets back in 175 We push them all to the chunk array We call queueChunk() in 183
Zeus
ZeusOP•4w ago
should trashedDays be in the json from system_metadata.system-config ?
Daniel
Daniel•4w ago
We queue asset deletion for all those assets with deleteOnDisk: true -- this part we do all over the place, especially also when manually triggering it I don't recall exactly, if it's the default I think we don't save it We always fill up with defaults
Zeus
ZeusOP•4w ago
gotcha
Zeus
ZeusOP•4w ago
ok not the issue then, I don't have that json key in the DB
Daniel
Daniel•4w ago
And the query itself is also fine šŸ˜… There isn't this much more that can be wrong lol
Zeus
ZeusOP•4w ago
yep, query returns all files expected for deletion.. and the deletion dates do sound correct. it's not at all recent so it's not like it got re uploaded from the phone or something
Daniel
Daniel•4w ago
Yea I'm assuming there aren't any helpful logs from tonight?
Zeus
ZeusOP•4w ago
I can check in the morning. I check the logs pretty often and haven't seen anything. I don't think I have last night since it just upgraded to 1.131 I sort of doubt it given the manual delete worked fine
Daniel
Daniel•4w ago
The fact that the trash generally is clearing though is killing me šŸ˜… Which logging level do you have set atm?
Zeus
ZeusOP•4w ago
default, through journald I can increase the level for server and microservices
Daniel
Daniel•4w ago
Maybe just for tonight if that'd be fine for you I really don't have any idea right now šŸ˜… So weird
Zeus
ZeusOP•4w ago
yeah i'll do verbose and see wow that's a lot of logs lmao
Daniel
Daniel•4w ago
Yeah it really goes lol Alternatively... are you willing to run a dev instance against your prod db? šŸ‘€
Zeus
ZeusOP•4w ago
I’d just clone the database, which is fine But I’d need to clone the assets as well ?
Daniel
Daniel•4w ago
Only the relevant ones Was thinking about adding the asset cleanup job to that "job create" endpoint So that you can trigger that whenever you want to
sogan
sogan•4w ago
I keep forgetting... when was the status column supposed to be set to trashed or deleted and what did it mean if an asset is active but has a non-null deletedAt
Daniel
Daniel•4w ago
To more easily test I mean, we don't look at that column at all afaict
Zeus
ZeusOP•4w ago
Yeah I could just restore into a new database pretty easily
sogan
sogan•4w ago
We have .where('status', '=', AssetStatus.TRASHED) in the query no? And the JSON above has active
sogan
sogan•4w ago
I'm looking at this one. Is that not it?
Daniel
Daniel•4w ago
This is the one that's called when you click the empty trash button We queue this https://github.com/immich-app/immich/blob/main/server/src/services/asset.service.ts#L188 in the nightly job https://github.com/immich-app/immich/blob/main/server/src/services/job.service.ts#L223 Unless I am completely lost right now
Zeus
ZeusOP•4w ago
the files that are in the trash from more recently are indeed status = trashed..
Daniel
Daniel•4w ago
Yeah generally that should absolutely be the case, Mert is right with that
Zeus
ZeusOP•4w ago
all 8 old rows do have status = active
Daniel
Daniel•4w ago
But I don't think we care about that for the nightly cleanup, which is wrong
Zeus
ZeusOP•4w ago
[Nest] 7 - 04/02/2025, 11:33:59 PM DEBUG [Microservices:VersionService] Running version check
[Nest] 7 - 04/03/2025, 12:00:00 AM LOG [Microservices:LibraryService] Initiating scan of all external libraries...
[Nest] 7 - 04/03/2025, 12:00:00 AM LOG [Microservices:LibraryService] Checking for any libraries pending deletion...
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset 88866966-9e5e-4ad9-a2e4-7b6817085bba
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset 5f88ac0c-67dd-4711-9f3a-7ea3792420f6
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset d9796257-6ac4-486b-b8df-896bfed200b2
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset c4207729-6ef3-436c-ac62-4d6470460da7
[Nest] 7 - 04/03/2025, 12:00:00 AM ERROR [Microservices:{"id":"1286cdde-6e86-44e5-9754-48664d72bafe"}] Unable to run job handler (thumbnailGeneration/generate-thumbnails): Error: Input file has corrupt header: heif: Invalid input: No 'hvcC' box (2.106)
heif: Invalid input: No 'hvcC' box (2.106)
Error: Input file has corrupt header: heif: Invalid input: No 'hvcC' box (2.106)
<... more output, a few of these hvcc errors>
[Nest] 7 - 04/03/2025, 12:00:00 AM VERBOSE [Microservices:JobRepository] Waiting for undefined queue to stop...
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset c48b1246-6e17-4f84-ac08-18faabaaf4c1
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset dd5f1815-c546-4d77-8684-bc63a82e91c0
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset 0dc60527-2d1d-451c-89ba-106be84e3d45
[Nest] 7 - 04/02/2025, 11:33:59 PM DEBUG [Microservices:VersionService] Running version check
[Nest] 7 - 04/03/2025, 12:00:00 AM LOG [Microservices:LibraryService] Initiating scan of all external libraries...
[Nest] 7 - 04/03/2025, 12:00:00 AM LOG [Microservices:LibraryService] Checking for any libraries pending deletion...
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset 88866966-9e5e-4ad9-a2e4-7b6817085bba
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset 5f88ac0c-67dd-4711-9f3a-7ea3792420f6
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset d9796257-6ac4-486b-b8df-896bfed200b2
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset c4207729-6ef3-436c-ac62-4d6470460da7
[Nest] 7 - 04/03/2025, 12:00:00 AM ERROR [Microservices:{"id":"1286cdde-6e86-44e5-9754-48664d72bafe"}] Unable to run job handler (thumbnailGeneration/generate-thumbnails): Error: Input file has corrupt header: heif: Invalid input: No 'hvcC' box (2.106)
heif: Invalid input: No 'hvcC' box (2.106)
Error: Input file has corrupt header: heif: Invalid input: No 'hvcC' box (2.106)
<... more output, a few of these hvcc errors>
[Nest] 7 - 04/03/2025, 12:00:00 AM VERBOSE [Microservices:JobRepository] Waiting for undefined queue to stop...
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset c48b1246-6e17-4f84-ac08-18faabaaf4c1
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset dd5f1815-c546-4d77-8684-bc63a82e91c0
[Nest] 7 - 04/03/2025, 12:00:00 AM DEBUG [Microservices:StorageTemplateService] Cleaning up move history for asset 0dc60527-2d1d-451c-89ba-106be84e3d45
logs very bland, just a lot of face matching jobs after this wait... they got deleted lmao
Daniel
Daniel•4w ago
.......... I can't do this anymore :monakS:
Zeus
ZeusOP•4w ago
I don't understand wtf changed lol unless the first file that I manually deleted was somehow blocking the rest??
Daniel
Daniel•4w ago
You didn't change the status field by any chance?
Zeus
ZeusOP•4w ago
no I didn't touch the DB other than the queries
Daniel
Daniel•4w ago
Ok I really have no idea then šŸ˜… But it works! :peepoAwesome:
Zeus
ZeusOP•4w ago
šŸ¤·ā€ā™‚ļø

Did you find this page helpful?