mutablelogic / go-sqlite

Golang interface to SQLite
https://pkg.go.dev/github.com/mutablelogic/go-sqlite
Apache License 2.0
8 stars 0 forks source link

Fix the Prepare/Close crash #15

Open djthorpe opened 2 years ago

djthorpe commented 2 years ago

A crash (probably from the Pool) when clearly a close is not paired with a prepare for a connection.

djthorpe commented 2 years ago

There are two issues. The prepared statement cache is not working:

go clean -testcache && go test -v ./pkg/sqlite3 -run Test_Cache_001

The results can return bad information. Opening with connection without the SQLITE_OPEN_CACHE flag fixes this, so it's definately the cache.

Secondly,

go clean -testcache && go test -v ./pkg/sqlite3 -run Test_Pool_002

Can sometimes return a Prepare/Close panic.

panic: /home/djt/projects/go-sqlite/pkg/sqlite3/cache.go:49: Prepare() missing call to Close()

goroutine 20 [running]:
github.com/mutablelogic/go-sqlite/sys/sqlite3.(*ConnEx).Prepare.func1(0x2491d00)
    /home/djt/projects/go-sqlite/sys/sqlite3/statementex.go:50 +0xc8
FAIL    github.com/mutablelogic/go-sqlite/pkg/sqlite3   1.843s

Exhibits under higher loads.