question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate key violation

See original GitHub issue

Describe the bug When running multiple API instances in parallel, race conditions occur in the assignToChannels function throwing duplicate key violation errors.

To Reproduce Steps to reproduce the behavior:

  1. Run 2 API instances
  2. Create a Product on 1 API instance
  3. Simultaneously add a different ProductVariant to the Product on each API instance
  4. Sometimes the error will occur

Expected behavior The check and insert in the database should be an atomic operation

Environment (please complete the following information):

  • @vendure/core version: 1.0.2
  • Nodejs version: 14
  • Database: postgres

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
hendrik-advantitgecommented, Jun 25, 2021
0reactions
hendrik-advantitgecommented, Oct 29, 2021

Hi Michael, it’s been a while and we have not encountered this error recently and thus have not been able to provide you with more details. However the problem still exists as far as we know. Reading the blogpost on the release of Vendure 1.3, the new with transaction() reminded me of this issue. This might be the perfect occasion for it? If needed I can try to plan in some time to create a repo that reproduces this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Violation of PRIMARY KEY constraint. Cannot insert duplicate ...
Cannot insert duplicate key in object 'dbo. AC_Shipping_Addresses'. The duplicate key value is (165863).
Read more >
Hidden dangers of duplicate key violations in PostgreSQL and ...
The “duplicate key violates unique constraint” error notifies the caller that a retry is needed. This seems like an intuitive approach, ...
Read more >
How to solve violation of PRIMARY KEY constraint ...
If the key is an identity column it shouldn't cause duplicates unless someone has reseeded the counter. In such case reseeding the counter...
Read more >
Error "Violation of PRIMARY KEY constraint. Cannot insert ...
1. Duplicate the Selection you are working on - then start working on the copied Selection · 2. Create an In Filter and...
Read more >
Violation of PRIMARY KEY constraint - Microsoft Q&A
Violation of PRIMARY KEY constraint ... Cannot insert duplicate key in object 'dbo.Staff'. The duplicate key value is (42840)' error.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found