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
psycopg2.errors.UniqueViolation: duplicate key value error #297
Comments
If we do not run the celery worker in the background but wait until the demo data command is complete then this error does not occur. I can't put my finger out what exactly is going wrong here yet. |
I'm assigning myself on this one. |
This is a result of attempting to create multiple I don't understand the data model enough to determine the appropriate fix. @banesullivan is this actually a one to one correspondence, or can there be multiple |
This is a on-to-one correspondence in practice. An ResonantGeoData/rgd/geodata/models/imagery/etl.py Lines 121 to 123 in 998a6c3
This should only ever be called from This makes me think my helper, ResonantGeoData/rgd/utility.py Lines 163 to 170 in 998a6c3
Or one |
Perhaps it is time we do some sort of task auditing to make sure the ETL routines are all only launching one task per model |
Yes. I think we'll want to re-engineer a lot of this to make task launching more explicit. |
Uncovered what's going wrong here. It is a trivial typo fix. I added a signal wrapper ResonantGeoData/rgd/geodata/signals.py Lines 21 to 33 in 998a6c3
that checks if a model instance has an ResonantGeoData/rgd/geodata/management/commands/_data_helper.py Lines 45 to 46 in 998a6c3
which means two tasks are being launched for the You can see the
and calling the ETL routine explicitly here:
|
We should come up with a safer way to use this |
Turns out #299 didn't entirely fix this issue. |
When running the demo data commands that I have, if the celery worker is set up to run in the background, an integretiy error for duplicate keys happens on the
image_entry.save()
call here:ResonantGeoData/rgd/geodata/models/imagery/etl.py
Line 69 in 998a6c3
The error:
This is making me think that when we create a new
ImageEntry
in the tasks, there is some sort of race condition between jobs for the sameImageFile
... which shouldn't happen? I'm not really sure what is going on here.Steps to reproduce
docker-compose run --rm django ./manage.py migrate
docker-compose up celery
and wait until readydocker-compose run --rm django ./manage.py landsat_data -c 3
Error Message
The text was updated successfully, but these errors were encountered: