-
Notifications
You must be signed in to change notification settings - Fork 514
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
HDDS-10184. Fix ManagedStatistics not closed properly #6055
Conversation
@adoroszlai PTAL, thanks you ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @whbing for reporting this issue and working on the fix.
I wonder if Statistics
should be kept open until DBOptions
is closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whbing Thanks working over this
ManagedStatistics is assigned to options, so do options close implicitly on its closer?
Even if we set ManagedStatistics to ManagedOption for closer, will there be twice close or not - One by rocksdb and another by ManagedOption(if its added).
So need to check do really need have leak detection for ManagedStatistics?
@sumitagrawl each object needs to be closed explicitly |
private static GenericTestUtils.LogCapturer log =
GenericTestUtils.LogCapturer.captureLogs(ManagedRocksObjectUtils.LOG);
assertFalse(log.getOutput().contains("is not closed properly")); Simple verification of the startup log, fixed after closing ManagedStatistics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though this fixes this issue, We are closing the ManagedStatistics
object before collecting any stats. I wonder if it records any of the stats if the ManagedStatistics
is closed here.
The gc has already begun to reclaim the ManagedStatistics object after init ManagedStatistics instance during we startup the OM. This indicates that the ManagedStatistics object is not continuously referenced throughout the runtime of OM. Perhaps we should determine exactly when its lifecycle ends. Maybe we can trace the metric changes after close ManagedStatistics to verify if it records any of the stats. |
I tested this for a short period, RocksDB statistics looked OK in Prometheus.
Still, closing |
👍 @adoroszlai Thanks for reminding. I'll add a new commit later |
@adoroszlai PTAL again if you have time , Thanks ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @whbing for updating the patch, LGTM. Two minor possible improvements noted. If you agree with them, only apply them if there are any other requests for changes. Otherwise they are fine to be included in future tasks.
if (statistics != null) { | ||
IOUtils.close(LOG, statistics); | ||
} | ||
IOUtils.close(LOG, db); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: IOUtils.close
accepts multiple objects to be closed, and handles null
values, too.
if (statistics != null) { | |
IOUtils.close(LOG, statistics); | |
} | |
IOUtils.close(LOG, db); | |
IOUtils.close(LOG, db, statistics); |
if (!rocksDbStat.equals(OZONE_METADATA_STORE_ROCKSDB_STATISTICS_OFF)) { | ||
statistics = new ManagedStatistics(); | ||
statistics.setStatsLevel(StatsLevel.valueOf(rocksDbStat)); | ||
dbOptions.setStatistics(statistics); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ManagedStatistics statistics
could be a local variable in build()
.
I don't think it makes any difference functionally, but it would be easier to follow its lifecycle. With instance variable, the reader needs to consider what happens if the same builder is used to build multiple RDBStore
instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The global variable statistics
are easier to pass to the RDBStore
In current method structure, , nothing else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @whbing for the patch. LGTM.
@adoroszlai @aswinshakil @sumitagrawl Thank you for the above review ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @whbing for the fix, @aswinshakil, @sumitagrawl for the review. |
(cherry picked from commit 9018728)
What changes were proposed in this pull request?
When config set:
ManagedStatistics not closed properly in OM and DN:
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-10184
How was this patch tested?