Skip to content

Commit

Permalink
ZOOKEEPER-4199: Avoid thread leak in QuorumRequestPipelineTest
Browse files Browse the repository at this point in the history
`QuorumRequestPipelineTest` hosts parameterized tests which explicitly call `QuorumBase.setUp(boolean)`.

This patch overrides the argument-less `QuorumBase.setUp()` with an empty body, as the former is annotated `BeforeEach`-otherwise causing the runtime to start a fresh 5-ensemble before each test.

Without the override, one such extraneous ensemble is created and immediately leaked for each combination of test method + parameters.

The test consequently requires 4000+ simultaneous threads to complete, and while Linux happily handles that load, macOS Catalina's per-process limit of 2048 threads effectively causes the JVM to "crash" or lock up.

The solution is copied verbatim from another parameterized subclass of `QuorumBase`, `EagerACLFilterTest`.

Author: Damien Diederen <[email protected]>

Reviewers: Enrico Olivelli <[email protected]>, Mate Szalay-Beko <[email protected]>

Closes apache#1591 from ztzg/ZOOKEEPER-4199-thread-leak-qrp-test
  • Loading branch information
ztzg authored and RokLenarcic committed Aug 31, 2022
1 parent 9cb9e3a commit 307080d
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.zookeeper.server.quorum.QuorumPeer.ServerState;
import org.apache.zookeeper.test.QuorumBase;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -59,6 +60,13 @@ public static Stream<Arguments> data() throws Exception {
Arguments.of(ServerState.OBSERVING));
}

@BeforeEach
@Override
public void setUp() {
//since parameterized test methods need a parameterized setUp method
//the inherited method has to be overridden with an empty function body
}

public void setUp(ServerState serverState) throws Exception {
CountdownWatcher clientWatch = new CountdownWatcher();
super.setUp(true);
Expand Down

0 comments on commit 307080d

Please sign in to comment.