From ca80eced2483f470b9cdeb9fe6100791c882a4f8 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 22 May 2024 10:49:27 -0700 Subject: [PATCH] usage of deadline conn at Accept() breaks websocket (#19789) fortunately not wired up to use, however if anyone enables deadlines for conn then sporadically MinIO startups fail. --- cmd/common-main.go | 4 ---- cmd/globals.go | 7 +------ cmd/server-main.go | 36 ++++-------------------------------- internal/http/dial_linux.go | 4 +++- internal/http/listener.go | 14 ++------------ 5 files changed, 10 insertions(+), 55 deletions(-) diff --git a/cmd/common-main.go b/cmd/common-main.go index cbb8f4fbc..8404156af 100644 --- a/cmd/common-main.go +++ b/cmd/common-main.go @@ -407,10 +407,6 @@ func buildServerCtxt(ctx *cli.Context, ctxt *serverCtxt) (err error) { ctxt.Interface = ctx.String("interface") ctxt.UserTimeout = ctx.Duration("conn-user-timeout") - ctxt.ConnReadDeadline = ctx.Duration("conn-read-deadline") - ctxt.ConnWriteDeadline = ctx.Duration("conn-write-deadline") - ctxt.ConnClientReadDeadline = ctx.Duration("conn-client-read-deadline") - ctxt.ConnClientWriteDeadline = ctx.Duration("conn-client-write-deadline") ctxt.SendBufSize = ctx.Int("send-buf-size") ctxt.RecvBufSize = ctx.Int("recv-buf-size") diff --git a/cmd/globals.go b/cmd/globals.go index ab88993ad..5a498ca25 100644 --- a/cmd/globals.go +++ b/cmd/globals.go @@ -160,12 +160,7 @@ type serverCtxt struct { FTP []string SFTP []string - UserTimeout time.Duration - ConnReadDeadline time.Duration - ConnWriteDeadline time.Duration - ConnClientReadDeadline time.Duration - ConnClientWriteDeadline time.Duration - + UserTimeout time.Duration ShutdownTimeout time.Duration IdleTimeout time.Duration ReadHeaderTimeout time.Duration diff --git a/cmd/server-main.go b/cmd/server-main.go index ff6a70c7d..5cf72b958 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -103,32 +103,6 @@ var ServerFlags = []cli.Flag{ EnvVar: "MINIO_READ_HEADER_TIMEOUT", Hidden: true, }, - cli.DurationFlag{ - Name: "conn-client-read-deadline", - Usage: "custom connection READ deadline for incoming requests", - Hidden: true, - EnvVar: "MINIO_CONN_CLIENT_READ_DEADLINE", - }, - cli.DurationFlag{ - Name: "conn-client-write-deadline", - Usage: "custom connection WRITE deadline for outgoing requests", - Hidden: true, - EnvVar: "MINIO_CONN_CLIENT_WRITE_DEADLINE", - }, - cli.DurationFlag{ - Name: "conn-read-deadline", - Usage: "custom connection READ deadline", - Hidden: true, - Value: 10 * time.Minute, - EnvVar: "MINIO_CONN_READ_DEADLINE", - }, - cli.DurationFlag{ - Name: "conn-write-deadline", - Usage: "custom connection WRITE deadline", - Hidden: true, - Value: 10 * time.Minute, - EnvVar: "MINIO_CONN_WRITE_DEADLINE", - }, cli.DurationFlag{ Name: "conn-user-timeout", Usage: "custom TCP_USER_TIMEOUT for socket buffers", @@ -440,12 +414,10 @@ func serverHandleCmdArgs(ctxt serverCtxt) { setGlobalInternodeInterface(ctxt.Interface) globalTCPOptions = xhttp.TCPOptions{ - UserTimeout: int(ctxt.UserTimeout.Milliseconds()), - ClientReadTimeout: ctxt.ConnClientReadDeadline, - ClientWriteTimeout: ctxt.ConnClientWriteDeadline, - Interface: ctxt.Interface, - SendBufSize: ctxt.SendBufSize, - RecvBufSize: ctxt.RecvBufSize, + UserTimeout: int(ctxt.UserTimeout.Milliseconds()), + Interface: ctxt.Interface, + SendBufSize: ctxt.SendBufSize, + RecvBufSize: ctxt.RecvBufSize, } // allow transport to be HTTP/1.1 for proxying. diff --git a/internal/http/dial_linux.go b/internal/http/dial_linux.go index dec72f90d..f210d4bde 100644 --- a/internal/http/dial_linux.go +++ b/internal/http/dial_linux.go @@ -39,10 +39,12 @@ func setTCPParametersFn(opts TCPOptions) func(network, address string, c syscall _ = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_REUSEPORT, 1) - { + if opts.SendBufSize > 0 { // Enable big buffers _ = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_SNDBUF, opts.SendBufSize) + } + if opts.RecvBufSize > 0 { _ = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_RCVBUF, opts.RecvBufSize) } diff --git a/internal/http/listener.go b/internal/http/listener.go index a16e0076a..9cf6425e6 100644 --- a/internal/http/listener.go +++ b/internal/http/listener.go @@ -22,9 +22,6 @@ import ( "fmt" "net" "syscall" - "time" - - "github.com/minio/minio/internal/deadlineconn" ) type acceptResult struct { @@ -75,9 +72,7 @@ func (listener *httpListener) Accept() (conn net.Conn, err error) { select { case result, ok := <-listener.acceptCh: if ok { - return deadlineconn.New(result.conn). - WithReadDeadline(listener.opts.ClientReadTimeout). - WithWriteDeadline(listener.opts.ClientWriteTimeout), result.err + return result.conn, result.err } case <-listener.ctx.Done(): } @@ -122,12 +117,7 @@ func (listener *httpListener) Addrs() (addrs []net.Addr) { // TCPOptions specify customizable TCP optimizations on raw socket type TCPOptions struct { - UserTimeout int // this value is expected to be in milliseconds - // When the net.Conn is idle for more than ReadTimeout duration, we close the connection on the client proactively. - ClientReadTimeout time.Duration - // When the net.Conn is idle for more than WriteTimeout duration, we close the connection on the client proactively. - ClientWriteTimeout time.Duration - + UserTimeout int // this value is expected to be in milliseconds SendBufSize int // SO_SNDBUF size for the socket connection, NOTE: this sets server and client connection RecvBufSize int // SO_RECVBUF size for the socket connection, NOTE: this sets server and client connection Interface string // This is a VRF device passed via `--interface` flag