Skip to content

fix: use getTemplateByIDNoLock #9484

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

Merged
merged 1 commit into from
Sep 1, 2023
Merged

fix: use getTemplateByIDNoLock #9484

merged 1 commit into from
Sep 1, 2023

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Sep 1, 2023

Spotted in: #9469

I was investigating the problem of blank, white pages happening in E2E tests, and found out that coder server is not responding if there request contains coder_session_token. I enabled pprof in Github action, and dumped goroutines.

It looks like we're calling the RLock twice:

1 @ 0x43ddf6 0x44f5cf 0x44f5a6 0x46e206 0x47ec51 0x2485acc 0x249cfbf 0x1ce51b3 0x246b48b 0x246b04f 0x472961
#	0x46e205	sync.runtime_SemacquireRWMutexR+0x25										/opt/hostedtoolcache/go/1.20.7/x64/src/runtime/sema.go:82
#	0x47ec50	sync.(*RWMutex).RLock+0x30											/opt/hostedtoolcache/go/1.20.7/x64/src/sync/rwmutex.go:71
#	0x2485acb	github.com/coder/coder/v2/coderd/database/dbfake.(*FakeQuerier).GetTemplateByID+0x8b				/home/runner/actions-runner/_work/coder/coder/coderd/database/dbfake/dbfake.go:2162
#	0x249cfbe	github.com/coder/coder/v2/coderd/database/dbfake.(*FakeQuerier).GetWorkspacesEligibleForTransition+0x8be	/home/runner/actions-runner/_work/coder/coder/coderd/database/dbfake/dbfake.go:3761
#	0x1ce51b2	github.com/coder/coder/v2/coderd/database/dbauthz.(*querier).GetWorkspacesEligibleForTransition+0x32		/home/runner/actions-runner/_work/coder/coder/coderd/database/dbauthz/dbauthz.go:1820
#	0x246b48a	github.com/coder/coder/v2/coderd/autobuild.(*Executor).runOnce+0x1ea						/home/runner/actions-runner/_work/coder/coder/coderd/autobuild/lifecycle_executor.go:113
#	0x246b04e	github.com/coder/coder/v2/coderd/autobuild.(*Executor).Run.func1+0x2ae	

@mtojek mtojek self-assigned this Sep 1, 2023
@mtojek mtojek requested review from johnstcn and mafredri September 1, 2023 13:10
@mtojek mtojek changed the title fix: use getProvisionerJobByIDNoLock fix: use getTemplateByIDNoLock Sep 1, 2023
@mtojek mtojek marked this pull request as ready for review September 1, 2023 13:12
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Would be nice if we could lint these, like "if mutex locked, disallow exported method call").

@mtojek mtojek enabled auto-merge (squash) September 1, 2023 13:18
@mtojek mtojek merged commit 5d7a779 into main Sep 1, 2023
@mtojek mtojek deleted the fix-deadlock branch September 1, 2023 13:21
@github-actions github-actions bot locked and limited conversation to collaborators Sep 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants