• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

go-sql-driver / mysql / 1610
83%

Build:
DEFAULT BRANCH: master
Ran 29 Mar 2019 08:32AM UTC
Jobs 9
Files 15
Run time 3min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

29 Mar 2019 08:29AM UTC coverage: 79.863% (+0.1%) from 79.753%
1610

push

travis-ci

methane
check connection liveness before writing query (#934)

This commit contains a potential fix to the issue reported in #657.

As a summary: when a MySQL server kills a connection on the server-side
(either because it is actively pruning connections, or because the
connection has hit the server-side timeout), the Go MySQL client does
not immediately become aware of the connection being dead.

Because of the way TCP works, the client cannot know that the connection
has received a RST packet from the server (i.e. the server-side has
closed) until it actually reads from it. This causes an unfortunate bug
wherein a MySQL idle connection is pulled from the connection pool, a
query packet is written to it without error, and then the query fails
with an "unexpected EOF" error when trying to read the response packet.

Since the initial write to the socket does not fail with an error, it is
generally not safe to return `driver.ErrBadConn` when the read fails,
because in theory the write could have arrived to the server and could
have been committed. Returning `ErrBadConn` could lead to duplicate
inserts on the database and data corruption because of the way the Go
SQL package performs retries.

In order to significantly reduce the circumstances where this
"unexpected EOF" error is returned for stale connections, this commit
performs a liveness check before writing a new query.

When do we check?
-----------------

This check is not performed for all writes. Go 1.10 introduced a new
`sql/driver` interface called `driver.SessionResetter`, which calls the
`ResetSession` method on any connections _when they are returned to the
connection pool_. Since performing the liveness check during
`ResetSession` is not particularly useful (the connection can spend a
long time in the pool before it's checked out again, and become stale),
we simply mark the connection with a `reset` flag instead.

This `reset` flag is then checked from `mysqlCo... (continued)

2689 of 3367 relevant lines covered (79.86%)

524916.54 hits per line

Jobs
ID Job ID Ran Files Coverage
1 1610.1 29 Mar 2019 08:31AM UTC 0
78.14
Travis Job 1610.1
2 1610.2 29 Mar 2019 08:32AM UTC 0
79.0
Travis Job 1610.2
3 1610.3 29 Mar 2019 08:32AM UTC 0
79.0
Travis Job 1610.3
4 1610.4 29 Mar 2019 08:32AM UTC 0
79.0
Travis Job 1610.4
5 1610.5 29 Mar 2019 08:35AM UTC 0
79.0
Travis Job 1610.5
6 1610.6 (DB=MYSQL8) 29 Mar 2019 08:34AM UTC 0
79.39
Travis Job 1610.6
7 1610.7 (DB=MYSQL57) 29 Mar 2019 08:34AM UTC 0
79.33
Travis Job 1610.7
8 1610.8 (DB=MARIA55) 29 Mar 2019 08:34AM UTC 0
78.68
Travis Job 1610.8
9 1610.9 (DB=MARIA10_1) 29 Mar 2019 08:35AM UTC 0
79.15
Travis Job 1610.9
Source Files on build 1610
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #1610
  • bc5e6eaa on github
  • Prev Build on master (#1609)
  • Next Build on master (#1615)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc