René's URL Explorer Experiment


Title: database race on create build / acquire job · Issue #2436 · coder/coder · GitHub

Open Graph Title: database race on create build / acquire job · Issue #2436 · coder/coder

X Title: database race on create build / acquire job · Issue #2436 · coder/coder

Description: Summary: Our current postgres code that handles creating builds and sending them out to provisionerd is subtly bugged from an ACID standpoint, and results in provisionerd failing to acquire a job. Details: I'm hitting this error in the T...

Open Graph Description: Summary: Our current postgres code that handles creating builds and sending them out to provisionerd is subtly bugged from an ACID standpoint, and results in provisionerd failing to acquire a job. ...

X Description: Summary: Our current postgres code that handles creating builds and sending them out to provisionerd is subtly bugged from an ACID standpoint, and results in provisionerd failing to acquire a job. ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"database race on create build / acquire job","articleBody":"**Summary**:  Our current postgres code that handles creating builds and sending them out to provisionerd is subtly bugged from an ACID standpoint, and results in provisionerd failing to acquire a job.\r\n\r\n**Details**:\r\n\r\nI'm hitting this error in the `TestDelete` CLI test.\r\n\r\n```\r\n    t.go:81: 2022-06-16 18:41:25.096 [DEBUG]\t\u003cgithub.com/coder/coder/coderd/coderd.go:382>\tdebugLogRequest.func1.1\tPOST /api/v2/workspaces/7138ac7f-4cbc-49d0-a772-aa2420a0e91d/builds\r\n    t.go:81: 2022-06-16 18:41:25.097 [DEBUG]\t(provisionerd-lucid_ptolemy4)\t\u003cgithub.com/coder/coder/coderd/provisionerdaemons.go:154>\t(*provisionerdServer).AcquireJob\tlocked job from database\t{\"id\": \"da766fb0-6e98-4a92-892b-a0565570d3cd\"}\r\n    t.go:81: 2022-06-16 18:41:25.097 [WARN]\t(provisionerd)\t\u003cgithub.com/coder/coder/provisionerd/provisionerd.go:232>\t(*Server).acquireJob\tacquire job ...\r\n        \"error\": request job was invalidated: get workspace build: sql: no rows in result set\r\n                 \tstorj.io/drpc/drpcwire.UnmarshalError:26\r\n                 \tstorj.io/drpc/drpcstream.(*Stream).HandlePacket:198\r\n                 \tstorj.io/drpc/drpcmanager.(*Manager).manageReader:211\r\n    t.go:81: 2022-06-16 18:41:25.097 [DEBUG]\t\u003cgithub.com/coder/coder/coderd/coderd.go:382>\tdebugLogRequest.func1.1\tGET /api/v2/workspacebuilds/f3e2c1b9-4948-4fbc-8d94-e399ba09ded4\r\n    t.go:81: 2022-06-16 18:41:25.104 [DEBUG]\t\u003cgithub.com/coder/coder/coderd/coderd.go:382>\tdebugLogRequest.func1.1\tGET /api/v2/workspacebuilds/f3e2c1b9-4948-4fbc-8d94-e399ba09ded4/logs\r\n✘ Queued [0ms]:53: \r\n    ptytest.go:53: ⧗  Running \r\n    ptytest.go:53: ⧗  Running \r\n    t.go:81: 2022-06-16 18:41:25.357 [DEBUG]\t\u003cgithub.com/coder/coder/coderd/coderd.go:382>\tdebugLogRequest.func1.1\tGET /api/v2/workspacebuilds/f3e2c1b9-4948-4fbc-8d94-e399ba09ded4\r\n    delete_test.go:71: \r\n        \tError Trace:\tdelete_test.go:71\r\n        \t            \t\t\t\tasm_arm64.s:1263\r\n        \tError:      \tTarget error should be in err chain:\r\n        \t            \texpected: \"EOF\"\r\n        \t            \tin chain: \"get workspace build: sql: no rows in result set\"\r\n        \tTest:       \tTestDelete/DifferentUser\r\n✘ Running [0ms]53: \r\n    ptytest.go:92: match exceeded deadline: wanted \"Cleaning Up\"; got \"\\x1b[1A\\r✘ Queued [0ms]\\r\\n⧗  \\x1b[;mRunning\\x1b[0m \\r\\n⧗  \\x1b[;mRunning\\x1b[0m \\r\\n\\x1b[1A\\r✘ Running [0ms]\\r\\n\"\r\n    ptytest.go:97: \r\n        \tError Trace:\tptytest.go:97\r\n        \t            \t\t\t\tdelete_test.go:75\r\n        \tError:      \tReceived unexpected error:\r\n        \t            \tEOF\r\n        \tTest:       \tTestDelete/DifferentUser\r\n    t.go:81: 2022-06-16 18:41:35.098 [DEBUG]\t(provisionerd)\t\u003cgithub.com/coder/coder/provisionerd/provisionerd.go:1073>\t(*Server).closeWithError\tclosing server with error\t{\"error\": null}\r\n    --- FAIL: TestDelete/DifferentUser (10.27s)\r\n```\r\n\r\nCoderd tries to acquire a job and fails with `request job was invalidated: get workspace build: sql: no rows in result set` that is to say, that it selected and locked a job in the database, then tried to look up the corresponding workspace build, and the build wasn't there.\r\n\r\nHow can this be?\r\n\r\nWhen we create the build, we insert the job and build in a single transaction, so you wouldn't expect some other query to be able to find the job but then not the build.\r\n\r\nAfter reading https://www.postgresql.org/docs/current/transaction-iso.html very carefully, I think this has to do with our use of `SELECT FOR UPDATE` in the locking query.\r\n\r\n> it is possible for an updating command to see an inconsistent snapshot: it can see the effects of concurrent updating commands on the same rows it is trying to update, but it does not see effects of those commands on other rows in the database. This behavior makes Read Committed mode unsuitable for commands that involve complex search conditions\r\n\r\nIt seems that the locking query, run in Read Committed mode (default), is able to see the effect of the transaction adding the job prior to that transaction being committed.  We may need to upgrade one or both of these transactions to a higher level of isolation.","author":{"url":"https://github.com/spikecurtis","@type":"Person","name":"spikecurtis"},"datePublished":"2022-06-16T20:36:52Z","url":"https://github.com/coder/coder/issues/2436"}

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:8acd6a99-1473-e39d-9658-cc72f8b92d10
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id835C:96DDF:281720E:32D0899:6B019389
html-safe-nonce8633d9fd07cc8613560366d24ca41d41a66d810fb5d768f90874e7356b0071bc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzVDOjk2RERGOjI4MTcyMEU6MzJEMDg5OTo2QjAxOTM4OSIsInZpc2l0b3JfaWQiOiI1MDQ3Mzk1Mjc4MjgyMzk2NTUzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacbd8af149027338713dce9978227e1140fdc55778ecafb5df26e54f7fa658c885
hovercard-subject-tagissue:1274056842
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/2436/issue_layout
twitter:imagehttps://opengraph.githubassets.com/af56959d63c9cee103143364d3857671c17f2cd97c4b10ddeab7591919c7fe65/coder/coder/issues/2436
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/af56959d63c9cee103143364d3857671c17f2cd97c4b10ddeab7591919c7fe65/coder/coder/issues/2436
og:image:altSummary: Our current postgres code that handles creating builds and sending them out to provisionerd is subtly bugged from an ACID standpoint, and results in provisionerd failing to acquire a job. ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamespikecurtis
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-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/coder/coder/issues/2436#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcoder%2Fcoder%2Fissues%2F2436
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%2F2436
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/2436
Reloadhttps://github.com/coder/coder/issues/2436
Reloadhttps://github.com/coder/coder/issues/2436
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/2436
New issuehttps://github.com/login?return_to=https://github.com/coder/coder/issues/2436
#2478https://github.com/coder/coder/pull/2478
database race on create build / acquire jobhttps://github.com/coder/coder/issues/2436#top
#2478https://github.com/coder/coder/pull/2478
apiArea: HTTP APIhttps://github.com/coder/coder/issues?q=state%3Aopen%20label%3A%22api%22
https://github.com/spikecurtis
spikecurtishttps://github.com/spikecurtis
on Jun 16, 2022https://github.com/coder/coder/issues/2436#issue-1274056842
https://www.postgresql.org/docs/current/transaction-iso.htmlhttps://www.postgresql.org/docs/current/transaction-iso.html
spikecurtishttps://github.com/spikecurtis
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 Jun 16, 2022https://github.com/coder/coder/issues/2436#event-6823883544
https://github.com/spikecurtis
spikecurtishttps://github.com/spikecurtis
on Jun 16, 2022https://github.com/coder/coder/issues/2436#issuecomment-1158264790
spikecurtishttps://github.com/spikecurtis
completedhttps://github.com/coder/coder/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#2478https://github.com/coder/coder/pull/2478
on Jun 17, 2022https://github.com/coder/coder/issues/2436#event-6831433973
https://github.com/spikecurtis
spikecurtishttps://github.com/spikecurtis
on Jun 17, 2022https://github.com/coder/coder/issues/2436#issuecomment-1159247360
Sign up for freehttps://github.com/signup?return_to=https://github.com/coder/coder/issues/2436
Sign in to commenthttps://github.com/login?return_to=https://github.com/coder/coder/issues/2436
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.