Skip to content

Fix memory leaks in expired matchers#3358

Merged
knative-prow[bot] merged 1 commit into
knative:mainfrom
dsimansk:pr/fix-tracker-leak
May 28, 2026
Merged

Fix memory leaks in expired matchers#3358
knative-prow[bot] merged 1 commit into
knative:mainfrom
dsimansk:pr/fix-tracker-leak

Conversation

@dsimansk
Copy link
Copy Markdown
Contributor

Changes

  • Fix memory leak in metrics' expired matchers

Memory leaks observed in @maschmid long running soak tests:

After pruning expired inexact matchers, the code checked len(s) (the exact matchers map) instead of len(ms) (the inexact matchers map), and then deleted from i.exact instead of i.inexact. This meant empty inexact matcher entries were never cleaned up, causing a memory leak for every label-selector-based tracker reference.

When removing inexact matchers for a deleted object, the code called delete(i.exact, ref) instead of delete(i.inexact, ref), so empty inexact entries accumulated indefinitely and could also incorrectly remove unrelated exact entries.

Release Note

Fix memory leak in metrics' expired matchers

PTAL, it's a follow-up to other memory leak in networking hanging idle connections.

/cc @dprotaso

@knative-prow knative-prow Bot requested a review from dprotaso May 27, 2026 08:51
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 27, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.85%. Comparing base (71f6ad6) to head (d194ed4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3358   +/-   ##
=======================================
  Coverage   74.85%   74.85%           
=======================================
  Files         189      189           
  Lines        8347     8347           
=======================================
  Hits         6248     6248           
  Misses       1854     1854           
  Partials      245      245           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dsimansk
Copy link
Copy Markdown
Contributor Author

/cc @maschmid @linkvt

@knative-prow knative-prow Bot requested review from linkvt and maschmid May 27, 2026 12:45
Copy link
Copy Markdown
Member

@linkvt linkvt left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold in case Dave should also take a look, feel free to unhold

@knative-prow knative-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 27, 2026
@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2026
@dprotaso
Copy link
Copy Markdown
Member

I don't generally like the tests accessing the internals - but I see the style is just complementing what's already there so I don't want to gate the PR on that

/hold cancel

@knative-prow knative-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 28, 2026
@knative-prow knative-prow Bot merged commit 0dbbb5a into knative:main May 28, 2026
38 checks passed
@dsimansk
Copy link
Copy Markdown
Contributor Author

/cherry-pick release-1.22
/cherry-pick release-1.21

@knative-prow-robot
Copy link
Copy Markdown
Contributor

@dsimansk: new pull request created: #3359

Details

In response to this:

/cherry-pick release-1.22
/cherry-pick release-1.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow-robot
Copy link
Copy Markdown
Contributor

@dsimansk: new pull request created: #3360

Details

In response to this:

/cherry-pick release-1.22
/cherry-pick release-1.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants