You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "jarredhj0214 (via GitHub)" <gi...@apache.org> on 2026/06/17 10:29:25 UTC
[PR] [MINOR] fix(oceanbase): Avoid MySQL driver version check [gravitino]
jarredhj0214 opened a new pull request, #11717:
URL: https://github.com/apache/gravitino/pull/11717
### What changes were proposed in this pull request?
This PR introduces `OceanBaseCatalogOperations` for the OceanBase JDBC catalog and makes `OceanBaseCatalog` use it instead of `MySQLProtocolCompatibleCatalogOperations`.
The new operations class extends the generic `JdbcCatalogOperations`, so OceanBase catalog initialization no longer applies the MySQL Connector/J major-version check. It still shuts down MySQL Connector/J cleanup resources when present, which keeps the MySQL protocol driver path covered.
A unit test is added to verify that OceanBase catalog uses `OceanBaseCatalogOperations` and does not use `MySQLProtocolCompatibleCatalogOperations`.
### Why are the changes needed?
OceanBase catalog supports both MySQL protocol URLs and OceanBase protocol URLs. Users may configure either MySQL Connector/J or the OceanBase official JDBC driver.
Currently, OceanBase catalog reuses `MySQLProtocolCompatibleCatalogOperations`, which rejects drivers whose major version is lower than 8. This can incorrectly reject OceanBase JDBC drivers, for example `oceanbase-client-2.4.18.jar`, during catalog creation with an error like:
`Mysql catalog does not support the jdbc driver version 2.4.18, minimal required version is 8.0`
This issue is not specific to `2.4.18`; OceanBase JDBC driver 4.x can also be incorrectly rejected because its major version is still lower than 8.
Fix: N/A
### Does this PR introduce _any_ user-facing change?
Yes. Creating an OceanBase catalog with the OceanBase JDBC driver is no longer incorrectly blocked by the MySQL Connector/J version check.
No public API or catalog property is added or removed.
### How was this patch tested?
Added unit coverage in `TestOceanBaseCatalogOperations`.
`git diff --check` passed.
Gradle tests were not run locally because the current machine only has JDK 8 installed, while Gravitino requires JDK 17 to build.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MINOR] fix(oceanbase): Avoid MySQL driver version check [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao merged PR #11717:
URL: https://github.com/apache/gravitino/pull/11717
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MINOR] fix(oceanbase): Avoid MySQL driver version check [gravitino]
Posted by "jarredhj0214 (via GitHub)" <gi...@apache.org>.
jarredhj0214 commented on code in PR #11717:
URL: https://github.com/apache/gravitino/pull/11717#discussion_r3451303549
##########
catalogs-contrib/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/OceanBaseCatalogOperations.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.gravitino.catalog.oceanbase;
+
+import org.apache.gravitino.catalog.jdbc.JdbcCatalogOperations;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcExceptionConverter;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter;
+import org.apache.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations;
+import org.apache.gravitino.catalog.jdbc.operation.JdbcTableOperations;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Operations for interacting with the OceanBase catalog in Apache Gravitino.
+ *
+ * <p>OceanBase supports both MySQL Connector/J and the OceanBase JDBC driver, so it should not use
+ * {@code MySQLProtocolCompatibleCatalogOperations}, which rejects non-MySQL Connector/J drivers by
+ * major version during catalog initialization.
+ */
+public class OceanBaseCatalogOperations extends JdbcCatalogOperations {
Review Comment:
Thanks for the suggestion. I have updated `OceanBaseCatalogOperations` to extend `MySQLProtocolCompatibleCatalogOperations` directly and override `checkJDBCDriverVersion()` to skip the MySQL Connector/J major-version check for OceanBase catalog initialization.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MINOR] fix(oceanbase): Avoid MySQL driver version check [gravitino]
Posted by "geyanggang (via GitHub)" <gi...@apache.org>.
geyanggang commented on code in PR #11717:
URL: https://github.com/apache/gravitino/pull/11717#discussion_r3432833745
##########
catalogs-contrib/catalog-jdbc-oceanbase/src/test/java/org/apache/gravitino/catalog/oceanbase/TestOceanBaseCatalogOperations.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.gravitino.catalog.oceanbase;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.gravitino.catalog.jdbc.MySQLProtocolCompatibleCatalogOperations;
+import org.apache.gravitino.connector.CatalogOperations;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class TestOceanBaseCatalogOperations {
+
+ @Test
+ public void testOceanBaseCatalogUsesOceanBaseOperations() {
+ CatalogOperations operations = new TestableOceanBaseCatalog().newOps(Collections.emptyMap());
+
+ Assertions.assertInstanceOf(OceanBaseCatalogOperations.class, operations);
+ Assertions.assertFalse(operations instanceof MySQLProtocolCompatibleCatalogOperations);
+ }
+
+ @Test
+ public void testCheckJDBCDriverVersionDoesNotRejectOceanBaseDriverVersion() {
+ OceanBaseCatalogOperations operations =
+ new OceanBaseCatalogOperations(null, null, null, null, null);
+
+ Assertions.assertDoesNotThrow(operations::checkJDBCDriverVersion);
+ }
+
+ private static class TestableOceanBaseCatalog extends OceanBaseCatalog {
+ @Override
+ protected CatalogOperations newOps(Map<String, String> config) {
+ return super.newOps(config);
+ }
+ }
Review Comment:
newOps is protected and the test class is in the same package as OceanBaseCatalog, so you can call it directly without the TestableOceanBaseCatalog subclass.
##########
catalogs-contrib/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/OceanBaseCatalogOperations.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.gravitino.catalog.oceanbase;
+
+import org.apache.gravitino.catalog.jdbc.JdbcCatalogOperations;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcExceptionConverter;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter;
+import org.apache.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations;
+import org.apache.gravitino.catalog.jdbc.operation.JdbcTableOperations;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Operations for interacting with the OceanBase catalog in Apache Gravitino.
+ *
+ * <p>OceanBase supports both MySQL Connector/J and the OceanBase JDBC driver, so it should not use
+ * {@code MySQLProtocolCompatibleCatalogOperations}, which rejects non-MySQL Connector/J drivers by
+ * major version during catalog initialization.
+ */
+public class OceanBaseCatalogOperations extends JdbcCatalogOperations {
+ private static final Logger LOG = LoggerFactory.getLogger(OceanBaseCatalogOperations.class);
+
+ /**
+ * Constructs a new instance of {@link OceanBaseCatalogOperations}.
+ *
+ * @param exceptionConverter The exception converter to be used by the operations.
+ * @param jdbcTypeConverter The type converter to be used by the operations.
+ * @param databaseOperation The database operations to be used by the operations.
+ * @param tableOperation The table operations to be used by the operations.
+ * @param columnDefaultValueConverter The column default value converter to be used by the
+ * operations.
+ */
+ public OceanBaseCatalogOperations(
+ JdbcExceptionConverter exceptionConverter,
+ JdbcTypeConverter jdbcTypeConverter,
+ JdbcDatabaseOperations databaseOperation,
+ JdbcTableOperations tableOperation,
+ JdbcColumnDefaultValueConverter columnDefaultValueConverter) {
+ super(
+ exceptionConverter,
+ jdbcTypeConverter,
+ databaseOperation,
+ tableOperation,
+ columnDefaultValueConverter);
+ }
+
+ /** Closes the OceanBase catalog and shuts down MySQL Connector/J cleanup resources if present. */
+ @Override
+ public void close() {
+ super.close();
+
+ try {
+ Class.forName("com.mysql.cj.jdbc.AbandonedConnectionCleanupThread")
+ .getMethod("uncheckedShutdown")
+ .invoke(null);
+ LOG.info("AbandonedConnectionCleanupThread has been shutdown...");
+ } catch (ClassNotFoundException e) {
+ LOG.debug("MySQL AbandonedConnectionCleanupThread was not found", e);
Review Comment:
since the ClassNotFoundException is completely expected when OceanBase's own driver is used (no MySQL classes on classpath), logging the full stack trace at DEBUG level is unnecessary noise. Consider dropping the exception parameter:
} catch (ClassNotFoundException e) {
LOG.debug("MySQL AbandonedConnectionCleanupThread not found on classpath, skipping shutdown");
}
##########
catalogs-contrib/catalog-jdbc-oceanbase/src/test/java/org/apache/gravitino/catalog/oceanbase/TestOceanBaseCatalogOperations.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.gravitino.catalog.oceanbase;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.gravitino.catalog.jdbc.MySQLProtocolCompatibleCatalogOperations;
+import org.apache.gravitino.connector.CatalogOperations;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class TestOceanBaseCatalogOperations {
+
+ @Test
+ public void testOceanBaseCatalogUsesOceanBaseOperations() {
+ CatalogOperations operations = new TestableOceanBaseCatalog().newOps(Collections.emptyMap());
+
+ Assertions.assertInstanceOf(OceanBaseCatalogOperations.class, operations);
+ Assertions.assertFalse(operations instanceof MySQLProtocolCompatibleCatalogOperations);
+ }
+
+ @Test
+ public void testCheckJDBCDriverVersionDoesNotRejectOceanBaseDriverVersion() {
+ OceanBaseCatalogOperations operations =
+ new OceanBaseCatalogOperations(null, null, null, null, null);
+
+ Assertions.assertDoesNotThrow(operations::checkJDBCDriverVersion);
+ }
Review Comment:
Mind adding a quick comment here to explain what this test is for?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MINOR] fix(oceanbase): Avoid MySQL driver version check [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11717:
URL: https://github.com/apache/gravitino/pull/11717#issuecomment-4764318647
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|67.16%|:green_circle:|
|:-|:-|:-:|
|Files changed|51.85%|:red_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|46.82%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|aws|3.66%|:red_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|10.4%|:red_circle:|
|catalog-fileset|80.23%|:green_circle:|
|catalog-glue|66.91%|:green_circle:|
|catalog-hive|79.42%|:green_circle:|
|catalog-jdbc-clickhouse|80.02%|:green_circle:|
|catalog-jdbc-common|44.22%|:green_circle:|
|catalog-jdbc-doris|80.28%|:green_circle:|
|catalog-jdbc-hologres|54.03%|:green_circle:|
|catalog-jdbc-mysql|79.23%|:green_circle:|
|catalog-jdbc-oceanbase|78.98% **`-1.52%`**|:green_circle:|
|catalog-jdbc-postgresql|82.29%|:green_circle:|
|catalog-jdbc-starrocks|78.51%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|58.53%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.94%|:green_circle:|
|catalog-lakehouse-paimon|82.14%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.51%|:green_circle:|
|client-java|78.01%|:green_circle:|
|common|50.17%|:green_circle:|
|core|82.59%|:green_circle:|
|filesystem-hadoop3|77.27%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|47.12%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-common|10.88%|:red_circle:|
|hive-metastore-common|53.77%|:green_circle:|
|iceberg-common|58.15%|:green_circle:|
|iceberg-rest-server|73.9%|:green_circle:|
|idp-basic|86.2%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|66.17%|:green_circle:|
|lance-common|20.83%|:red_circle:|
|lance-rest-server|60.13%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|82.95%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|85.96%|:green_circle:|
|server-common|74.18%|:green_circle:|
|spark|28.57%|:red_circle:|
|spark-common|41.66%|:green_circle:|
|trino-connector|40.25%|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|catalog-jdbc-oceanbase|[OceanBaseCatalog.java](https://github.com/jarredhj0214/gravitino/blob/43fc7b17f20d89b6ca47bc3c5659949ea820c4c2/catalogs-contrib/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/OceanBaseCatalog.java)|84.62%|:green_circle:|
||[OceanBaseCatalogOperations.java](https://github.com/jarredhj0214/gravitino/blob/43fc7b17f20d89b6ca47bc3c5659949ea820c4c2/catalogs-contrib/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/OceanBaseCatalogOperations.java)|21.43%|:red_circle:|
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MINOR] fix(oceanbase): Avoid MySQL driver version check [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #11717:
URL: https://github.com/apache/gravitino/pull/11717#discussion_r3449423899
##########
catalogs-contrib/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/OceanBaseCatalogOperations.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.gravitino.catalog.oceanbase;
+
+import org.apache.gravitino.catalog.jdbc.JdbcCatalogOperations;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcExceptionConverter;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter;
+import org.apache.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations;
+import org.apache.gravitino.catalog.jdbc.operation.JdbcTableOperations;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Operations for interacting with the OceanBase catalog in Apache Gravitino.
+ *
+ * <p>OceanBase supports both MySQL Connector/J and the OceanBase JDBC driver, so it should not use
+ * {@code MySQLProtocolCompatibleCatalogOperations}, which rejects non-MySQL Connector/J drivers by
+ * major version during catalog initialization.
+ */
+public class OceanBaseCatalogOperations extends JdbcCatalogOperations {
Review Comment:
You can directly extend `MySQLProtocolCompatibleCatalogOperations` and overwrite `checkJDBCDriverVersion` to simply the code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MINOR] fix(oceanbase): Avoid MySQL driver version check [gravitino]
Posted by "jarredhj0214 (via GitHub)" <gi...@apache.org>.
jarredhj0214 commented on PR #11717:
URL: https://github.com/apache/gravitino/pull/11717#issuecomment-4763960575
Thanks for the review. I have addressed all three comments:
- Removed the exception parameter from the expected ClassNotFoundException debug log.
- Removed the unnecessary TestableOceanBaseCatalog subclass and call newOps directly.
- Added a short comment explaining the JDBC driver version test.
@geyanggang
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org