Open
Description
Hi, I'm trying to use sqlx in a non-blocking manner in a http.Handler. To do this I put the sqlx code in a goroutine. Everything works OK until I set GOMAXPROCS > 1, when it starts panicking under load.
This code errors when you throw a decent number of requests at it:
https://play.golang.org/p/JzdcbvkrvU
Bench the server with wrk or similar
wrk -c10 -d5 http://localhost:3000/sql
I'm relatively new to go, and could be missing some obvious no-no with GOMAXPROCS and goroutines. If anybody could point me in the right direction I'd appreciate it.
The errors look like this:
goroutine 2031 [runnable, locked to thread]:
github.com/mattn/go-sqlite3._Cfunc__sqlite3_open_v2(0x53b4330, 0xc20cd86a40, 0x10006, 0x0, 0x0)
github.com/mattn/go-sqlite3/_obj/_cgo_gotypes.go:106 +0x43
github.com/mattn/go-sqlite3.(*SQLiteDriver).Open(0xc20801e020, 0x4429510, 0x42, 0x0, 0x0, 0x0, 0x0)
/Users/Marc/gocode/src/github.com/mattn/go-sqlite3/sqlite3.go:269 +0x20d
database/sql.(*DB).conn(0xc20805e1e0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.4/libexec/src/database/sql/sql.go:664 +0x506
database/sql.(*DB).query(0xc20805e1e0, 0x4407c50, 0x20, 0xc20b075700, 0x2, 0x2, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.4/libexec/src/database/sql/sql.go:933 +0x43
database/sql.(*DB).Query(0xc20805e1e0, 0x4407c50, 0x20, 0xc20b075700, 0x2, 0x2, 0x200000000000000, 0x0, 0x0)
/usr/local/Cellar/go/1.4/libexec/src/database/sql/sql.go:924 +0xa6
github.com/jmoiron/sqlx.(*DB).QueryRowx(0xc20803aab0, 0x4407c50, 0x20, 0xc20b075700, 0x2, 0x2, 0xc20b075700)
/Users/Marc/gocode/src/github.com/jmoiron/sqlx/sqlx.go:335 +0x69
github.com/jmoiron/sqlx.Get(0x47142e0, 0xc20803aab0, 0x42d7fc0, 0xc209e0b500, 0x4407c50, 0x20, 0xc20b075700, 0x2, 0x2, 0x0, ...)
/Users/Marc/gocode/src/github.com/jmoiron/sqlx/sqlx.go:637 +0x7b
github.com/jmoiron/sqlx.(*DB).Get(0xc20803aab0, 0x42d7fc0, 0xc209e0b500, 0x4407c50, 0x20, 0xc20b075700, 0x2, 0x2, 0x0, 0x0)
/Users/Marc/gocode/src/github.com/jmoiron/sqlx/sqlx.go:302 +0xc6
main.func·001()
/Users/Marc/gocode/request-mirror.go:46 +0x1c4
created by main.(*handler).sqlHandler
/Users/Marc/gocode/request-mirror.go:47 +0x90