执行xorm.NewEngine时fatal error: concurrent map read and map write #678
Labels
No Label
backport/done
backport/v1
blocked
db
oracle
db
sqlserver
duplicate
feature
cache
frontport/done
frontport/main
invalid
kind
breaking
kind
bug
kind
build
kind
dependencies
kind
docs
kind
driver
kind
enhancement
kind
feature
kind
performance
kind
proposal
kind
question
kind
refactor
kind
testing
need
feedback
need
test
proposal:accepted
RaspBerry Pi
regression
skip-changelog
upstream
wip
wontfix
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#678
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
在执行
db, err := xorm.NewEngine("sqlite3", "/path/to/db")
时候 出现了如下错误,看起来应该不是我业务代码造成的Call stack:
fatal error: concurrent map read and map write
goroutine 63 [running]:
runtime.throw(0xa3c7be, 0x21)
/usr/local/go/src/runtime/panic.go:596 +0x95 fp=0xc4201daa88 sp=0xc4201daa68
runtime.mapaccess2_faststr(0x99bf80, 0xc420011fb0, 0xa2af2b, 0x7, 0x416a88, 0x0)
/usr/local/go/src/runtime/hashmap_fast.go:326 +0x50a fp=0xc4201daae8 sp=0xc4201daa88
github.com/go-xorm/core.RegisterDriver(0xa2af2b, 0x7, 0xe91a40, 0xeda2d0)
/root/tools/src/github.com/go-xorm/core/driver.go:15 +0x65 fp=0xc4201dab60 sp=0xc4201daae8
github.com/go-xorm/xorm.regDrvsNDialects(0xc420386030)
/root/tools/src/github.com/go-xorm/xorm/xorm.go:42 +0x64d fp=0xc4201dac50 sp=0xc4201dab60
github.com/go-xorm/xorm.NewEngine(0xa2b35a, 0x7, 0xc420386000, 0x2c, 0x0, 0x0, 0x416a88)
/root/tools/src/github.com/go-xorm/xorm/xorm.go:56 +0x34 fp=0xc4201dad28 sp=0xc4201dac50
你是在运行过程中创建engine的?
不太确定“在运行过程中创建”是什么意思, 我这程序会同时访问多个sqlite数据库文件,每次我都是在每个goroutine里NewEngine 然后Close掉。之前没出现过这问题,最近加了一个新的goroutine,相同使用方法 就出现这个情况了
我着急想解决这个问题的话,是否是把Driver(core/driver.go)里面所有对drivers这变量的读写加读写锁就可以了? 只使用sqlite3Driver的情况下