[FLINK-35321] Ensure pendingCommitables metric is not re-registered when copying CommitableCollector#27598
Conversation
Signed-off-by: deamondev <piotr.rudnicki94@protonmail.com>
| this.metricGroup = metricGroup; | ||
| this.metricGroup.setCurrentPendingCommittablesGauge(this::getNumPending); | ||
|
|
||
| if (setCurrentPendingCommitablesGauge) { |
There was a problem hiding this comment.
I think we'll want add a unit test in CommittableCollectorTest.java to verify that copy() does not re-register metrics as expected. A simple metric group stub that counts gauge registrations with before/after assertions should be enough.
There was a problem hiding this comment.
I added unit test by simply using spy method provided by Mockito. I think its more elegant than writing new wrapper with custom reference counting. I reset Mockito's reference counters before each test, so it is thread-safe.
edit: I see mockito is discouraged. I'll rewrite it then.
There was a problem hiding this comment.
Minor suggestion: for consistency, we may also want to update the static ofLegacy() path as well and adjust its collector to reflect the same changes.
There was a problem hiding this comment.
Ok, now the constructor is
public CommittableCollector(
SinkCommitterMetricGroup metricGroup, boolean shouldSetPendingCommittablesGauge) {
this(new TreeMap<>(), metricGroup, shouldSetPendingCommittablesGauge);
}and I adjusted it only in ofLegacy method where I think it should be set to false. Still I'm not quite sure if thats correct. So, I have another request for advice.
|
Thanks for your insight @rionmonster . I wonder on whether I should set this very new flag when spawning |
Yes, I think using
So we don't want to re-reregister the metrics during those transient instances that eventually are just discarded. |
Signed-off-by: deamondev <piotr.rudnicki94@protonmail.com>
Signed-off-by: deamondev <piotr.rudnicki94@protonmail.com>
Signed-off-by: deamondev <piotr.rudnicki94@protonmail.com>
|
@flinkbot run azure |
Signed-off-by: deamondev <piotr.rudnicki94@protonmail.com>
Signed-off-by: deamondev <piotr.rudnicki94@protonmail.com>
What is the purpose of the change
In this PR I add simple flag to constructor of
CommittableCollectorin order to stop re-registeringpendingCommitablesmetric while deep-copy of this class.Verifying this change
This change is already covered by existing tests.
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (yes / no)Documentation