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

Conversation

spikecurtis
Copy link
Contributor

Might fix #2436 entirely, but definitely will fix in the fake db case.

There are additional bugs lurking around basically every use of InTx() in our tests that this fixes, because until this PR, transactions exposed intermediate state to other goroutines with the fake database.

Signed-off-by: Spike Curtis <spike@coder.com>
// inTxMutex is a no op, since inside a transaction we are already locked.
type inTxMutex struct{}

func (_ *inTxMutex) Lock() {}
Copy link
Member

@Emyrk Emyrk Jun 17, 2022

Choose a reason for hiding this comment

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

Even more lazy.

Suggested change
func (_ *inTxMutex) Lock() {}
func (nTxMutex) Lock() {}

Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

Exactly what I was thinking.

Signed-off-by: Spike Curtis <spike@coder.com>
Signed-off-by: Spike Curtis <spike@coder.com>
Signed-off-by: Spike Curtis <spike@coder.com>
@spikecurtis spikecurtis merged commit 0aa66b4 into main Jun 17, 2022
@spikecurtis spikecurtis deleted the spike/2436_better_fake_db_transaction_isolation branch June 17, 2022 20:50
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

Successfully merging this pull request may close these issues.

database race on create build / acquire job
2 participants