go-sqlite3: Panic: driver.Stmt is nil, not *sqlite3.SQLiteStmt in exec()

Attempting to debug https://github.com/rqlite/rqlite/issues/830

Can anyone tell me why this might be happening? I’ve looked at the go-sqlite3 code, and can’t see how this could happen. How could:

https://github.com/mattn/go-sqlite3/blob/3392062c729d77820afc1f5cae3427f0de39e954/sqlite3.go#L1744

return anything but a *sqlite3.SQLiteStmt and a nil error? I’m wondering if I have a race in rqlite that is setting something to nil. But a basic reading of the panic implies that (c *SQLiteConn) prepare() is truly returning nil, nil. Is that possible?

Background:

rqlite is hitting the following issue:

panic: interface conversion: driver.Stmt is nil, not *sqlite3.SQLiteStmt

goroutine 25 [running]:
github.com/rqlite/go-sqlite3.(*SQLiteConn).exec(0xc00018ea20, 0xddbb00, 0xc00002e0a0, 0xc00024bc00, 0x6a8, 0x1414c70, 0x0, 0x0, 0xc000379920, 0x47b8bb, ...)
	/tmp/tmp.xoS5K1RUKH/pkg/mod/github.com/rqlite/go-sqlite3@v1.20.2/sqlite3.go:803 +0x72e
github.com/rqlite/go-sqlite3.(*SQLiteConn).Exec(0xc00018ea20, 0xc00024bc00, 0x6a8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0)
	/tmp/tmp.xoS5K1RUKH/pkg/mod/github.com/rqlite/go-sqlite3@v1.20.2/sqlite3.go:792 +0x145
github.com/rqlite/rqlite/db.(*DB).Execute.func1(0xc000379ab0, 0xcfd300, 0xc0001914d0, 0xc000226000, 0x201, 0x0, 0x0)
	/tmp/tmp.xoS5K1RUKH/src/github.com/rqlite/rqlite/db/db.go:321 +0x2aa
github.com/rqlite/rqlite/db.(*DB).Execute(0xc0001914d0, 0xc000226000, 0xc000ef6101, 0x0, 0x0, 0x0, 0x0, 0xc0001f83f0)
	/tmp/tmp.xoS5K1RUKH/src/github.com/rqlite/rqlite/db/db.go:356 +0xa5
github.com/rqlite/rqlite/store.(*Store).Apply(0xc000182780, 0xc000460060, 0x0, 0x0)
	/tmp/tmp.xoS5K1RUKH/src/github.com/rqlite/rqlite/store/store.go:950 +0x3c6
github.com/hashicorp/raft.(*Raft).runFSM.func1(0xc0019a8040)
	/tmp/tmp.xoS5K1RUKH/pkg/mod/github.com/hashicorp/raft@v1.3.0/fsm.go:90 +0x2bd
github.com/hashicorp/raft.(*Raft).runFSM.func2(0xc00028a200, 0x1, 0x40)
	/tmp/tmp.xoS5K1RUKH/pkg/mod/github.com/hashicorp/raft@v1.3.0/fsm.go:113 +0x75
github.com/hashicorp/raft.(*Raft).runFSM(0xc0002b6000)
	/tmp/tmp.xoS5K1RUKH/pkg/mod/github.com/hashicorp/raft@v1.3.0/fsm.go:216 +0x3c4
github.com/hashicorp/raft.(*raftState).goFunc.func1(0xc0002b6000, 0xc000194cd0)
	/tmp/tmp.xoS5K1RUKH/pkg/mod/github.com/hashicorp/raft@v1.3.0/state.go:146 +0x55
created by github.com/hashicorp/raft.(*raftState).goFunc
	/tmp/tmp.xoS5K1RUKH/pkg/mod/github.com/hashicorp/raft@v1.3.0/state.go:144 +0x66

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 25 (16 by maintainers)

Commits related to this issue

Most upvoted comments

I tried your suggestion @rittneje and it works great! You can see the work-in-progress PR here: https://github.com/rqlite/rqlite/pull/842/files#diff-30c25f2a7d8ae335d2aada4b0a6013ad9d159595bb6a2a14b1d0022451b6753fR108

Below is a graph showing Execute rate staying steady (green line) even as I increase query load (orange line). Previously Execute rate would drop as Query load increased.

ExecuteAndQueries

This is a really great, thanks so much.