Skip to content

Connection to an in-memory db is lost if context is cancelled while a transaction is running.

In a memory-based DB, if a transaction is in progress and that transaction's context is cancelled, the connection to the database is lost. We only have one connection to the database and we lose the database after this.

SQL library will discard the connection if it does not implement interfaces driver.Validator and driver.SessionResetter: https://github.com/golang/go/blob/master/src/database/sql/sql.go#L1903-L1904

Can we implement these two interfaces so we don't lose the connection?