data race with cycle relation
zwell opened this issue · comments
Weichang Zha commented
GORM Playground Link
Description
In my project, hava some cycle orm relation, I use -race option to test, There is a certain probability that "DATA RACE"
Here are the test results for playgroud
==================
WARNING: DATA RACE
Read at 0x00c0005f2150 by goroutine 26:
gorm.io/gorm/schema.(*Schema).guessRelation()
E:/work/code/source/playground/gorm/schema/relationship.go:553 +0x1e44
gorm.io/gorm/schema.(*Schema).parseRelation()
E:/work/code/source/playground/gorm/schema/relationship.go:95 +0x744
gorm.io/gorm/schema.ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/schema/schema.go:350 +0x4164
gorm.io/gorm.(*Statement).ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/statement.go:493 +0x146
gorm.io/gorm.(*Statement).Parse()
E:/work/code/source/playground/gorm/statement.go:489 +0x3ab
gorm.io/gorm.(*processor).Execute()
E:/work/code/source/playground/gorm/callbacks.go:105 +0x386
gorm.io/gorm.(*DB).First()
E:/work/code/source/playground/gorm/finisher_api.go:129 +0x2f8
gorm.io/playground.TestGORM.func2()
E:/work/code/source/playground/main_test.go:23 +0xa4
Previous write at 0x00c0005f2150 by goroutine 25:
gorm.io/gorm/schema.ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/schema/schema.go:365 +0x46b3
gorm.io/gorm.(*Statement).ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/statement.go:493 +0x146
gorm.io/gorm.(*Statement).Parse()
E:/work/code/source/playground/gorm/statement.go:489 +0x3ab
gorm.io/gorm.(*processor).Execute()
E:/work/code/source/playground/gorm/callbacks.go:105 +0x386
gorm.io/gorm.(*DB).First()
E:/work/code/source/playground/gorm/finisher_api.go:129 +0x2f8
gorm.io/playground.TestGORM.func1()
E:/work/code/source/playground/main_test.go:16 +0xa4
Goroutine 26 (running) created at:
gorm.io/playground.TestGORM()
E:/work/code/source/playground/main_test.go:21 +0x4e
testing.tRunner()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1689 +0x21e
testing.(*T).Run.gowrap1()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1742 +0x44
Goroutine 25 (running) created at:
gorm.io/playground.TestGORM()
E:/work/code/source/playground/main_test.go:14 +0x2c
testing.tRunner()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1689 +0x21e
testing.(*T).Run.gowrap1()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1742 +0x44
==================
==================
WARNING: DATA RACE
Read at 0x00c0005f2168 by goroutine 26:
gorm.io/gorm/schema.(*Schema).guessRelation()
E:/work/code/source/playground/gorm/schema/relationship.go:553 +0x1e44
gorm.io/gorm/schema.(*Schema).parseRelation()
E:/work/code/source/playground/gorm/schema/relationship.go:95 +0x744
gorm.io/gorm/schema.ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/schema/schema.go:350 +0x4164
gorm.io/gorm.(*Statement).ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/statement.go:493 +0x146
gorm.io/gorm.(*Statement).Parse()
E:/work/code/source/playground/gorm/statement.go:489 +0x3ab
gorm.io/gorm.(*processor).Execute()
E:/work/code/source/playground/gorm/callbacks.go:105 +0x386
gorm.io/gorm.(*DB).First()
E:/work/code/source/playground/gorm/finisher_api.go:129 +0x2f8
gorm.io/playground.TestGORM.func2()
E:/work/code/source/playground/main_test.go:23 +0xa4
Previous write at 0x00c0005f2168 by goroutine 25:
gorm.io/gorm/schema.ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/schema/schema.go:369 +0x489b
gorm.io/gorm.(*Statement).ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/statement.go:493 +0x146
gorm.io/gorm.(*Statement).Parse()
E:/work/code/source/playground/gorm/statement.go:489 +0x3ab
gorm.io/gorm.(*processor).Execute()
E:/work/code/source/playground/gorm/callbacks.go:105 +0x386
gorm.io/gorm.(*DB).First()
E:/work/code/source/playground/gorm/finisher_api.go:129 +0x2f8
gorm.io/playground.TestGORM.func1()
E:/work/code/source/playground/main_test.go:16 +0xa4
Goroutine 26 (running) created at:
gorm.io/playground.TestGORM()
E:/work/code/source/playground/main_test.go:21 +0x4e
testing.tRunner()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1689 +0x21e
testing.(*T).Run.gowrap1()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1742 +0x44
Goroutine 25 (running) created at:
gorm.io/playground.TestGORM()
E:/work/code/source/playground/main_test.go:14 +0x2c
testing.tRunner()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1689 +0x21e
testing.(*T).Run.gowrap1()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1742 +0x44
==================
==================
WARNING: DATA RACE
Read at 0x00c0005f2180 by goroutine 26:
gorm.io/gorm/schema.(*Schema).guessRelation()
E:/work/code/source/playground/gorm/schema/relationship.go:553 +0x1e44
gorm.io/gorm/schema.(*Schema).parseRelation()
E:/work/code/source/playground/gorm/schema/relationship.go:95 +0x744
gorm.io/gorm/schema.ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/schema/schema.go:350 +0x4164
gorm.io/gorm.(*Statement).ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/statement.go:493 +0x146
gorm.io/gorm.(*Statement).Parse()
E:/work/code/source/playground/gorm/statement.go:489 +0x3ab
gorm.io/gorm.(*processor).Execute()
E:/work/code/source/playground/gorm/callbacks.go:105 +0x386
gorm.io/gorm.(*DB).First()
E:/work/code/source/playground/gorm/finisher_api.go:129 +0x2f8
gorm.io/playground.TestGORM.func2()
E:/work/code/source/playground/main_test.go:23 +0xa4
Previous write at 0x00c0005f2180 by goroutine 25:
gorm.io/gorm/schema.ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/schema/schema.go:373 +0x4a7b
gorm.io/gorm.(*Statement).ParseWithSpecialTableName()
E:/work/code/source/playground/gorm/statement.go:493 +0x146
gorm.io/gorm.(*Statement).Parse()
E:/work/code/source/playground/gorm/statement.go:489 +0x3ab
gorm.io/gorm.(*processor).Execute()
E:/work/code/source/playground/gorm/callbacks.go:105 +0x386
gorm.io/gorm.(*DB).First()
E:/work/code/source/playground/gorm/finisher_api.go:129 +0x2f8
gorm.io/playground.TestGORM.func1()
E:/work/code/source/playground/main_test.go:16 +0xa4
Goroutine 26 (running) created at:
gorm.io/playground.TestGORM()
E:/work/code/source/playground/main_test.go:21 +0x4e
testing.tRunner()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1689 +0x21e
testing.(*T).Run.gowrap1()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1742 +0x44
Goroutine 25 (running) created at:
gorm.io/playground.TestGORM()
E:/work/code/source/playground/main_test.go:14 +0x2c
testing.tRunner()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1689 +0x21e
testing.(*T).Run.gowrap1()
D:/Golang/sdk/go1.22.3/src/testing/testing.go:1742 +0x44
==================