From 3cd45190295d4aebc7fcb55e9a60ada037c6a3bc Mon Sep 17 00:00:00 2001 From: Matteo Merli Date: Tue, 1 Sep 2026 08:09:51 -0700 Subject: [PATCH] Fix flaky ConnectionFailTest: restore fd limit in SetUp ConnectionFailTest lowers the process soft fd limit (RLIMIT_NOFILE) in a loop and never restores it, so a test leaves the limit as low as ~8 for the next one. The next test's SetUp() then makes an HTTP request to create the partitioned topic, and curl can intermittently fail to open a socket (res: -1) when the previous client's async connection teardown still holds file descriptors. Restore the soft limit to the hard limit in SetUp() before making the HTTP request. --- tests/unix/ConnectionFailTest.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unix/ConnectionFailTest.cc b/tests/unix/ConnectionFailTest.cc index a05e6a39..11ac3849 100644 --- a/tests/unix/ConnectionFailTest.cc +++ b/tests/unix/ConnectionFailTest.cc @@ -31,6 +31,10 @@ class ConnectionFailTest : public ::testing::TestWithParam { struct rlimit limit; ASSERT_EQ(getrlimit(RLIMIT_NOFILE, &limit), 0); maxFdCount_ = limit.rlim_max; + // The previous test leaves the soft fd limit lowered, which could make the HTTP request below fail + // to open a socket. Restore it before creating the topic. + limit.rlim_cur = limit.rlim_max; + ASSERT_EQ(setrlimit(RLIMIT_NOFILE, &limit), 0); int numPartitions = GetParam(); topic_ = "test-connection-fail-" + std::to_string(numPartitions) + std::to_string(time(nullptr)); if (numPartitions > 0) {