cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

SQL: driver is opening a new connection for every transaction

Open vivekmenezes opened this issue 11 years ago • 5 comments

The Go SQL driver is supposed to recycle a connection after a transaction with the server. I'm seeing it open a new connection for every call to db.Begin() var db *sql.DB tx, err := db.Begin()

vivekmenezes avatar Aug 06 '15 19:08 vivekmenezes

Is it unbounded? The Go SQL driver doesn't start recycling until the pool is full, I believe. See: http://godoc.org/database/sql#DB.SetMaxIdleConns http://godoc.org/database/sql#DB.SetMaxOpenConns

tamird avatar Aug 06 '15 19:08 tamird

Looks like it just hangs after reaching the limit. It really should use a free connection rather than opening a new one.

vivekmenezes avatar Aug 06 '15 19:08 vivekmenezes

Looks like it just hangs after reaching the limit.

Interesting. Can you write a test that repros this?

It really should use a free connection rather than opening a new one.

Heh, this is out of our control.

tamird avatar Aug 06 '15 19:08 tamird

yeah will write a test as I work on a fix

On Thu, Aug 6, 2015 at 3:19 PM Tamir Duberstein [email protected] wrote:

Looks like it just hangs after reaching the limit.

Interesting. Can you write a test that repros this?

It really should use a free connection rather than opening a new one.

Heh, this is out of our control.

— Reply to this email directly or view it on GitHub https://github.com/cockroachdb/cockroach/issues/2007#issuecomment-128479139 .

vivekmenezes avatar Aug 06 '15 19:08 vivekmenezes

I was not calling Commit() on the transaction because our current version of Commit() is unimplemented and returns an error. Once I call it, it works. This is not a bug.

vivekmenezes avatar Aug 06 '15 19:08 vivekmenezes