-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Keep track and release Reactor Netty 4 Transport accepted Http Channels during the Node shutdown #20106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andrross
merged 14 commits into
opensearch-project:main
from
fdesu:issue/20034-fix-flaky-msearch-error-reporting-smoke-tests
Dec 2, 2025
Merged
Keep track and release Reactor Netty 4 Transport accepted Http Channels during the Node shutdown #20106
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
719398d
Close RestClient after MSearch API calls to reliably close HttpChannels
fdesu a76f224
Add the CHANGELOG entry
fdesu 25166b1
Merge remote-tracking branch 'upstream/main' into issue/20034-fix-fla…
fdesu b975d8e
Keep track of Reactor Netty 4 Transport accepted Http Channels
fdesu 2d55d7f
Merge remote-tracking branch 'upstream/main' into issue/20034-fix-fla…
fdesu 4abed82
Update CHANGELOG
fdesu 6fa89ac
Add missing visibility modifier to RestCancellableNodeClient#getNumTasks
fdesu 4e56c55
Extract channel wrapper into a separate class and extend the get() fo…
fdesu e8f44c5
Add missing javadocs
fdesu 77606c7
Hook into AbstractHttpServerTransport directly from Reactor Request C…
fdesu d8ed05b
Make sure the CloseContext is always called even if the channel is di…
reta 84ee332
Remove extra code
fdesu d91400a
Add more coverage for streaming and non-streaming netty connections
fdesu 93a3457
Revert visibility modifier of the RestCancellableNodeClient#getNumTasks
fdesu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...ClusterTest/java/org/opensearch/transport/netty4/Netty4HttpChannelsReleaseIntegTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| */ | ||
|
|
||
| package org.opensearch.transport.netty4; | ||
|
|
||
| import org.opensearch.OpenSearchNetty4IntegTestCase; | ||
| import org.opensearch.client.Request; | ||
| import org.opensearch.client.Response; | ||
| import org.opensearch.core.common.Strings; | ||
| import org.opensearch.core.xcontent.MediaTypeRegistry; | ||
| import org.opensearch.index.query.MatchAllQueryBuilder; | ||
| import org.opensearch.rest.action.RestCancellableNodeClient; | ||
| import org.opensearch.search.builder.SearchSourceBuilder; | ||
| import org.opensearch.test.OpenSearchIntegTestCase; | ||
| import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope; | ||
| import org.opensearch.threadpool.TestThreadPool; | ||
| import org.opensearch.threadpool.ThreadPool; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.concurrent.CountDownLatch; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
| import static org.hamcrest.Matchers.anyOf; | ||
| import static org.hamcrest.Matchers.equalTo; | ||
|
|
||
| @ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1) | ||
| public class Netty4HttpChannelsReleaseIntegTests extends OpenSearchNetty4IntegTestCase { | ||
|
|
||
| @Override | ||
| protected boolean addMockHttpTransport() { | ||
| return false; // enable http | ||
| } | ||
|
|
||
| private ThreadPool threadPool; | ||
|
|
||
| @Before | ||
| public void createThreadPool() { | ||
| threadPool = new TestThreadPool(getClass().getName()); | ||
| } | ||
|
|
||
| @After | ||
| public void stopThreadPool() { | ||
| ThreadPool.terminate(threadPool, 5, TimeUnit.SECONDS); | ||
| } | ||
|
|
||
| public void testAcceptedChannelsGetCleanedUpOnTheNodeShutdown() throws InterruptedException { | ||
| String testIndex = "test_idx"; | ||
| assertAcked(client().admin().indices().prepareCreate(testIndex)); | ||
|
|
||
| int initialHttpChannels = RestCancellableNodeClient.getNumChannels(); | ||
| int numChannels = randomIntBetween(50, 100); | ||
| CountDownLatch countDownLatch = new CountDownLatch(numChannels); | ||
| for (int i = 0; i < numChannels; i++) { | ||
| threadPool.generic().execute(() -> { | ||
| executeRequest(testIndex); | ||
| countDownLatch.countDown(); | ||
| }); | ||
| } | ||
| countDownLatch.await(); | ||
|
|
||
| // no channels get closed in this test, hence we expect as many channels as we created in the map | ||
| assertEquals("All channels remain open", initialHttpChannels + numChannels, RestCancellableNodeClient.getNumChannels()); | ||
| assertEquals(0, RestCancellableNodeClient.getNumTasks()); | ||
| } | ||
|
|
||
| /** | ||
| * Execute a Search request against the given index. The Search requests are tracked | ||
| * by the RestCancellableNodeClient to verify that channels are released properly. | ||
| * | ||
| * @param index the index to search against | ||
| */ | ||
| private static void executeRequest(String index) { | ||
| try { | ||
| Request request = new Request("GET", "/" + index + "/_search"); | ||
| SearchSourceBuilder searchSource = new SearchSourceBuilder().query(new MatchAllQueryBuilder()); | ||
| request.setJsonEntity(Strings.toString(MediaTypeRegistry.JSON, searchSource)); | ||
| Response response = getRestClient().performRequest(request); | ||
| assertThat(response.getStatusLine().getStatusCode(), anyOf(equalTo(200), equalTo(201))); | ||
| } catch (IOException e) { | ||
| throw new IllegalStateException("Failed to execute the request", e); | ||
| } | ||
| } | ||
|
|
||
| } |
92 changes: 92 additions & 0 deletions
92
...t/java/org/opensearch/http/reactor/netty4/ReactorNetty4HttpChannelsReleaseIntegTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| */ | ||
|
|
||
| package org.opensearch.http.reactor.netty4; | ||
|
|
||
| import org.opensearch.OpenSearchReactorNetty4IntegTestCase; | ||
| import org.opensearch.client.Request; | ||
| import org.opensearch.client.Response; | ||
| import org.opensearch.core.common.Strings; | ||
| import org.opensearch.core.xcontent.MediaTypeRegistry; | ||
| import org.opensearch.index.query.MatchAllQueryBuilder; | ||
| import org.opensearch.rest.action.RestCancellableNodeClient; | ||
| import org.opensearch.search.builder.SearchSourceBuilder; | ||
| import org.opensearch.test.OpenSearchIntegTestCase; | ||
| import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope; | ||
| import org.opensearch.threadpool.TestThreadPool; | ||
| import org.opensearch.threadpool.ThreadPool; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.concurrent.CountDownLatch; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
| import static org.hamcrest.Matchers.anyOf; | ||
| import static org.hamcrest.Matchers.equalTo; | ||
|
|
||
| @ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1) | ||
| public class ReactorNetty4HttpChannelsReleaseIntegTests extends OpenSearchReactorNetty4IntegTestCase { | ||
|
|
||
| @Override | ||
| protected boolean addMockHttpTransport() { | ||
| return false; // enable http | ||
| } | ||
|
|
||
| private ThreadPool threadPool; | ||
|
|
||
| @Before | ||
| public void createThreadPool() { | ||
| threadPool = new TestThreadPool(getClass().getName()); | ||
| } | ||
|
|
||
| @After | ||
| public void stopThreadPool() { | ||
| ThreadPool.terminate(threadPool, 5, TimeUnit.SECONDS); | ||
| } | ||
|
|
||
| public void testAcceptedChannelsGetCleanedUpOnTheNodeShutdown() throws InterruptedException { | ||
| String testIndex = "test_idx"; | ||
| assertAcked(client().admin().indices().prepareCreate(testIndex)); | ||
|
|
||
| int initialHttpChannels = RestCancellableNodeClient.getNumChannels(); | ||
| int numChannels = randomIntBetween(50, 100); | ||
| CountDownLatch countDownLatch = new CountDownLatch(numChannels); | ||
| for (int i = 0; i < numChannels; i++) { | ||
| threadPool.generic().execute(() -> { | ||
| executeRequest(testIndex); | ||
| countDownLatch.countDown(); | ||
| }); | ||
| } | ||
| countDownLatch.await(); | ||
|
|
||
| // no channels get closed in this test, hence we expect as many channels as we created in the map | ||
| assertEquals("All channels remain open", initialHttpChannels + numChannels, RestCancellableNodeClient.getNumChannels()); | ||
| assertEquals(0, RestCancellableNodeClient.getNumTasks()); | ||
| } | ||
|
|
||
| /** | ||
| * Execute a Search request against the given index. The Search requests are tracked | ||
| * by the RestCancellableNodeClient to verify that channels are released properly. | ||
| * | ||
| * @param index the index to search against | ||
| */ | ||
| private static void executeRequest(String index) { | ||
| try { | ||
| Request request = new Request("GET", "/" + index + "/_search"); | ||
| SearchSourceBuilder searchSource = new SearchSourceBuilder().query(new MatchAllQueryBuilder()); | ||
| request.setJsonEntity(Strings.toString(MediaTypeRegistry.JSON, searchSource)); | ||
| Response response = getRestClient().performRequest(request); | ||
| assertThat(response.getStatusLine().getStatusCode(), anyOf(equalTo(200), equalTo(201))); | ||
| } catch (IOException e) { | ||
| throw new IllegalStateException("Failed to execute the request", e); | ||
| } | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.