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 connection leak in Prometheus and in Oauth2 tests #17411

Merged
merged 3 commits into from
May 10, 2023

Conversation

findepi
Copy link
Member

@findepi findepi commented May 9, 2023

No description provided.

findepi added 3 commits May 9, 2023 16:49
- avoid resource allocation in constructor
- close okhttp client
- close Response (fix connection leak)
- do not use ImmutableMap as return type
okhttp's Response needs to be closed.
Also improve message in TaskId constructor checks.
@findepi findepi added the no-release-notes This pull request does not require release notes entry label May 9, 2023
@cla-bot cla-bot bot added the cla-signed label May 9, 2023
@@ -140,11 +137,20 @@ protected abstract TestingHydraIdentityProvider getHydraIdp()
public void tearDown()
throws Exception
{
Logging logging = Logging.initialize();
Copy link
Member

Choose a reason for hiding this comment

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

this is not needed, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

define "this".

logging reconfiguration was pre-existing here. i am fine removing it, if we tell me it's not needed.

server,
hydraIdP,
() -> {
httpClient.dispatcher().executorService().shutdown();
Copy link
Member

Choose a reason for hiding this comment

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

Should we have some kind of wrapper on OkHttpClient to make it closeable. It looks like it is not trivial thing to close it and an easy mistake to have.

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea. i will not do this within this PR though, hope that's ok

@@ -164,18 +164,15 @@ private Map<String, Object> fetchMetrics(JsonCodec<Map<String, Object>> metricsC
public byte[] fetchUri(URI uri)
{
Request.Builder requestBuilder = new Request.Builder().url(uri.toString());
Response response;
Copy link
Member

Choose a reason for hiding this comment

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

How did you found it? Can we have static code analyzer for it?

Copy link
Member Author

Choose a reason for hiding this comment

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

okhttp reports leaked connection by logging a warning. I noticed "leaked" in the test output when trying to understand what's going on in #16933
it just happened that TestMarkDistinctOperator was running concurrently with TestOAuth2WebUiAuthenticationFilterWithJwt

i don't know about a way to automate that and refuse to do this as part of this PR, i hope this is ok

@findepi
Copy link
Member Author

findepi commented May 10, 2023

@findepi findepi merged commit 88a16c4 into trinodb:master May 10, 2023
@findepi findepi deleted the findepi/rcc branch May 10, 2023 12:03
@github-actions github-actions bot added this to the 417 milestone May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed no-release-notes This pull request does not require release notes entry
Development

Successfully merging this pull request may close these issues.

2 participants