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 "jobs_job_name_key" #35

Closed
seamusabshere opened this issue Nov 29, 2022 · 1 comment
Closed

Comments

@seamusabshere
Copy link
Member

error inserting job caused by: duplicate key value violates unique constraint "jobs_job_name_key"

@emk
Copy link
Contributor

emk commented Dec 2, 2022

I looked at the code very closely, and I was initially baffled by this. Every place that creates jobs uses unique_kubernetes_job_name, which calls resource_tag and ThreadRng to generate a unique job suffix. And ThreadRng uses a cryptographic seed that supposedly uses kernel entropy.

But then I realized that we imitate the way that Kubernetes uses 5-character tags, which gives us only 36^5 = 60,466,176 possible tags.

Which means that after an estimated sqrt(36^5) = 7,776 jobs, we got bit by the Birthday paradox. Oops. Fortunately, this is an easy fix.

@emk emk closed this as completed in 7318273 Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants