Skip to content
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

duplicate key value violates unique constraint "cardpicker_token_pkey" #50

Open
ners10100100 opened this issue Oct 13, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@ners10100100
Copy link

Hey. Anyone knows what this error is about? I don't know exactly how it happens, and it seems kind of random to me.
This is the output from docker-compose logs -f django:

django_1         | Finished crawling Male MPC Drive as of 1/31/2021.
django_1         | Traceback (most recent call last):
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 84, in _execute
django_1         |     return self.cursor.execute(sql, params)
django_1         | psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "cardpicker_token_pkey"
django_1         | DETAIL:  Key (id)=(1fcNPOh0ijnEEDcD7rC5m5M9klJ9k3W5M) already exists.
django_1         |
django_1         |
django_1         | The above exception was the direct cause of the following exception:
django_1         |
django_1         | Traceback (most recent call last):
django_1         |   File "manage.py", line 21, in <module>
django_1         |     main()
django_1         |   File "manage.py", line 17, in main
django_1         |     execute_from_command_line(sys.argv)
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
django_1         |     utility.execute()
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 413, in execute
django_1         |     self.fetch_command(subcommand).run_from_argv(self.argv)
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/core/management/base.py", line 354, in run_from_argv
django_1         |     self.execute(*args, **cmd_options)
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/core/management/base.py", line 398, in execute
django_1         |     output = self.handle(*args, **options)
django_1         |   File "/MPCAutofill/MPCAutofill/cardpicker/management/commands/update_database.py", line 348, in handle
django_1         |     search_folder(service, Source.objects.get(id=x), sources[x])
django_1         |   File "/MPCAutofill/MPCAutofill/cardpicker/management/commands/update_database.py", line 190, in search_folder
django_1         |     x[1].objects.bulk_create(x[0])
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/models/manager.py", line 85, in manager_method
django_1         |     return getattr(self.get_queryset(), name)(*args, **kwargs)
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 502, in bulk_create
django_1         |     returned_columns = self._batched_insert(
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 1287, in _batched_insert
django_1         |     inserted_rows.extend(self._insert(
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 1270, in _insert
django_1         |     return query.get_compiler(using=using).execute_sql(returning_fields)
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/models/sql/compiler.py", line 1416, in execute_sql
django_1         |     cursor.execute(sql, params)
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 66, in execute
django_1         |     return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
django_1         |     return executor(sql, params, many, context)
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 84, in _execute
django_1         |     return self.cursor.execute(sql, params)
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/utils.py", line 90, in __exit__
django_1         |     raise dj_exc_value.with_traceback(traceback) from exc_value
django_1         |   File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 84, in _execute
django_1         |     return self.cursor.execute(sql, params)
django_1         | django.db.utils.IntegrityError: duplicate key value violates unique constraint "cardpicker_token_pkey"
django_1         | DETAIL:  Key (id)=(1fcNPOh0ijnEEDcD7rC5m5M9klJ9k3W5M) already exists.
django_1         |
docker_django_1 exited with code 1

Any help is appreciated!

@fklemme
Copy link
Contributor

fklemme commented Oct 13, 2021

Just guessing here: You have two or more drives with the same key/id?

@ners10100100
Copy link
Author

No, I thought about that too, but I double checked!

@G3KK094
Copy link

G3KK094 commented Oct 13, 2021

Had the same problem. Also with the same ID 1fcNPOh0ijnEEDcD7rC5m5M9klJ9k3W5M.
I removed the male MPC drive from drives.csv.
Then it started without errors.

@ners10100100
Copy link
Author

Ok! I'll test this and report back if it helped! Thank you!

@ners10100100
Copy link
Author

So, I've removed male MPC drive but still the same issue. Here is my drives.csv:

key,drive_id,drive_public,description
nofacej,1xbWFU2bXCTit1Nvij2GIuzfTUVRVtf3N,,"1"
warpdandy01,170_LZjeOSMGEqXewrGF6laVEG-R3QZsc,,"2"
iderp,1fbVYpuh1slaRgPkHiV0Ra9DCzBXch_gE,,"3"
mtgRomanceLands,1kBFMLLn3kDVPK6Ctzzxs8AEWv3T1982W,,"4"
galtego,1cLOX8DPrwD01DcXwDIsnYBHaNo841Isb,,"5"
joshuaBirnholz,1Z0saK2t86Jjy46uJ3KiTYuX4bV22bJsq,,"6"
Darkpingouin,1KIzc6FLgQWq6iJFoJseX-xnHKLiJlRDa,,"7"
alexWolfe,1gXPzQdwFBupK-rSufGtZEjGvrYSVDjod,,"8"
bobUngus,1ALN654xsm2DP5M9ak_lI-nSwY5xdR7Yu,,"9"
kellieP,17FYnN8a6W2MciEpK6hx2W3o8vtAqihxc,,"10"
clearMoon,1bIVIzTo0ZsxHUFTig5Thl82rKY2jP3gf,,"11"
AmazonFire,1K3KK0EgyHNzttIKtv_TMF8nVdEjAubJd,,"12"
bitBeaker,1bkrWAjtIcE7eT9036EUW0u1iwwyM3KXx,,"13"
BazukiAlters,17whjecbdN1Z463FuEH5Lb7V28qph5pat,,"14"
JasonHensgens,1HhKlGCPFCGhCp7N8cPDuEZIlV-A_opHK,,"15"
moldyAce,1u89hTeF1VH5sJB4-b8ogSfZpNNDuDS7z,,"16"
geshman,1I0HR7m3nKZj4SlmgsgCE4pRhkhK3d0KH,,"17"
MattConstant,1PRVXMm_fZ_B2vCv57fpm-kbSzmgMFhgW,,"18"
kelpsk,1ezcj0JZ4qj9AjKZGZztvl6oMCepnx7H0,,"20"
DrDolathan,17PUQ4HUqeBRQ0PfF3iZaj-GKsfr8z9zf,,"21"
LLLulu-22,1rZ1UcgplwteU-Apo8G4lxHLomEKufrsG,,"22"
lichtlaerm,10CUCZOdrgI1gYJp7wfbN9eAcSsIdST2h,,"23"
purplexbatman,1v-AM8tDsKcXK4aLp4f0AztC4vhY5qs30,,"24"
BeardedBeowolf,1DiufSeltvZOi7fOU2aeaM6Ditvq2HYhb,,"25"
BananaPie,10A304Ne2g-DjYqE-zWMRMeem1lt8lTnB,,"26"
DonSinga,1bGuZuM9Ccol0I-1W6FJ3W0fB4gkUYqen,,"27"
ropes4u,1ykzhkOeybhqwjnfc08wWMX__lpJ3RgHr,,"28"
Haven_King,1E4zO82ZAYy0_BeOLzxNVUVBMOl1xvjli,,"29"
SnakeFatherJim,1v8e4tTAHxJ7tNjFq1Su5TbLQhE6yp2GV,,"30"
Smyris,1-zKMu1EvOMWiu9o3BmiEie7kS-2X1Bjn,,"31"
foo,1dUmU2hBiSmA4-GMYeXomys4O0JiKz3Rl,,"32"
baz,1Z5zFJ-r_PHmOgrl7-T4wqJ1PCIumtrXJ,,"33"

@ndepaola ndepaola added the bug Something isn't working label Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants