Race condition on Relation
zwell opened this issue · comments
I'm getting a race condition warning when running a daemon I'm coding. Linux 3.10, MySQL 5.7.16, Go 1.9, GORM 1.25.10:
WARNING: DATA RACE
Read at 0x00c001559010 by goroutine 120:
gorm.io/gorm/schema.(*Schema).guessRelation()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/relationship.go:538 +0x1b19
gorm.io/gorm/schema.(*Schema).parseRelation()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/relationship.go:88 +0x724
gorm.io/gorm/schema.ParseWithSpecialTableName()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:341 +0x3aa4
gorm.io/gorm/schema.Parse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:117 +0x6e
gorm.io/gorm/schema.getOrParse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:422 +0x30a
gorm.io/gorm/schema.(*Schema).parseRelation()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/relationship.go:74 +0x424
gorm.io/gorm/schema.ParseWithSpecialTableName()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:341 +0x3aa4
gorm.io/gorm.(*Statement).ParseWithSpecialTableName()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/statement.go:492 +0x144
gorm.io/gorm.(*Statement).Parse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/statement.go:488 +0x3cd
gorm.io/gorm.(*processor).Execute()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks.go:105 +0x3a8
gorm.io/gorm.(*DB).Count()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/finisher_api.go:495 +0x11ac
kd-saas/common/repository.(*GormRepo[...]).Paginate()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/common/repository/paginate.go:9 +0x173
kd-saas/tenant/api/internal/handler/business.WalletRecordListHandler()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/tenant/api/internal/handler/business/wallet_record_list_handler.go:48 +0x424
kd-saas/tenant/api/internal/router.MakeHandler[...].func1()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/tenant/api/internal/router/define.go:26 +0x2a1
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
net/http.Handler.ServeHTTP-fm()
<autogenerated>:1 +0x75
kd-saas/common/request/operation_log.(*Middleware).Handle.func1()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/common/request/operation_log/operation_log_middleware.go:39 +0x5b5
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
net/http.Handler.ServeHTTP-fm()
<autogenerated>:1 +0x75
kd-saas/common/request/operation_log.(*Trace).Handle.func1()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/common/request/operation_log/trace_middleware.go:20 +0x61
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
net/http.Handler.ServeHTTP-fm()
<autogenerated>:1 +0x75
kd-saas/common/database.(*TenantMiddleware).Handle.func1()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/common/database/tenant_middleware.go:23 +0x6a
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
net/http.Handler.ServeHTTP-fm()
<autogenerated>:1 +0x75
kd-saas/common/assistant/auth.(*Middleware).Handle.func1()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/common/assistant/auth/middleware.go:29 +0x4c4
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.Authorize.func1.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/authhandler.go:81 +0x6cf
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.GunzipHandler.func1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/gunziphandler.go:26 +0x13a
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.MaxBytesHandler.func2.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/maxbyteshandler.go:24 +0x16a
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.MetricHandler.func1.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/metrichandler.go:21 +0x110
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.RecoverHandler.func1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/recoverhandler.go:21 +0xeb
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.(*timeoutHandler).ServeHTTP.func1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/timeouthandler.go:86 +0xe1
Previous write at 0x00c001559010 by goroutine 117:
gorm.io/gorm/schema.(*Schema).parseRelation()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/relationship.go:121 +0x11ca
gorm.io/gorm/schema.ParseWithSpecialTableName()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:341 +0x3aa4
gorm.io/gorm/schema.Parse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:117 +0x6e
gorm.io/gorm/schema.getOrParse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:422 +0x30a
gorm.io/gorm/schema.(*Schema).parseRelation()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/relationship.go:74 +0x424
gorm.io/gorm/schema.ParseWithSpecialTableName()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:341 +0x3aa4
gorm.io/gorm/schema.Parse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:117 +0x6e
gorm.io/gorm/schema.getOrParse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:422 +0x30a
gorm.io/gorm/schema.(*Schema).parseRelation()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/relationship.go:74 +0x424
gorm.io/gorm/schema.ParseWithSpecialTableName()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:341 +0x3aa4
gorm.io/gorm/schema.Parse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:117 +0x6e
gorm.io/gorm/schema.getOrParse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:422 +0x30a
gorm.io/gorm/schema.(*Schema).parseRelation()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/relationship.go:74 +0x424
gorm.io/gorm/schema.ParseWithSpecialTableName()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:341 +0x3aa4
gorm.io/gorm/schema.Parse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:117 +0x6e
gorm.io/gorm/schema.getOrParse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:422 +0x30a
gorm.io/gorm/schema.(*Schema).parseRelation()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/relationship.go:74 +0x424
gorm.io/gorm/schema.ParseWithSpecialTableName()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:341 +0x3aa4
gorm.io/gorm.(*Statement).ParseWithSpecialTableName()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/statement.go:492 +0x144
gorm.io/gorm.(*Statement).Parse()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/statement.go:488 +0x3cd
gorm.io/gorm.(*processor).Execute()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks.go:105 +0x3a8
gorm.io/gorm.(*DB).First()
/var/lib/jenkins/go/pkg/mod/gorm.io/gorm@v1.25.10/finisher_api.go:129 +0x2e4
kd-saas/common/repository.(*GormRepo[...]).First()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/common/repository/finisher.go:23 +0x14d
kd-saas/tenant/api/internal/handler/business.AddressHandler()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/tenant/api/internal/handler/business/address_handler.go:19 +0x18b
kd-saas/tenant/api/internal/router.MakeHandler[...].func1()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/tenant/api/internal/router/define.go:26 +0x1e4
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
net/http.Handler.ServeHTTP-fm()
<autogenerated>:1 +0x75
kd-saas/common/request/operation_log.(*Middleware).Handle.func1()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/common/request/operation_log/operation_log_middleware.go:21 +0x3a4
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
net/http.Handler.ServeHTTP-fm()
<autogenerated>:1 +0x75
kd-saas/common/request/operation_log.(*Trace).Handle.func1()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/common/request/operation_log/trace_middleware.go:20 +0x61
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
net/http.Handler.ServeHTTP-fm()
<autogenerated>:1 +0x75
kd-saas/common/database.(*TenantMiddleware).Handle.func1()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/common/database/tenant_middleware.go:23 +0x6a
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
net/http.Handler.ServeHTTP-fm()
<autogenerated>:1 +0x75
kd-saas/common/assistant/auth.(*Middleware).Handle.func1()
/var/lib/jenkins/workspace/test_kd_saas_tenant_api/common/assistant/auth/middleware.go:29 +0x4c4
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.Authorize.func1.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/authhandler.go:81 +0x6cf
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.GunzipHandler.func1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/gunziphandler.go:26 +0x13a
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.MaxBytesHandler.func2.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/maxbyteshandler.go:24 +0x16a
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.MetricHandler.func1.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/metrichandler.go:21 +0x110
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.RecoverHandler.func1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/recoverhandler.go:21 +0xeb
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.(*timeoutHandler).ServeHTTP.func1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/timeouthandler.go:86 +0xe1
Goroutine 120 (running) created at:
github.com/zeromicro/go-zero/rest/handler.(*timeoutHandler).ServeHTTP()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/timeouthandler.go:80 +0x6d5
github.com/zeromicro/go-zero/rest/handler.SheddingHandler.func2.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/sheddinghandler.go:53 +0x22d
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.BreakerHandler.func1.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/breakerhandler.go:39 +0x206
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.MaxConnsHandler.func2.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/maxconnshandler.go:30 +0x101
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.PrometheusHandler.func1.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/prometheushandler.go:45 +0x243
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.LogHandler.func1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/loghandler.go:42 +0x657
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.TraceHandler.func1.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/tracehandler.go:64 +0x721
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/router.(*patRouter).ServeHTTP()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/router/patrouter.go:66 +0x1fd
net/http.serverHandler.ServeHTTP()
/usr/local/go/src/net/http/server.go:2947 +0x641
net/http.(*conn).serve()
/usr/local/go/src/net/http/server.go:1991 +0xbe4
net/http.(*Server).Serve.func3()
/usr/local/go/src/net/http/server.go:3102 +0x58
Goroutine 117 (running) created at:
github.com/zeromicro/go-zero/rest/handler.(*timeoutHandler).ServeHTTP()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/timeouthandler.go:80 +0x6d5
github.com/zeromicro/go-zero/rest/handler.SheddingHandler.func2.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/sheddinghandler.go:53 +0x22d
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.BreakerHandler.func1.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/breakerhandler.go:39 +0x206
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.MaxConnsHandler.func2.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/maxconnshandler.go:30 +0x101
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.PrometheusHandler.func1.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/prometheushandler.go:45 +0x243
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.LogHandler.func1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/loghandler.go:42 +0x657
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/handler.TraceHandler.func1.1()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/handler/tracehandler.go:64 +0x721
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/net/http/server.go:2109 +0x4d
github.com/zeromicro/go-zero/rest/router.(*patRouter).ServeHTTP()
/var/lib/jenkins/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.4/rest/router/patrouter.go:66 +0x1fd
net/http.serverHandler.ServeHTTP()
/usr/local/go/src/net/http/server.go:2947 +0x641
net/http.(*conn).serve()
/usr/local/go/src/net/http/server.go:1991 +0xbe4
net/http.(*Server).Serve.func3()
/usr/local/go/src/net/http/server.go:3102 +0x58
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 ✨
reproduction steps
for i := 0; i < 10; i++ {
go func() {
repo := repository.NewBusinessRepo(db)
_, _ = repo.Unscoped().Where("id", 1).
Preload("Address").First()
}()
}
for i := 0; i < 10; i++ {
go func() {
repo := repository.NewBusinessWalletRecordRepo(db)
_, _ = repo.
Joins("left join business_wallets bw on bw.id = business_wallet_records.wallet_id").
Joins("left join businesses b on b.id = bw.business_id").
Preload(clause.Associations).
Preload("BusinessWallet.Business", func(db *gorm.DB) *gorm.DB {
return db.Unscoped()
}).
Order("business_wallet_records.id desc").
Paginate(1, 20)
}()
}
report
WARNING: DATA RACE
Read at 0x00c0013260e0 by goroutine 158:
gorm.io/gorm/callbacks.preload()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks/preload.go:272 +0xebe
gorm.io/gorm/callbacks.preloadEntryPoint()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks/preload.go:156 +0xd1c
gorm.io/gorm/callbacks.Preload()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks/query.go:283 +0x55b
gorm.io/gorm.(*processor).Execute()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks.go:130 +0xbe1
gorm.io/gorm.(*DB).Find()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/finisher_api.go:170 +0x238
gorm.io/gorm/callbacks.preload()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks/preload.go:284 +0x254f
gorm.io/gorm/callbacks.preloadEntryPoint()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks/preload.go:156 +0xd1c
gorm.io/gorm/callbacks.Preload()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks/query.go:283 +0x55b
gorm.io/gorm.(*processor).Execute()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks.go:130 +0xbe1
gorm.io/gorm.(*DB).Find()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/finisher_api.go:170 +0x238
kd-saas/common/repository.(*GormRepo[...]).Find()
E:/work/code/saas-api/common/repository/finisher.go:11 +0x18d
kd-saas/common/repository.(*GormRepo[...]).Find()
<autogenerated>:1 +0x6c
kd-saas/tenant/repository.(*BusinessWalletRecordRepo).Find()
<autogenerated>:1 +0x64
kd-saas/common/repository.(*GormRepo[...]).Paginate()
E:/work/code/saas-api/common/repository/paginate.go:20 +0x557
kd-saas/tenant/api/tests.TestRace.func2()
E:/work/code/saas-api/tenant/api/tests/race_test.go:46 +0x167
Previous write at 0x00c0013260e0 by goroutine 144:
gorm.io/gorm/schema.(*Schema).parseRelation()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/relationship.go:119 +0x106a
gorm.io/gorm/schema.ParseWithSpecialTableName()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/schema/schema.go:341 +0x3aa4
gorm.io/gorm.(*Statement).ParseWithSpecialTableName()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/statement.go:492 +0x144
gorm.io/gorm.(*Statement).Parse()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/statement.go:488 +0x3cd
gorm.io/gorm.(*processor).Execute()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/callbacks.go:105 +0x3a8
gorm.io/gorm.(*DB).First()
C:/Users/Administrator/go/pkg/mod/gorm.io/gorm@v1.25.10/finisher_api.go:129 +0x2e4
kd-saas/common/repository.(*GormRepo[...]).First()
E:/work/code/saas-api/common/repository/finisher.go:23 +0x14d
kd-saas/tenant/api/tests.TestRace.func1()
E:/work/code/saas-api/tenant/api/tests/race_test.go:31 +0x104
Goroutine 158 (running) created at:
kd-saas/tenant/api/tests.TestRace()
E:/work/code/saas-api/tenant/api/tests/race_test.go:36 +0xe4
testing.tRunner()
D:/Golang/sdk/go1.19.3/src/testing/testing.go:1446 +0x216
testing.(*T).Run.func1()
D:/Golang/sdk/go1.19.3/src/testing/testing.go:1493 +0x47
Goroutine 144 (running) created at:
kd-saas/tenant/api/tests.TestRace()
E:/work/code/saas-api/tenant/api/tests/race_test.go:28 +0x52
testing.tRunner()
D:/Golang/sdk/go1.19.3/src/testing/testing.go:1446 +0x216
testing.(*T).Run.func1()
D:/Golang/sdk/go1.19.3/src/testing/testing.go:1493 +0x47
I think it is caused by the same relation
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 ✨