You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When context is canceled during the query, then it's not cleaned properly as its using go-sql-driver v1.5.0 instead of v1.6.0 (v1.6.0 supports IsValid(), which validates the connection before returning it to pool) go-sql-driver PR
Currently this step is skipped and pool gets canceled connections.
Steps to Reproduce
dsn:=fmt.Sprintf("root:root@tcp(%s:%d)/", address, port)
// open connection with new relic wrapperdb, err:=sql.Open("nrmysql", dsn)
assert.NoError(t, err)
// Setup timeout of a queryctx, cancel:=context.WithTimeout(context.Background(), time.Millisecond*50)
defercancel()
// Get the connectionconn, err:=db.Conn(ctx)
assert.NoError(t, err)
// Execute the request, context will be canceled before this query manages to execute_, err=conn.ExecContext(ctx, "SELECT SLEEP(1)")
assert.Error(t, err)
// Close the connection// This only releases the connection, however does not validate if the connection is validerr=conn.Close()
assert.NoError(t, err)
// Pick a new connection from the pool (as connections are reused, then the previous one is picked)conn, err=db.Conn(context.Background())
assert.NoError(t, err)
// As we are reusing the broken connection, then this ping will fail.err=conn.PingContext(context.Background())
assert.NoError(t, err)
// Now change the driver from `nrmysql` to `mysql`// Make sure that go-sql-driver version is v1.6.0 and rerun the test, it should pass.
Expected Behavior
Before connection is passed back to the pool, it should be validated if it has been canceled
Your Environment
Go 1.17
github.com/go-sql-driver/mysql v1.6.0
github.com/newrelic/go-agent/v3/integrations/nrmysql v1.2.1
The text was updated successfully, but these errors were encountered:
Thanks for filing this bug @JakobJoonas. It's always super helpful when there is a good reproducer attached. We will take a look at this and patch it up as soon as we can.
@JakobJoonas we totally lost sight of this. If I understand correctly, upgrading to github.com/go-sql-driver/mysql v1.6.0 should resolve this problem, right?
Description
When context is canceled during the query, then it's not cleaned properly as its using go-sql-driver v1.5.0 instead of v1.6.0 (v1.6.0 supports IsValid(), which validates the connection before returning it to pool) go-sql-driver PR
Currently this step is skipped and pool gets canceled connections.
Steps to Reproduce
Expected Behavior
Before connection is passed back to the pool, it should be validated if it has been canceled
Your Environment
Go 1.17
github.com/go-sql-driver/mysql v1.6.0
github.com/newrelic/go-agent/v3/integrations/nrmysql v1.2.1
The text was updated successfully, but these errors were encountered: