-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug / Race condition when adding assets via the python API #15354
Comments
Thank you for the information. When you cannot view a certain photo, do you know if the jobs have finished running? We use a queue system so regardless of how many photos get uploaded, they should be processed in order |
Yes, I checked that. All the queues were complete. I also tried re-running what queues that I could from the UI. |
Our CLI does a multithreaded upload and we've never had any issues around that. |
Yea, I unfortunately don't have a good explanation for what happened. I'm pretty new to Immich and don't have a good grasp on the internals. I was only able to detect the issue because I still had both accounts active and was able to manually check some of the files. Some additional details that I forgot to mention:
|
The bug
I ran into what I suspect is some kind of race condition with the postgres database in immich when adding assets too rapidly.
What I was doing:
My wife and I had separate accounts, but we want to share facial recognition, so I decided to have us both use my account. To migrate her photos into my account, I wrote the python code below. The code first went through and downloaded all of her assets. I then uploaded them into my account with 3 threads.
What went wrong:
All of the files made it into my account, however some were not viewable from the immich webpage or app. I checked some of the images/videos that wouldn't show up (I could find them because I had a copy of everything under my wife's account), and verified that the files were indeed where they should be. Trying to upload the file again would give the duplicate file error.
How I fixed it:
In the end, I wrote code to delete and re-upload all of the files, this time without using threads. This resulted in a different set of photos being missing, which is what lead me to believe there is a race condition type error. I then deleted and re-uploaded them a second time, this time with a sleep command in-between the steps. This finally resulted in a successful upload.
Python code:
Base functions/etc:
Initial upload (That had the issue):
First fix attempt (that also had the issue):
Final fix that worked:
The OS that Immich Server is running on
Unraid 7.0.0 via Docker
Version of Immich Server
v1.123.0
Version of Immich Mobile App
v1.124.2
Platform with the issue
Your docker-compose.yml content
Not sure how to display this. I added this via the unraid managed feature.
Your .env content
Reproduction steps
described above
Relevant log output
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: