-
Notifications
You must be signed in to change notification settings - Fork 495
Fix Production readiness for Persistence #1707
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
Merged
singhpk234
merged 4 commits into
apache:main
from
singhpk234:fix/remove-production-readinees-check
May 30, 2025
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...olaris/extension/persistence/relational/jdbc/RelationalJdbcProductionReadinessChecks.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.polaris.extension.persistence.relational.jdbc; | ||
|
|
||
| import jakarta.enterprise.context.ApplicationScoped; | ||
| import jakarta.enterprise.inject.Produces; | ||
| import java.util.Optional; | ||
| import org.apache.polaris.core.config.ProductionReadinessCheck; | ||
| import org.apache.polaris.core.persistence.MetaStoreManagerFactory; | ||
| import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
|
||
| @ApplicationScoped | ||
| public class RelationalJdbcProductionReadinessChecks { | ||
| @Produces | ||
| public ProductionReadinessCheck checkRelationalJdbc( | ||
| @ConfigProperty(name = "quarkus.datasource.jdbc.url") Optional<String> jdbcUrl, | ||
| MetaStoreManagerFactory metaStoreManagerFactory) { | ||
| // This check should only be applicable when persistence uses RelationalJdbc. | ||
| if (!(metaStoreManagerFactory instanceof JdbcMetaStoreManagerFactory)) { | ||
| return ProductionReadinessCheck.OK; | ||
| } | ||
|
|
||
| if (jdbcUrl.isPresent() && jdbcUrl.get().startsWith("jdbc:h2")) { | ||
| return ProductionReadinessCheck.of( | ||
| ProductionReadinessCheck.Error.of( | ||
| "The current persistence (jdbc:h2) is intended for tests only.", | ||
| "quarkus.datasource.jdbc.url")); | ||
| } | ||
| return ProductionReadinessCheck.OK; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 might be more reliable, plus it's in sync with actual persistence usage:
polaris/extension/persistence/relational-jdbc/src/main/java/org/apache/polaris/extension/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java
Line 119 in 2a69415
The EclipseLink side is good to merge, IMHO, so if you prefer we could move this to a separate PR.
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 would not mind adding this:
JdbcMetaStoreManagerFactory.getDatabaseType()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.
sounds good, tbh i think the h2 check is fine, though one thing i realized doing this will also check the connection is properly made to the DB and if its not then we simply fail early that your DB is misconfigured correct it !
let me make the change should be small IMHO
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 connections. Although, I would not fail the startup in that case, maybe just produce a warning check?
Uh oh!
There was an error while loading. Please reload this page.
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.
In general, connection checks should be part of the "readiness" check.
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.
Agree, though i prefer failing as without persistence we can't use the application at all, let me know if you feel strongly otherwise.