Skip to content

Broken pipe errors #446

Closed
Closed
@marksamman

Description

@marksamman

Issue description

Connections that have been idle for some time are causing broken pipe errors the next time they are used. I haven't noticed queries actually failing, so I think this is just an annoyance of broken pipe errors appearing in the log. With a read/write timeout below wait_timeout, I would expect the idle connections to be closed by the driver before MySQL kills the connections.

DSN:

user:password@unix(/var/run/mysqld/mysqld.sock)/database?charset=utf8mb4,utf8&readTimeout=25000s&writeTimeout=25000s

Timeout variables:

MariaDB [(none)]> show variables like '%timeout%';
+-----------------------------+----------+
| Variable_name               | Value    |
+-----------------------------+----------+
| connect_timeout             | 5        |
| deadlock_timeout_long       | 50000000 |
| deadlock_timeout_short      | 10000    |
| delayed_insert_timeout      | 300      |
| innodb_flush_log_at_timeout | 1        |
| innodb_lock_wait_timeout    | 50       |
| innodb_rollback_on_timeout  | OFF      |
| interactive_timeout         | 28800    |
| lock_wait_timeout           | 31536000 |
| net_read_timeout            | 30       |
| net_write_timeout           | 60       |
| slave_net_timeout           | 3600     |
| thread_pool_idle_timeout    | 60       |
| wait_timeout                | 28800    |
+-----------------------------+----------+

Error log

packets.go:124: write unix @->/var/run/mysqld/mysqld.sock: write: broken pipe

Configuration

Driver version (or git SHA): 66312f7

Go version: 1.6 linux/amd64

Server version: MariaDB 10.1.13

Server OS: Debian 8.1 (Jessie)

Activity

methane

methane commented on Apr 9, 2016

@methane
Member

@marksamman driver can't remove connection from connection pool in database/sql.DB.
I added new API in database/sql for this reason.
See https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime

Your wait_timeout is 28800. So I recommend to use set half of it to MaxLifetime.
db.SetConnMaxLifetime(time.Second * 14400)

marksamman

marksamman commented on Apr 10, 2016

@marksamman
Author

Thanks, that seems to have solved the issue for me. If there's nothing the driver can do about it then I guess this issue can be closed, perhaps it could be documented in the README, but I'll leave it up to the project maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @methane@marksamman@julienschmidt

        Issue actions

          Broken pipe errors · Issue #446 · go-sql-driver/mysql