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

Core: Close the MetricsReporter when the Catalog is closed. #9353

Merged
merged 5 commits into from
Jan 18, 2024

Conversation

huyuanfeng2018
Copy link
Contributor

link #9349

@huyuanfeng2018
Copy link
Contributor Author

cc @nastra

.palantir/revapi.yml Outdated Show resolved Hide resolved
@@ -487,6 +486,7 @@ public Configuration getConf() {

@Override
public void close() throws IOException {
super.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is not using closeableGroup a deliberate choice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don’t quite understand what problem can be solved by using closeableGroup it's here, Can you give some examples?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think in order to close metric reporter when cloase the catalog, it can also be implemented to add super.metricsReporter() to closeableGroup on line 143, but this require to change the BaseMetastoreCatalog.metricsReporter() method from private to protected.

This approach keep the Closeable in concrete class instead of abstract base class, and it seem to be more aligned with how other closable are handled in the this class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think in order to close metric reporter when cloase the catalog, it can also be implemented to add super.metricsReporter() to closeableGroup on line 143, but this require to change the BaseMetastoreCatalog.metricsReporter() method from private to protected.

This approach keep the Closeable in concrete class instead of abstract base class, and it seem to be more aligned with how other closable are handled in the this class.

I agree with this statement. In the Java language, it is generally a common practice to call super.close() when a subclass overrides the method of the parent class, so I did do this at the beginning. If want to unify for the closable approach, it is indeed better to use closeableGroup. I will modify this part of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dramaticlly Can you help me take a look?

Copy link
Contributor

Choose a reason for hiding this comment

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

curious, is there any motivation to keep Closable in abstract class BaseMetastoreCatalog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

look here:

Because of this, I think BaseMetastoreCatalog should keep Closeable to limit the behavior of subclasses, because the metricsReporter in BaseMetastoreCatalog must be released when the catalog is closed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's reasonable. In my mind it would have been ideal if metrics reporting was a separate Mixin interface and each concrete implementation implements that mixin ("SupportsMetricsReporting") and takes responsibility for providing a metrics reporter implementation and overriding close. The tradeoff is there is more close implementations but I think it's generally better to have those implementations be at the concrete level. That's a wider change, and probably I'm missing an implication of that design so the current approach is fine to me.

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

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

This looks good to me, although I do think there are some possible improvements we could do for having MetricsReporting being a separate mixin for catalogs, but those are out of scope for what this PR is doing.

I'll wait for a bit in case @aokolnychyi has any further comments before merging.

@@ -143,6 +142,7 @@ void initialize(
this.closeableGroup = new CloseableGroup();
closeableGroup.addCloseable(dynamo);
closeableGroup.addCloseable(fileIO);
closeableGroup.addCloseable(metricsReporter());
Copy link
Contributor

Choose a reason for hiding this comment

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

I just wanted to point out that this effectively will initialize the reporter much earlier (during catalog instantiation) than previously (during table loading). This is probably ok

Copy link
Contributor

@dramaticlly dramaticlly left a comment

Choose a reason for hiding this comment

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

LGTM!

@nastra nastra merged commit 2446cee into apache:main Jan 18, 2024
42 checks passed
@huyuanfeng2018 huyuanfeng2018 deleted the metric_report_close branch January 18, 2024 10:54
geruh pushed a commit to geruh/iceberg that referenced this pull request Jan 26, 2024
adnanhemani pushed a commit to adnanhemani/iceberg that referenced this pull request Jan 30, 2024
devangjhabakh pushed a commit to cdouglas/iceberg that referenced this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants