New photos not being added

I'm running the latest version as of today, although I think this problem started potentially a couple updates ago. Generate Thumbnails, extract metadata and scan external library jobs seem to be stuck. When I check the docker logs I see the below. I've attached my docker-compose.yml file. Unable to run job handler (LibrarySyncFiles): PostgresError: duplicate key value violates unique constraint "asset_ownerId_libraryId_checksum_idx" PostgresError: duplicate key value violates unique constraint "asset_ownerId_libraryId_checksum_idx" at ErrorResponse (/usr/src/app/server/node_modules/postgres/cjs/src/connection.js:794:26) at handle (/usr/src/app/server/node_modules/postgres/cjs/src/connection.js:480:6) at Socket.data (/usr/src/app/server/node_modules/postgres/cjs/src/connection.js:315:9) at Socket.emit (node:events:518:28) at addChunk (node:internal/streams/readable:561:12) at readableAddChunkPushByteMode (node:internal/streams/readable:512:3) at Readable.push (node:internal/streams/readable:392:5) at TCP.onStreamRead (node:internal/stream_base_commons:189:23)
42 Replies
Immich
Immich4d ago
:wave: Hey @Todd1561, 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. :ballot_box_with_check: verified I'm on the latest release(note that mobile app releases may take some time). 2. :ballot_box_with_check: read applicable release notes. 3. :ballot_box_with_check: reviewed the FAQs for known issues. 4. :ballot_box_with_check: reviewed Github for known issues. 5. :ballot_box_with_check: tried accessing Immich via local ip (without a custom reverse proxy). 6. :ballot_box_with_check: uploaded the relevant information (see below). 7. :ballot_box_with_check: 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. Successfully submitted, a tag has been added to inform contributors. :white_check_mark:
Mraedis
Mraedis4d ago
What's your env @Todd1561 ?
Todd1561
Todd1561OP4d ago
I don't have a separate env file
Mraedis
Mraedis4d ago
Yes you do or else this wouldn't work lol
Todd1561
Todd1561OP4d ago
@Mraedis i'm far from a docker expert but as far as I'm aware all my environment settings are specified in the docker compose file, like the upload location and DB username/pw. I've checked, I have no separate .env file in the immich docker folder, unless it's somewhere else. I'm also not sure why this would matter, the issue clearly seems to be an attempt to insert a duplicate record into a database. But I'm not sure how/why immich is trying to do that, was hoping someone familiar with the internal working could shed some light
F4mouZSt4r
F4mouZSt4r4d ago
You definetly have a .env file. Your Upload Location etc is not hard-coded in the docker-compose file - ${UPLOAD_LOCATION}:/usr/src/app/upload thats a variable which are defined in the .env file.
Todd1561
Todd1561OP4d ago
ok my bad, it was named just ".env" which apparently in linux means hide it from everything.
Mraedis
Mraedis4d ago
Yes. dotfiles are hidden by default
Todd1561
Todd1561OP4d ago
You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables The location where your uploaded files are stored UPLOAD_LOCATION=/immich/uploads The Immich version to use. You can pin this to a specific version like "v1.71.0" IMMICH_VERSION=release Connection secrets for postgres and typesense. You should change these to random passwords TYPESENSE_API_KEY=xxxx DB_PASSWORD=xxxx PUBLIC_LOGIN_PAGE_MESSAGE="Nelson Photos" The values below this line do not need to be changed ################################################################################### DB_HOSTNAME=immich_postgres DB_USERNAME=postgres DB_DATABASE_NAME=immich REDIS_HOSTNAME=immich_redis
Mraedis
Mraedis4d ago
And it matters because I want to weed out rookie mistakes
Todd1561
Todd1561OP4d ago
rookie mistakes, sounds like me lol the instance is only referencing a single, read-only external library. i don't do any uploading. but content is added to the library outside of immich
Mraedis
Mraedis4d ago
The good news is it's not a rookie error The bad news is, it's not a rookie error 🙁 Did you perhaps delete your external library at one point?
Todd1561
Todd1561OP4d ago
nope, nothings really changed in a long time
Mraedis
Mraedis4d ago
How many assets are in your external library ?
Todd1561
Todd1561OP4d ago
immich reports 33,500 photos and 1,700 videos
Mraedis
Mraedis4d ago
That doesn't seem like it's worth a quick reload Do you have a longer error log? One that has the asset ids perhaps
Todd1561
Todd1561OP4d ago
yes i have more detail. is there a best practice for pasting long code blocks here? sorry i don't use discord much
Mraedis
Mraedis4d ago
Just upload a text file, that's fastest
Mraedis
Mraedis4d ago
Could you go to /mnt/media/photos/kim/iPhone Photo Backup/2025/08/ and /mnt/media/photos/kim/iPhone Photo Backup/2025/07/ for me and check whether any of the files IMG_1809.HEIC IMG_1807.JPG IMG_1799.JPG IMG_1788.JPG IMG_1796.HEIC IMG_1798.JPG IMG_1795.JPG IMG_1794.JPG exist with duplicate names perhaps? for instance once as IMG_1794.JPG and another as IMG_1794.jpg Right there are 472 more items on that list 👀 I don't know how to convert \\x7f73e60a1a25deb149ab8c226c7587871d2438cbto an identifier here 🥲 @etnoy any wisdom to share? Would identical files with alternating caps names cause this error?
Todd1561
Todd1561OP4d ago
i don't see any duplicates, everything seems to be upper case. might be worth noting that these files are stored on a windows/NTFS file share, which isn't case-sensitive. So it shouldn't even allow duplicates like that
etnoy
etnoy4d ago
You can't have files that have alternating caps if you are anywhere near windows
Todd1561
Todd1561OP4d ago
yeah that's why i was trying to say, i don't think that's the issue here
etnoy
etnoy4d ago
Is this a new immich install?
Todd1561
Todd1561OP4d ago
no probably older than most, maybe a couple years?
etnoy
etnoy4d ago
Which version are you on now?
Todd1561
Todd1561OP4d ago
1.138.1, latest i think
etnoy
etnoy4d ago
You are hitting a db constraint which should never happen, it's a last defense in the code
Todd1561
Todd1561OP4d ago
should i pull the offending files from the external library, run a library scan, reintroduce them and scan again? but ultimately it seems like something in the upstream app code isn't catching some situation and it's falling to the rdbms to prevent bad data from being stored
etnoy
etnoy4d ago
Please turn on debug logging and post a more complete log
Todd1561
Todd1561OP4d ago
ok
etnoy
etnoy4d ago
When scanning
Todd1561
Todd1561OP4d ago
ok see attached. this is a fresh restart of the container with debug logging on. the sql constraint errors start around line 1025
Todd1561
Todd1561OP4d ago
might be worth noting that i only noticed this issue because the iOS app shows a bunch of broken images (exclamation mark thumbnails) for all these images. The web app just doesn't show them at all. So I wonder if there are others with this issue that just don't realize it because they only use the web app (not sure how android behaves)
etnoy
etnoy4d ago
As a test, can you create a new library and set the same settings and scan? There will be some duplication but let's see if the scan success You can later delete the new library
Todd1561
Todd1561OP4d ago
and just put the problematic photos in this new library i assume?
Mraedis
Mraedis4d ago
I think the idea here is to see whether the behaviour repeats with all the same import paths, so really a full copy You don't even need to copy if I understand it, just add a second library with the same path
Todd1561
Todd1561OP4d ago
well we're talking about 10's of thousands of files. isn't that going to balloon the DB even if we later delete the test library? once DBs allocate space they generally don't like to give it back without causing a lot of fragmentation
etnoy
etnoy3d ago
I think that's a non issue tbh
Todd1561
Todd1561OP3d ago
I'm still not thrilled with the idea of doubling up the DB so I wound up just doing what I outlined above. I removed the offending files (there were 44) from the external source, ran a rescan, reintroduced the files and ran another rescan as well as an extract metadata and generate thumbnails (running those 2 did seem to be necessary). I noted in the logs that immich recognized these images as existing assets that it "onlined" and when I refreshed the timeline they appeared as normal and not broken. Also no more SQL constraint errors in the logs. Sooo, I'm not sure what happened or if it'll happen again. If you want other details to try and chase down whatever bug there might be let me know
Mraedis
Mraedis3d ago
Alright thanks 🙂
Todd1561
Todd1561OP3d ago
no problem and thanks to you guys for helping out

Did you find this page helpful?