From 2380a4f252f0943e36b0bbad24a0ceca4ecf29b9 Mon Sep 17 00:00:00 2001 From: Iwan BK Date: Fri, 8 Apr 2022 08:22:16 +0700 Subject: [PATCH] Mitigate frozen predixy due to infinite TCP conn retry to a failed Redis cluster node --- src/Socket.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Socket.cpp b/src/Socket.cpp index effb7b6..68403e4 100644 --- a/src/Socket.cpp +++ b/src/Socket.cpp @@ -178,6 +178,13 @@ bool Socket::setTcpKeepAlive(int interval) if (ret != 0) { return false; } + // Mitigate frozen predixy due to infinite TCP conn retry to a failed Redis cluster node + // https://github.com/joyieldInc/predixy/issues/136 + val = 1000; // millisecond + ret = setsockopt(mFd, IPPROTO_TCP, TCP_USER_TIMEOUT, &val, sizeof(val)); + if (ret != 0) { + return false; + } #else ((void)interval); //Avoid unused var warning for non Linux systems #endif @@ -238,4 +245,4 @@ int Socket::writev(const struct iovec* vecs, int cnt) return n; } return 0; -} +} \ No newline at end of file