GORM Playground Link
N/A (not relevant, but the bot is nagging)
Description
We had a panic caused by Gorm in one of our CI tests (see pocket-id/pocket-id#684), due to a data race (concurrent map read and map write) in schema/schema.go
This seems to have happened when 2 goroutines in our app tried to execute a query at the same time in Postgres.
Relevant segments from the stack trace:
fatal error: concurrent map read and map write
goroutine 203 [running]:
internal/runtime/maps.fatal({0x16765db?, 0xa75387?})
runtime/panic.go:1058 +0x18
gorm.io/gorm/schema.Schema.LookUpField(...)
gorm.io/gorm@v1.25.12/schema/schema.go:81
gorm.io/gorm/schema.(*Schema).guessRelation(0xc000294b40, 0xc000158f30, 0xc0006d7a00, 0x1ecc7f8?)
gorm.io/gorm@v1.25.12/schema/relationship.go:548 +0x12d7
gorm.io/gorm/schema.(*Schema).parseRelation(0xc000294b40, 0xc0006d7a00)
gorm.io/gorm@v1.25.12/schema/relationship.go:91 +0x3f3
gorm.io/gorm/schema.ParseWithSpecialTableName({0x143d1e0, 0xc000335380?}, 0xc0003ded50, {0x1ecc7f8, 0xc00039e840}, {0x0, 0x0})
gorm.io/gorm@v1.25.12/schema/schema.go:342 +0x22d8
gorm.io/gorm.(*Statement).ParseWithSpecialTableName(0xc000294960, {0x143d1e0?, 0xc000335380?}, {0x0?, 0x4737f9?})
gorm.io/gorm@v1.25.12/statement.go:493 +0x65
gorm.io/gorm.(*Statement).Parse(...)
gorm.io/gorm@v1.25.12/statement.go:489
gorm.io/gorm.(*processor).Execute(0xc0003986e0, 0x1ebf300?)
gorm.io/gorm@v1.25.12/callbacks.go:105 +0x1ae
gorm.io/gorm.(*DB).Delete(0x15d1060?, {0x143d1e0, 0xc000335380}, {0xc000542120, 0x2, 0x2})
gorm.io/gorm@v1.25.12/finisher_api.go:439 +0x12b
github.com/pocket-id/pocket-id/backend/internal/job.(*DbCleanupJobs).clearOidcAuthorizationCodes(0xc000010a08?, {0x1ec2d68, 0xc000398410})
github.com/pocket-id/pocket-id/backend/internal/job/db_cleanup_job.go:67 +0x165
reflect.Value.call({0x13f6160?, 0xc00003de90?, 0xc0006a3728?}, {0x1644b84, 0x4}, {0xc00052b5d8, 0x1, 0xffffffffffffffff?})
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: ItalyPaleAle
There's no playground link because it is not relevant to the case (and not easily replicable with a playground). See stack trace attached.
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: ItalyPaleAle
Bad bot