Skip to content

EOF error in packets.go readPacket() not propagating #108

Closed
@insasho

Description

@insasho

I'm running a query that is returning around 250k rows from a MySQL 5.1 server. Occasionally I will get incomplete result sets without an error being returned to my invocation of the API methods. The following is printed:

[MySQL] 2013/07/10 11:18:38 packets.go:67: EOF

The relevant snippet of code:

errLog.Print(err.Error())
return nil, driver.ErrBadConn

Replacing "Print" with "Panic" shows the following stack trace:

[MySQL] 2013/07/10 11:23:33 packets.go:67: EOF
panic: EOF

goroutine 1 [running]:
log.(_Logger).Panic(0xc2000aa1e0, 0x7fd696a4f460, 0x1, 0x1)
/usr/local/go/src/pkg/log/log.go:193 +0xa7
github.com/go-sql-driver/mysql.(_mysqlConn).readPacket(0xc2000c3770, 0xc200100000, 0x66, 0x1000, 0xc2000ae000, ...)
ROOT/src/github.com/go-sql-driver/mysql/packets.go:67 +0x683
github.com/go-sql-driver/mysql.(_mysqlRows).readBinaryRow(0xc2000fe540, 0xc2000f6680, 0x4, 0x4, 0x0, ...)
ROOT/src/github.com/go-sql-driver/mysql/packets.go:861 +0x4e
github.com/go-sql-driver/mysql.(_mysqlRows).Next(0xc2000fe540, 0xc2000f6680, 0x4, 0x4, 0x0, ...)
ROOT/src/github.com/go-sql-driver/mysql/rows.go:68 +0x120
database/sql.(*Rows).Next(0xc2000c24e0, 0x676020)
/usr/local/go/src/pkg/database/sql/sql.go:1310 +0xc1
main.writeBooks(0xc2000c2120, 0xc2000aa5f0)
ROOT/src/example.com/sitemap/sitemapgenerator.go:152 +0x167
main.main()
ROOT/src/example.com/sitemap/sitemapgenerator.go:280 +0x87e

goroutine 2 [syscall]:
exit status 2

It looks like readBinaryRow is not actually returning the non-nil error, and instead returning early with a nil error:

func (rows *mysqlRows) readBinaryRow(dest []driver.Value) (err error) {
data, err := rows.mc.readPacket()
if err != nil {
return
}

This bug is particularly insidious because it is happening in a call to .Next(), which means that callers will be operating on partial result sets without knowing it.

System:

  • Ubuntu 13.04 64-bit
  • go 1.1
  • MySQL 5.1.63-0ubuntu0.10.04.1-log

This happens with both an SSH port forward and when on a proper network connection (rackspace cloud).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions