-
Notifications
You must be signed in to change notification settings - Fork 344
Move JDBC Quarkus configuration to the JDBC persistence module #3281
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
base: main
Are you sure you want to change the base?
Conversation
| import org.apache.polaris.persistence.relational.jdbc.RelationalJdbcConfiguration; | ||
|
|
||
| @ConfigMapping(prefix = "polaris.persistence.relational.jdbc") | ||
| public interface QuarkusRelationalJdbcConfiguration extends RelationalJdbcConfiguration {} |
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.
This subinterface is now useless. I suggest removing it and placing the @ConfigMapping annotation directly on RelationalJdbcConfiguration.
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.
Great idea! Changed per your suggestion.
| compileOnly(libs.smallrye.config.core) // @ConfigMapping for Quarkus integration | ||
| implementation(libs.smallrye.common.annotation) // @Identifier | ||
| implementation(libs.postgresql) | ||
| implementation(platform(libs.quarkus.amazon.services.bom)) |
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.
This new dependency is intriguing. This module doesn't need the RDS extension for compilation, not even for tests. If the intent is to create a Polaris server distribution that supports Amazon RDS, I wonder if a better approach wouldn't be to include the RDS Quarkus extension directly in polaris-server?
Conversely, if we decide to keep this dependency here: it is bringing quarkus-core transitively. This means that this module becomes de facto a Quarkus module. In this case we should declare the dependency implementation(platform(libs.quarkus.bom)) and add the Quarkus plugin.
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.
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.
It isn't new dependency. As you said, it was there for a while. It looks like #3252 didn't do anything about it. Let me know if I missed something.
At this moment, I think it'd be nice to keep as is until we find a better place to hold it. I'm a bit concern that if we removed it here, but didn't get the chance to place it anywhere before next release, it will break users. With that, we might just keep this PR as a pure refactor. WDYT?
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.
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.
I do believe that runtime library dependencies should be concentrated in the runtime/server module.
So, I do not think bringing RDS as an implementation dependency into JDBC persistence is justified. JDBC persistence code should not depend on specific drivers, only on JDBC interfaces.
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.
JDBC Persistence and other similar modules compile against their respective interfaces.
The runtime/server module includes drivers (PostgreSQL, RDS, etc.) according to the Polaris project decisions - whatever is supposed to be included in the ASF releases. This does not have to be an all-encompassing list.
In this regard, the runtime/server module is essentially the "default" server "package".
Downstream projects are not supposed to reuse runtime/server directly.
Downstream projects reuse JDBC Persistence, runtime/service, etc... as needed and build a custom server. Downstream projects also include libraries / drivers as needed according to the needs of the downstream project.
For example, PostgreSQL or RDS code may or may not be included - the decision should rest with the downstream project IMHO. A downstream project may even choose to use a completely different JDBC driver.
Conversely, with the current state of this PR, RDS is an impl. dependency of JDBC Persistence and NOT including it in downstream builds requires extra work at explicitly preventing RDS jars from leaking into custom builds... which is very inconvenient.
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 for the explanation.
The default dependencies, esp. drivers are not only used by runtime/server, but also the admin module. Instead of adding them to both, how about putting them in the runtime/default module, and let both admin and server depend on runtime/default? I think the downstream projects are also not supposed to directly reuse the runtime/default module. WDYT?
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.
Good point about adding common server/admin dependencies to runtime/default... I kind of forgot about it 😅 but indeed I added it a long time ago precisely for this purpose 👍
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.
With that, I'm probably not going to need #3252 at all :) ... but I'll revisit after this PR is merged ;)
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.
Fixed it in the new commits. I think we should start to put the driver in the default module moving forward. We could move this to the runtime/default as well in a followup.
runtimeOnly("org.postgresql:postgresql")
With that, I'm probably not going to need #3252 at all :)
You can buy me a drink :-)
singhpk234
left a comment
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 @flyrain
| import io.smallrye.config.ConfigMapping; | ||
| import java.util.Optional; | ||
|
|
||
| @ConfigMapping(prefix = "polaris.persistence.relational.jdbc") |
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.
I do not oppose this change, but I'd like to highlight that this will impose the config naming convention defined in this annotation on downstream projects. It may be possible to provide a different config object for JDBC downstream or it may not be... I cannot say for sure.
Old code delegated runtime configuration to the server runtime, so this may be a behaviour change in downstream projects.
Given that NoSQL code follows a similar approach (not splitting interfaces and @ConfigMapping) this change looks reasonable to me.
| compileOnly(libs.smallrye.config.core) // @ConfigMapping for Quarkus integration | ||
| implementation(libs.smallrye.common.annotation) // @Identifier | ||
| implementation(libs.postgresql) | ||
| implementation(platform(libs.quarkus.amazon.services.bom)) |
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.
I do believe that runtime library dependencies should be concentrated in the runtime/server module.
So, I do not think bringing RDS as an implementation dependency into JDBC persistence is justified. JDBC persistence code should not depend on specific drivers, only on JDBC interfaces.
| metaStoreManagerMap.remove(realm); | ||
| } catch (IllegalStateException e) { | ||
| // Realm is not bootstrapped, return a failed result | ||
| results.put(realm, new BaseResult(BaseResult.ReturnStatus.ENTITY_NOT_FOUND, e.getMessage())); |
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.
To fix
RelationalJdbcPurgeCommandTest > testPurgeFailure(LaunchResult) FAILED
org.assertj.core.error.AssertJMultipleFailuresError at PurgeCommandTestBase.java:48
This is needed as runtime-defaults has configuration file application.properties with Quarkus configuration like logging, console, or output-related settings, which interferes with how Quarkus Main tests capture stdout. When the exception is thrown, the output isn't captured in LaunchResult.getOutput(). It only goes to logs. This causes the test assertion to fail because result.getOutput() is empty.
The fix ensures that when a realm isn't bootstrapped, the PurgeCommand receives a failed BaseResult and can properly write the error message to stdout,
polaris/runtime/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java
Line 53 in dc4e343
| failed.forEach( |
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.
Hi @flyrain , the logic in your message LGTM, but the logic in the code is not specific enough, I'm afraid.
Catching IllegalStateException does not necessarily mean that the failure is due to realm not having been bootstrapped.
Is it possible to make this change more specific to the bootstrap use case?
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.
I'm fine with catching IllegalStateException in general, but why should the status be ENTITY_NOT_FOUND when we do not really know the root reason 🤔 ?
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.
Actually, the matter might be related to mixing runtime/admin/src/main/resources/application.properties and runtime/defaults/src/main/resources/application.properties (or perhaps application-test.properties).
In my experience having more than one application.properties file in a Quarkus build leads to very obscure behaviours. So far I thought it was only happening when external jars (with application.properties were on the class path), but apparently the oddities happen in a multi-module build too 🤔
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.
I'm afraid the runtime/defaults module will have to be limited to holding only the application.properties for servers (shared with test modules).
We can probably keep the Quarkus config refactoring in this PR, but the common module may have to stay to hold dependencies shared between the server and admin tools. WDYT?
Removes the
polaris-runtime-commonmodule and updates dependent modules accordingly.Quarkus/JDBC configuration is moved to and owned by the JDBC persistence module, where it fits more naturally. No behavior changes expected.
Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)