Skip to content

[FLINK-40549][metrics] Fix closed metricGroup leak on split finish - #29083

Open
Efrat19 wants to merge 2 commits into
apache:masterfrom
Efrat19:metric-group-leak2
Open

[FLINK-40549][metrics] Fix closed metricGroup leak on split finish#29083
Efrat19 wants to merge 2 commits into
apache:masterfrom
Efrat19:metric-group-leak2

Conversation

@Efrat19

@Efrat19 Efrat19 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Today there's no API to deregister child metric groups added via MetricGroup#addGroup. This is not a problem as long as child metric groups are permanent through parent lifecycle.

For split level metric group this is a problem because they might not live as long as the source (aka splitFinished). As a result we are left with a closed child metric group reference on the parent, preventing the object GC.

Brief change log

  • Remove metricGroup parent reference upon close()
  • Close splitMetricGroup along with the child splitWatermarkMetricGroup

Verifying this change

This change added tests and can be verified as follows:

(example:)

  • Unit tests ensuring the metric groups are closed and dereferenced by the parent.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Co-Generated-by: claude-fable-5

@flinkbot

flinkbot commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Today there's no API to deregister child metric groups added via MetricGroup#addGroup. This is not a problem as long as child metric groups are permanent through parent lifecycle.

For split level metric group this is a problem because they might not live as long as the source (aka splitFinished). As a result we are left with a closed child metric group reference on the parent, preventing the object GC.
…litWatermarkMetricGroup

Previousely we incorrectly closed the child splitWatermarkMetricGroup on split finished, leaving the parent metricGroup unclosed
@Efrat19 Efrat19 changed the title [][] Deregister closed metric groups [FLINK-40549][metrics] Fix closed metricGroup leak on split finish Sep 3, 2026
@Efrat19
Efrat19 marked this pull request as ready for review September 3, 2026 16:36
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.

2 participants