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

Better handling of closeables in BasePolarisCatalog #478

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

adutra
Copy link
Contributor

@adutra adutra commented Nov 25, 2024

Even if closeables are collected by CallContext and closed when the request finishes, it is safer to close the catalog's own cloaseables when BasePolarisCatalog.close() is called: this makes it possible to release resources when a test manually creates a catalog, or when the catalog is wrapped within PolarisCatalogHandlerWrapper.

Furthermore, the "request" catalog used by PolarisCatalogHandlerWrapper is stored in CallContext under a different key, and closed manually in PolarisApplication: it is better to add the catalog to the CallContext's closeables group and have it closed automatically when the CallContext is closed.

Comment on lines 269 to 270
this.closeableGroup = CallContext.getCurrentContext().closeables();
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.

Where do these get closed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When BasePolarisCatalog.close() is called.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I think that was my confusion. It looks like there are some objects in the CloseableGroup (the value ofmetricReporter()) that are no longer going in there. I just wanted to double-check where they are getting closed now. Does putting this in the CloseableGroup somehow still do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops you are right, I removed one line accidentally 🤦‍♂️ Thanks for spotting that, fixing.

@adutra adutra force-pushed the close-catalog-fix branch 2 times, most recently from bbcf373 to 4877fc3 Compare November 26, 2024 15:30
Even if closeables are collected by `CallContext` and closed when the request finishes,
it is safer to close the catalog's own cloaseables when `BasePolarisCatalog.close()` is called:
this makes it possible to release resources when a test manually creates a catalog,
or when the catalog is wrapped within `PolarisCatalogHandlerWrapper`.

Furthermore, the "request" catalog used by PolarisCatalogHandlerWrapper is stored
in `CallContext` under a different key, and closed manually in `PolarisApplication`:
it is better to add the catalog to the `CallContext`'s closeables group and have it
closed automatically when the `CallContext` is closed.
Copy link
Contributor

@eric-maynard eric-maynard left a comment

Choose a reason for hiding this comment

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

LGTM!

@eric-maynard eric-maynard merged commit 5980f80 into apache:main Nov 26, 2024
5 checks passed
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.

3 participants