Hello,

Encountered an issue while running test code, getting data race as following

[2022-02-11T13:11:38.067Z] WARNING: DATA RACE [2022-02-11T13:11:38.067Z] Read at 0x00c00038d6e0 by goroutine 75: [2022-02-11T13:11:38.067Z] runtime.mapaccess2_faststr() [2022-02-11T13:11:38.067Z] /usr/local/go/src/runtime/map_faststr.go:107 +0x0 [2022-02-11T13:11:38.067Z] github.com/jinzhu/gorm.newDialect() [2022-02-11T13:11:38.067Z] /home/jenkins/workspace//vendor/github.com/jinzhu/gorm/dialect.go:63 +0x87 [2022-02-11T13:11:38.067Z] github.com/jinzhu/gorm.(DB).clone() [2022-02-11T13:11:38.067Z] /home/jenkins/workspace//vendor/github.com/jinzhu/gorm/main.go:853 +0xba [2022-02-11T13:11:38.067Z] github.com/jinzhu/gorm.(DB).NewScope() [2022-02-11T13:11:38.067Z] /home/jenkins/workspace//vendor/github.com/jinzhu/gorm/main.go:204 +0x44 [2022-02-11T13:11:38.067Z] github.com/jinzhu/gorm.(DB).Find() [2022-02-11T13:11:38.068Z] /home/jenkins/workspace//vendor/github.com/jinzhu/gorm/main.go:354 +0x84 [2022-02-11T13:11:38.068Z] /store.(DBClient).Find()

Previous write at 0x00c00038d6e0 by goroutine 289: [2022-02-11T13:11:38.068Z] runtime.mapassign_faststr() [2022-02-11T13:11:38.068Z] /usr/local/go/src/runtime/map_faststr.go:202 +0x0 [2022-02-11T13:11:38.068Z] github.com/jinzhu/gorm.RegisterDialect() [2022-02-11T13:11:38.068Z] /home/jenkins/workspace//vendor/github.com/jinzhu/gorm/dialect.go:77 +0x4ee

The register dialect is happening as below code snippet

d, ok := gorm.GetDialect("mysql")
if !ok {
    return nil, gerror.New(GormGetDialectError, "Failed to get Gorm dialect \"mysql\"")
}

gorm.RegisterDialect(driverName, d)

Please let me know, if any more input is needed.

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 2 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: jinzhu

this should only be called once, doesn't expect goroutine safe.