Skip to content
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

Fix Netty4HttpServerTransportTests testChannelAcceptorCannotTamperThreadContext #108374

Conversation

albertzaharovits
Copy link
Contributor

Fix Netty4HttpServerTransportTests testChannelAcceptorCannotTamperThreadContext

Closes #108193

@albertzaharovits albertzaharovits added >test Issues or PRs that are addressing/adding tests :Security/Security Security issues without another label labels May 7, 2024
@albertzaharovits albertzaharovits self-assigned this May 7, 2024
@@ -568,11 +568,9 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th
}
};
// there's only one netty worker thread that's reused across client requests
Settings settings = Settings.builder()
.put(Netty4Plugin.WORKER_COUNT.getKey(), 1)
Settings settings = createBuilderWithPort().put(Netty4Plugin.WORKER_COUNT.getKey(), 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the problem. I think the error we're seeing in #108193 is an exception due to an RST state for the socket.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Funnily, this was the first thing I tried. Not sure why it failed for me before, but I re-tested it now and it passes without exceptions.

for (int i = 0; i < nRetries; i++) {
acceptChannel.set(randomBoolean());
try (Netty4HttpClient client = new Netty4HttpClient()) {
try (Netty4HttpClient client = new Netty4HttpClient()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, I think it's "better" to reuse the client. If there is context pollution, it will first show up across different requests from the same client, before leaking across clients (because clients are statically assigned to a single thread).

.put(Netty4Plugin.SETTING_HTTP_WORKER_COUNT.getKey(), 0)
.build();
NioEventLoopGroup group = new NioEventLoopGroup();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not used.

Copy link
Contributor

@slobodanadamovic slobodanadamovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@albertzaharovits albertzaharovits merged commit 4c8d152 into elastic:main May 8, 2024
14 checks passed
@albertzaharovits albertzaharovits deleted the fix-testChannelAcceptorCannotTamperThreadContext branch May 8, 2024 07:25
albertzaharovits added a commit to albertzaharovits/elasticsearch that referenced this pull request May 8, 2024
…eadContext (elastic#108374)

Fix Netty4HttpServerTransportTests testChannelAcceptorCannotTamperThreadContext
elasticsearchmachine pushed a commit that referenced this pull request May 8, 2024
…eadContext (#108374) (#108399)

Fix Netty4HttpServerTransportTests testChannelAcceptorCannotTamperThreadContext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Security/Security Security issues without another label >test Issues or PRs that are addressing/adding tests v8.14.1 v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI] Netty4HttpServerTransportTests testChannelAcceptorCannotTamperThreadContext failing
2 participants