Skip to content

Lock the fake database during transactions #2478

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 5 commits into from
Jun 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix lint
Signed-off-by: Spike Curtis <spike@coder.com>
  • Loading branch information
spikecurtis committed Jun 17, 2022
commit 6299d0c2004dc8019283c5ba1dfd494ff65a93ef
10 changes: 5 additions & 5 deletions coderd/database/databasefake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ type rwMutex interface {
// inTxMutex is a no op, since inside a transaction we are already locked.
type inTxMutex struct{}

func (_ *inTxMutex) Lock() {}
func (_ *inTxMutex) RLock() {}
func (_ *inTxMutex) Unlock() {}
func (_ *inTxMutex) RUnlock() {}
func (inTxMutex) Lock() {}
func (inTxMutex) RLock() {}
func (inTxMutex) Unlock() {}
func (inTxMutex) RUnlock() {}

// fakeQuerier replicates database functionality to enable quick testing.
type fakeQuerier struct {
Expand Down Expand Up @@ -96,7 +96,7 @@ type data struct {
func (q *fakeQuerier) InTx(fn func(database.Store) error) error {
q.mutex.Lock()
defer q.mutex.Unlock()
return fn(&fakeQuerier{mutex: &inTxMutex{}, data: q.data})
return fn(&fakeQuerier{mutex: inTxMutex{}, data: q.data})
}

func (q *fakeQuerier) AcquireProvisionerJob(_ context.Context, arg database.AcquireProvisionerJobParams) (database.ProvisionerJob, error) {
Expand Down