8000 Race when using a DB instance from multiple goroutines · Issue #3662 · go-gorm/gorm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Race when using a DB instance from multiple goroutines #3662
Closed
@kapvode

Description

@kapvode

GORM Playground Link

go-gorm/playground#188

Description

I encountered a race, similar to what was reported in #3595.

I might have misunderstood the documentation, but it seems to me that my example from the playground pull request should be the same as the first example from the documentation, demonstrating what should be a safe way of using a DB instance from multiple goroutines.

https://gorm.io/docs/method_chaining.html#Method-Chain-Safety-Goroutine-Safety

db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})

// Safe for new initialized *gorm.DB
for i := 0; i < 100; i++ {
  go db.Where(...).First(&user)
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0