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

proxy: fix memory leak again #5909

Merged
merged 2 commits into from
Nov 23, 2023
Merged

proxy: fix memory leak again #5909

merged 2 commits into from
Nov 23, 2023

Conversation

conradludgate
Copy link
Contributor

Problem

The connections.join_next helped but it wasn't enough... The way I implemented the improvement before was still faulty but it mostly worked so it looked like it was working correctly.

From tokio::select docs:

  1. Once an returns a value, attempt to apply the value to the provided , if the pattern matches, evaluate and return. If the pattern does not match, disable the current branch and for the remainder of the current call to select!. Continue from step 3.

The connections.join_next() future would complete and Some(Err(e)) branch would be evaluated but not match (as the future would complete without panicking, we would hope). Since the branch doesn't match, it's disabled. The select continues but never attempts to call join_next again. Getting unlucky, more TCP connections are created than we attempt to join_next.

Summary of changes

Replace the Some(Err(e)) pattern with Some(e). Because of the auto-disabling feature, we don't need the if !connections.is_empty() step as the None pattern will disable it for us.

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.
  • Do we need to implement analytics? if so did you add the relevant metrics to the dashboard?
  • If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section.

Checklist before merging

  • Do not forget to reformat commit message to not include the above checklist

@conradludgate conradludgate requested a review from a team as a code owner November 23, 2023 18:13
@conradludgate conradludgate enabled auto-merge (squash) November 23, 2023 18:18
@arpad-m
Copy link
Member

arpad-m commented Nov 23, 2023

I think comments would help in this instance, that this ensures faster dropping.

Copy link
Member

@koivunej koivunej left a comment

Choose a reason for hiding this comment

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

Asked on slack about a third place which I misremembered, great find!

Copy link

github-actions bot commented Nov 23, 2023

2412 tests run: 2284 passed, 0 failed, 128 skipped (full report)


Flaky tests (5)

Postgres 16

  • test_ondemand_download_timetravel[real_s3]: debug
  • test_pageserver_restarts_under_worload: debug
  • test_timeline_deletion_with_files_stuck_in_upload_queue: release

Postgres 15

  • test_pageserver_restarts_under_worload: debug

Postgres 14

  • test_get_tenant_size_with_multiple_branches: release

Code coverage (full report)

  • functions: 54.2% (8987 of 16592 functions)
  • lines: 81.5% (52455 of 64358 lines)

The comment gets automatically updated with the latest test results
a4f09be at 2023-11-23T19:23:22.725Z :recycle:

@conradludgate conradludgate merged commit a56fd45 into main Nov 23, 2023
40 checks passed
@conradludgate conradludgate deleted the proxy-memory-leak-2 branch November 23, 2023 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants