René's URL Explorer Experiment


Title: Duplicate name when creating a new workspace build (transition): `pq: duplicate key value violates unique constraint "workspace_builds_workspace_id_name_key"` · Issue #3038 · coder/coder · GitHub

Open Graph Title: Duplicate name when creating a new workspace build (transition): `pq: duplicate key value violates unique constraint "workspace_builds_workspace_id_name_key"` · Issue #3038 · coder/coder

X Title: Duplicate name when creating a new workspace build (transition): `pq: duplicate key value violates unique constraint "workspace_builds_workspace_id_name_key"` · Issue #3038 · coder/coder

Description: This is an issue we ran into CI, it's a rare occurrence but there's a non-zero chance it can happen to our users as well. Problem: When a new workspace build is created for an existing workspace (e.g. transition into deleted) a new (uniq...

Open Graph Description: This is an issue we ran into CI, it's a rare occurrence but there's a non-zero chance it can happen to our users as well. Problem: When a new workspace build is created for an existing workspace (e...

X Description: This is an issue we ran into CI, it's a rare occurrence but there's a non-zero chance it can happen to our users as well. Problem: When a new workspace build is created for an existing work...

Opengraph URL: https://github.com/coder/coder/issues/3038

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Duplicate name when creating a new workspace build (transition): `pq: duplicate key value violates unique constraint \"workspace_builds_workspace_id_name_key\"`","articleBody":"This is an issue we ran into CI, it's a rare occurrence but there's a non-zero chance it can happen to our users as well.\r\n\r\n**Problem:** When a new workspace build is created for an existing workspace (e.g. transition into deleted) a new (unique-ish) name is generated for that job via `namesgenerator.GetRandomName(1)`. Normally this should not be an issue, but we have a unique constraint on `(workspace_id, name)`:\r\n\r\n```sql\r\nALTER TABLE ONLY workspace_builds\r\n    ADD CONSTRAINT workspace_builds_workspace_id_name_key UNIQUE (workspace_id, name);\r\n```\r\n\r\nThis results in a non-zero chance that both the create job and delete job receive the same `name`, resulting in the conflict. For very long lived workspaces, the chance of hitting this issue becomes greater. I did a local test that reproduced this after running workspace start/stop 200 times.\r\n\r\nThe CI run that hit this issue: https://github.com/coder/coder/runs/7399324482?check_suite_focus=true\r\n\r\n```\r\n2022-07-18T22:52:32.7769558Z     workspaces_test.go:331: \r\n2022-07-18T22:52:32.7770135Z         \tError Trace:\t/home/runner/work/coder/coder/coderd/workspaces_test.go:331\r\n2022-07-18T22:52:32.7770615Z         \tError:      \tReceived unexpected error:\r\n2022-07-18T22:52:32.7772201Z         \t            \tPOST http://127.0.0.1:42617/api/v2/workspaces/9a172a87-b686-4a93-a286-70d473562375/builds: unexpected status code 500: Internal error inserting workspace build.\r\n2022-07-18T22:52:32.7773646Z         \t            \t\tError: execute transaction: insert workspace build: pq: duplicate key value violates unique constraint \"workspace_builds_workspace_id_name_key\"\r\n2022-07-18T22:52:32.7774246Z         \tTest:       \tTestWorkspaceByOwnerAndName/Deleted\r\n2022-07-18T22:52:32.7774730Z         \tMessages:   \tdelete the workspace\r\n2022-07-18T22:52:32.7775638Z     t.go:81: 2022-07-18 22:49:15.883 [DEBUG]\t(provisionerd)\t\u003cgithub.com/coder/coder/provisionerd/provisionerd.go:370>\t(*Server).closeWithError\tclosing server with error\t{\"error\": null}\r\n2022-07-18T22:52:32.7776288Z     --- FAIL: TestWorkspaceByOwnerAndName/Deleted (6.92s)\r\n2022-07-18T22:52:32.7776505Z \r\n2022-07-18T22:52:32.7776777Z make: *** [Makefile:175: test-postgres] Error 1\r\n```\r\n\r\n**Questions**\r\n- Is there a good reason to keep unique names for all workspace builds (and all transitions)?\r\n- Should we try a new name on conflict?","author":{"url":"https://github.com/mafredri","@type":"Person","name":"mafredri"},"datePublished":"2022-07-19T11:41:09Z","url":"https://github.com/coder/coder/issues/3038"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d84960c2-5ec2-f4e2-615d-93e9486caf76
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB0AE:3C21B:29D3595:356D4DA:6B0197B8
html-safe-nonceb70f8b3d30b903e853f5aa6f802ecccbd8d195f26f34bb5106e48a0064dbb403
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEFFOjNDMjFCOjI5RDM1OTU6MzU2RDREQTo2QjAxOTdCOCIsInZpc2l0b3JfaWQiOiIxMjYwNTUzNTg4NzAzMzM2Mzc2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac41369d053a1032205cfd5ca8beacaef20a30398126c68c9a02068637cfb39cf0
hovercard-subject-tagissue:1309393098
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/3038/issue_layout
twitter:imagehttps://opengraph.githubassets.com/125c45e97b302cbf2bd8fac5498aded3530dc03dd8008b2c6e143c2783ad18c3/coder/coder/issues/3038
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/125c45e97b302cbf2bd8fac5498aded3530dc03dd8008b2c6e143c2783ad18c3/coder/coder/issues/3038
og:image:altThis is an issue we ran into CI, it's a rare occurrence but there's a non-zero chance it can happen to our users as well. Problem: When a new workspace build is created for an existing workspace (e...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemafredri
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/coder/coder git https://github.com/coder/coder.git
octolytics-dimension-user_id95932066
octolytics-dimension-user_logincoder
octolytics-dimension-repository_id440752086
octolytics-dimension-repository_nwocoder/coder
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id440752086
octolytics-dimension-repository_network_root_nwocoder/coder
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/coder/coder/issues/3038#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcoder%2Fcoder%2Fissues%2F3038
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcoder%2Fcoder%2Fissues%2F3038
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=coder%2Fcoder
Reloadhttps://github.com/coder/coder/issues/3038
Reloadhttps://github.com/coder/coder/issues/3038
Reloadhttps://github.com/coder/coder/issues/3038
coderhttps://github.com/coder
coderhttps://github.com/coder/coder
Codehttps://github.com/coder/coder
Issues320 (320)https://github.com/coder/coder/issues
Pull requests470 (470)https://github.com/coder/coder/pulls
Discussionshttps://github.com/coder/coder/discussions
Actionshttps://github.com/coder/coder/actions
Projectshttps://github.com/coder/coder/projects
Security and quality49 (49)https://github.com/coder/coder/security
Insightshttps://github.com/coder/coder/insights
https://github.com/coder/coder
New issuehttps://github.com/login?return_to=https://github.com/coder/coder/issues/3038
New issuehttps://github.com/login?return_to=https://github.com/coder/coder/issues/3038
Duplicate name when creating a new workspace build (transition): pq: duplicate key value violates unique constraint "workspace_builds_workspace_id_name_key"https://github.com/coder/coder/issues/3038#top
apiArea: HTTP APIhttps://github.com/coder/coder/issues?q=state%3Aopen%20label%3A%22api%22
https://github.com/mafredri
mafredrihttps://github.com/mafredri
on Jul 19, 2022https://github.com/coder/coder/issues/3038#issue-1309393098
https://github.com/coder/coder/runs/7399324482?check_suite_focus=truehttps://github.com/coder/coder/runs/7399324482?check_suite_focus=true
mafredrihttps://github.com/mafredri
bughttps://github.com/coder/coder/issues?q=state%3Aopen%20label%3A%22bug%22
apiArea: HTTP APIhttps://github.com/coder/coder/issues?q=state%3Aopen%20label%3A%22api%22
on Jul 19, 2022https://github.com/coder/coder/issues/3038#event-7019936699
https://github.com/mafredri
mafredrihttps://github.com/mafredri
on Jul 20, 2022https://github.com/coder/coder/issues/3038#issuecomment-1190283608
https://github.com/coder/coder/runs/7429175788?check_suite_focus=truehttps://github.com/coder/coder/runs/7429175788?check_suite_focus=true
coder/cli/templatedelete_test.gohttps://github.com/coder/coder/blob/87b0b4b1ea77eabcec9669bda258936cc83b6519/cli/templatedelete_test.go#L60
87b0b4bhttps://github.com/coder/coder/commit/87b0b4b1ea77eabcec9669bda258936cc83b6519
coder/coderd/coderdtest/coderdtest.gohttps://github.com/coder/coder/blob/87b0b4b1ea77eabcec9669bda258936cc83b6519/coderd/coderdtest/coderdtest.go#L369
87b0b4bhttps://github.com/coder/coder/commit/87b0b4b1ea77eabcec9669bda258936cc83b6519
mafredrihttps://github.com/mafredri
on Jul 20, 2022https://github.com/coder/coder/issues/3038#event-7029519488
fix: Increase randomness for names used in testshttps://github.com/coder/coder/commit/b9e6e6366e15479fea04f1ddf53b0261184df024
b9e6e63https://github.com/coder/coder/commit/b9e6e6366e15479fea04f1ddf53b0261184df024
fix: Increase randomness for names used in tests (#3063)https://github.com/coder/coder/commit/cd74afcccc10355076da162ca9b4ba2b336eebff
#3063https://github.com/coder/coder/pull/3063
cd74afchttps://github.com/coder/coder/commit/cd74afcccc10355076da162ca9b4ba2b336eebff
https://github.com/spikecurtis
spikecurtishttps://github.com/spikecurtis
on Jul 20, 2022https://github.com/coder/coder/issues/3038#issuecomment-1190440939
#1561https://github.com/coder/coder/issues/1561
https://github.com/mafredri
mafredrihttps://github.com/mafredri
on Jul 20, 2022https://github.com/coder/coder/issues/3038#issuecomment-1190545486
@spikecurtishttps://github.com/spikecurtis
#1561https://github.com/coder/coder/issues/1561
coder/coderd/templateversions.gohttps://github.com/coder/coder/blob/87b0b4b1ea77eabcec9669bda258936cc83b6519/coderd/templateversions.go#L762
87b0b4bhttps://github.com/coder/coder/commit/87b0b4b1ea77eabcec9669bda258936cc83b6519
coder/coderd/provisionerdaemons.gohttps://github.com/coder/coder/blob/87b0b4b1ea77eabcec9669bda258936cc83b6519/coderd/provisionerdaemons.go#L69
87b0b4bhttps://github.com/coder/coder/commit/87b0b4b1ea77eabcec9669bda258936cc83b6519
#1561https://github.com/coder/coder/issues/1561
https://github.com/kylecarbs
kylecarbshttps://github.com/kylecarbs
on Aug 24, 2022https://github.com/coder/coder/issues/3038#issuecomment-1225999993
#1561https://github.com/coder/coder/issues/1561
kylecarbshttps://github.com/kylecarbs
not plannedhttps://github.com/coder/coder/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Anot-planned
on Aug 24, 2022https://github.com/coder/coder/issues/3038#event-7252810405
Sign up for freehttps://github.com/signup?return_to=https://github.com/coder/coder/issues/3038
Sign in to commenthttps://github.com/login?return_to=https://github.com/coder/coder/issues/3038
apiArea: HTTP APIhttps://github.com/coder/coder/issues?q=state%3Aopen%20label%3A%22api%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.