Description

We detected a data race in a binary compiled using the -race flag in go build:

WARNING: DATA RACE
Write at 0x00c000690e00 by goroutine 33:
  gorm.io/gorm/schema.(*Schema).parseRelation()
      /path/to/project/.gopath/pkg/mod/gorm.io/gorm@v1.25.2/schema/relationship.go:118 +0x1031
  gorm.io/gorm/schema.ParseWithSpecialTableName()
      /path/to/project/.gopath/pkg/mod/gorm.io/gorm@v1.25.2/schema/schema.go:321 +0x3b4d
  gorm.io/gorm.(*Statement).ParseWithSpecialTableName()
      /path/to/project/.gopath/pkg/mod/gorm.io/gorm@v1.25.2/statement.go:492 +0x144
  gorm.io/gorm.(*Statement).Parse()
      /path/to/project/.gopath/pkg/mod/gorm.io/gorm@v1.25.2/statement.go:488 +0x3dd
  gorm.io/gorm.(*processor).Execute()
      /path/to/project/.gopath/pkg/mod/gorm.io/gorm@v1.25.2/callbacks.go:105 +0x3b8
  gorm.io/gorm.(*DB).Find()
      /path/to/project/.gopath/pkg/mod/gorm.io/gorm@v1.25.2/finisher_api.go:170 +0x238

[..]

Previous read at 0x00c000690e00 by goroutine 36:
  gorm.io/gorm/callbacks.preload()
      /path/to/project/.gopath/pkg/mod/gorm.io/gorm@v1.25.2/callbacks/preload.go:195 +0xe24
  gorm.io/gorm/callbacks.Preload()
      /path/to/project/.gopath/pkg/mod/gorm.io/gorm@v1.25.2/callbacks/query.go:298 +0xf16
  gorm.io/gorm.(*processor).Execute()
      /path/to/project/.gopath/pkg/mod/gorm.io/gorm@v1.25.2/callbacks.go:130 +0xbe1
  gorm.io/gorm.(*DB).Find()
      /path/to/project/.gopath/pkg/mod/gorm.io/gorm@v1.25.2/finisher_api.go:170 +0x238
  import.path/pkg/database.findOrdereds[...]()
      /path/to/project/pkg/database/generic.go:59 +0x11a

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