Skip to content

Commit

Permalink
Handle epipe errors
Browse files Browse the repository at this point in the history
Presently, if the tcp session to the server closes, we will emit
broken pipe errors potentially until we reach ConnMaxLifetime.

Since EPIPE means that the tcp session is dead (ie we received a
RST packet from the server), there is no point in attempting to
proceed past that point: set the connection as closed.
  • Loading branch information
n-oden committed Jan 13, 2023
1 parent 930a6c9 commit a51c9cd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"log"
"net"
"os"
"syscall"
"time"

"github.com/ClickHouse/ch-go/compress"
Expand Down Expand Up @@ -226,6 +227,10 @@ func (c *connect) sendData(block *proto.Block, name string) error {
return err
}
if err := c.flush(); err != nil {
if errors.Is(err, syscall.EPIPE) {
c.debugf("[send data] pipe is broken, closing connection")
c.closed = true
}
return err
}
defer func() {
Expand Down

0 comments on commit a51c9cd

Please sign in to comment.