Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2247)

Issue 8633044: code review 8633044: database/sql: close driver Stmt before releasing Conn (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years ago by bradfitz
Modified:
11 years ago
Reviewers:
CC:
golang-dev, r
Visibility:
Public.

Description

database/sql: close driver Stmt before releasing Conn From the issue, which describes it as well as I could: database/sql assumes that driver.Stmt.Close does not need the connection. see database/sql/sql.go:1308: This puts the Rows' connection back into the idle pool, and then calls the driver.Stmt.Close method of the Stmt it belongs to. In the postgresql driver implementation (https://github.com/lib/pq), Stmt.Close communicates with the server (on the connection that was just put back into the idle pool). Most of the time, this causes no problems, but if another goroutine makes a query at the right (wrong?) time, chaos results. In any case, traffic is being sent on "free" connections shortly after they are freed, leading to race conditions that kill the driver code. Fixes Issue 5283

Patch Set 1 #

Patch Set 2 : diff -r 824737065aef https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 824737065aef https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 86446fab23ef https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+39 lines, -1 line) Patch
M src/pkg/database/sql/fakedb_test.go View 1 3 chunks +18 lines, -0 lines 0 comments Download
M src/pkg/database/sql/sql.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/database/sql/sql_test.go View 1 1 chunk +20 lines, -0 lines 0 comments Download

Messages

Total messages: 3
bradfitz
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
11 years ago (2013-04-15 18:47:15 UTC) #1
r
LGTM
11 years ago (2013-04-15 19:24:23 UTC) #2
bradfitz
11 years ago (2013-04-15 21:06:43 UTC) #3
*** Submitted as https://code.google.com/p/go/source/detail?r=b141b8379367 ***

database/sql: close driver Stmt before releasing Conn

From the issue, which describes it as well as I could:

database/sql assumes that driver.Stmt.Close does not need the
connection.

see database/sql/sql.go:1308:

This puts the Rows' connection back into the idle pool, and
then calls the driver.Stmt.Close method of the Stmt it belongs
to.  In the postgresql driver implementation
(https://github.com/lib/pq), Stmt.Close communicates with the
server (on the connection that was just put back into the idle
pool).  Most of the time, this causes no problems, but if
another goroutine makes a query at the right (wrong?) time,
chaos results.

In any case, traffic is being sent on "free" connections
shortly after they are freed, leading to race conditions that
kill the driver code.

Fixes Issue 5283

R=golang-dev, r
CC=golang-dev
https://codereview.appspot.com/8633044
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b