Skip to content
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

Deadlock on sqlite with PrepareStmt = true #7350

Open
pascal-fischer opened this issue Jan 22, 2025 · 0 comments
Open

Deadlock on sqlite with PrepareStmt = true #7350

pascal-fischer opened this issue Jan 22, 2025 · 0 comments
Assignees
Labels
type:with reproduction steps with reproduction steps

Comments

@pascal-fischer
Copy link

GORM Playground Link

go-gorm/playground#783

Description

Requirements:

  • using sqlite
  • setting sqlDB.SetMaxOpenConns to 1
  • setting PrepareStmt to true

There seems to be a race condition if we have 2 goroutines try to call the same db read at the same time (for the test I have multiple goroutines so the test is more likely to hit the race condition):

  • one call is in a transaction the other one is not -> FAIL
  • both calls in a transaction -> SUCCESS
  • both calls outside of transaction -> SUCCESS

If we set PrepareStmt to false it will work as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:with reproduction steps with reproduction steps
Projects
None yet
Development

No branches or pull requests

2 participants