Closed
Description
Issue description
Intermittently I get failed writes against MariaDB. Lines like the below show up in my logs and data that was supposed to be written is lost. I have not yet tried writing retry logic in my application.
Both my Go app and MariaDB are running in Docker containers. However, I am seeing these errors when they on the same host, connecting over a local Docker network.
Docker version: 1.10.3
Example code
func (z *Zim) saveJob(j *job, transactions ...*gorm.DB) error {
var (
transaction *gorm.DB
err error
name, value string
order int
line string
)
switch len(transactions) {
case 0:
transaction = z.mariaDBHandle.Begin()
err = z.saveJob(j, transaction)
if err == nil {
transaction.Commit()
} else {
transaction.Rollback()
}
return err
case 1:
transaction = transactions[0]
default:
panic("too many transaction handlers passed to saveJob")
}
if len(j.ID) == 0 {
// create the job!
// assign an ID
j.ID = uuid.NewV4().String()
err = transaction.Set("gorm:save_associations", false).Create(j).Error
if err != nil {
return err
}
// on creation, only save options
for name, value = range j.Options {
err = transaction.Set(
"gorm:save_associations", false,
).Create(&jobOption{
ID: uuid.NewV4().String(),
JobID: j.ID,
Name: name,
Value: value,
}).Error
if err != nil {
return err
}
}
} else {
// update the job!
err = transaction.Set("gorm:save_associations", false).Save(j).Error
if err != nil {
return err
}
// on update, save Stdout and Stderr lines
for order, line = range j.Stdout {
err = transaction.Set(
"gorm:save_associations", false,
).Create(&jobStdout{
ID: uuid.NewV4().String(),
JobID: j.ID,
Order: order,
Line: line,
}).Error
if err != nil {
return err
}
}
for order, line = range j.Stderr {
err = transaction.Set(
"gorm:save_associations", false,
).Create(&jobStderr{
ID: uuid.NewV4().String(),
JobID: j.ID,
Order: order,
Line: line,
}).Error
if err != nil {
return err
}
}
}
return nil
}
Error log
[mysql] 2016/12/14 22:56:20 packets.go:33: unexpected EOF
[mysql] 2016/12/14 22:56:20 packets.go:130: write tcp 172.29.0.16:55610->172.29.0.4:3306: write: broken pipe
Configuration
Driver version (or git SHA):
{
"checksumSHA1": "xmTgJXWHguGKHPuZE50FIbs88L0=",
"path": "github.com/go-sql-driver/mysql",
"revision": "a0583e0143b1624142adab07e0e97fe106d99561",
"revisionTime": "2016-12-01T11:50:36Z"
},
Go version: run go version
in your console
$ go version
go version go1.7.3 darwin/amd64
Server version: E.g. MySQL 5.6, MariaDB 10.0.20
MariaDB: off-the-shelf container mariadb:10.1.19
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
CoreOS 1122.3.0
Metadata
Metadata
Assignees
Labels
No labels