Skip to content

Lock the fake database during transactions - #2478

Merged
spikecurtis merged 5 commits into
mainfrom
spike/2436_better_fake_db_transaction_isolation
Jun 17, 2022
Merged

spikecurtis merged 5 commits into
mainfrom
spike/2436_better_fake_db_transaction_isolation

Conversation

@spikecurtis

Copy link
Copy Markdown
Collaborator

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() {}

@Emyrk Emyrk Jun 17, 2022 •

Copy link
Copy Markdown
Member

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() {}

@Emyrk Emyrk left a comment

Copy link
Copy Markdown
Member

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