From a19c4058bebe5badaef71af78f033afaa3393256 Mon Sep 17 00:00:00 2001 From: Huang Zhw Date: Tue, 16 Mar 2021 23:25:30 +0800 Subject: [PATCH] When tests exit normally, some processes may still be alive (#8647) In certain scenario start_server may think it failed to start a redis server although it started successfully. in these cases, it'll not terminate it, and it'll remain running when the test is over. In start_server if config doesn't have bind (the minimal.conf in introspection.tcl), it will try to bind ipv4 and ipv6. One may success while other fails. It will output "Could not create server TCP listening socket". wait_server_started uses this message to check whether instance started successfully. So it will consider that it failed even though redis started successfully. Additionally, in some cases it wasn't clear to users why the server exited, since the warning message printed to the log, could in some cases be harmless, and in some cases fatal. This PR adds makes a clear distinction between a warning log message and a fatal one, and changes the test suite to look for the fatal message. --- src/server.c | 10 +++++++--- tests/support/server.tcl | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/server.c b/src/server.c index 9fff466da..0ed58c07f 100644 --- a/src/server.c +++ b/src/server.c @@ -3055,7 +3055,7 @@ int listenToPort(int port, socketFds *sfd) { if (sfd->fd[sfd->count] == ANET_ERR) { int net_errno = errno; serverLog(LL_WARNING, - "Could not create server TCP listening socket %s:%d: %s", + "Warning: Could not create server TCP listening socket %s:%d: %s", addr, port, server.neterr); if (net_errno == EADDRNOTAVAIL && optional) continue; @@ -3193,11 +3193,15 @@ void initServer(void) { /* Open the TCP listening socket for the user commands. */ if (server.port != 0 && - listenToPort(server.port,&server.ipfd) == C_ERR) + listenToPort(server.port,&server.ipfd) == C_ERR) { + serverLog(LL_WARNING, "Failed listening on port %u (TCP), aborting.", server.port); exit(1); + } if (server.tls_port != 0 && - listenToPort(server.tls_port,&server.tlsfd) == C_ERR) + listenToPort(server.tls_port,&server.tlsfd) == C_ERR) { + serverLog(LL_WARNING, "Failed listening on port %u (TLS), aborting.", server.tls_port); exit(1); + } /* Open the listening Unix domain socket. */ if (server.unixsocket != NULL) { diff --git a/tests/support/server.tcl b/tests/support/server.tcl index 3ff923d7e..4c1bc37c8 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -253,7 +253,7 @@ proc wait_server_started {config_file stdout pid} { # Check if the port is actually busy and the server failed # for this reason. - if {[regexp {Could not create server TCP} [exec cat $stdout]]} { + if {[regexp {Failed listening on port} [exec cat $stdout]]} { set port_busy 1 break }