You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/01/27 02:32:09 UTC

[GitHub] [druid] clintropolis opened a new pull request #12205: use reflection to check for mysql transient exception type

clintropolis opened a new pull request #12205:
URL: https://github.com/apache/druid/pull/12205


   Missed this in #11402, this change will make the `MySQLConnector` implementation of `SQLMetadataConnector.connectorIsTransientException` not explode when using MariaDB driver (and added javadocs that only vendor specific errors need handled here). I poked around the MariaDB connector and didn't find any obvious custom transient exceptions to add here for it.


-- 
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@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] abhishekagarwal87 commented on a change in pull request #12205: use reflection to check for mysql transient exception type

Posted by GitBox <gi...@apache.org>.
abhishekagarwal87 commented on a change in pull request #12205:
URL: https://github.com/apache/druid/pull/12205#discussion_r793243733



##########
File path: extensions-core/mysql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/mysql/MySQLConnector.java
##########
@@ -241,4 +241,19 @@ public DBI getDBI()
   {
     return dbi;
   }
+
+  @VisibleForTesting
+  static boolean isTransientException(ClassLoader classLoader, String driverName, Throwable e)
+  {
+    if (driverName.contains("mysql")) {
+      try {
+        Class<?> clazz = Class.forName(MYSQL_TRANSIENT_EXCEPTION_CLASS_NAME, false, classLoader);

Review comment:
       maybe we can do this just once in the constructor? what do you think

##########
File path: extensions-core/mysql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/mysql/MySQLConnector.java
##########
@@ -241,4 +241,19 @@ public DBI getDBI()
   {
     return dbi;
   }
+
+  @VisibleForTesting
+  static boolean isTransientException(ClassLoader classLoader, String driverName, Throwable e)
+  {
+    if (driverName.contains("mysql")) {
+      try {
+        Class<?> clazz = Class.forName(MYSQL_TRANSIENT_EXCEPTION_CLASS_NAME, false, classLoader);
+        return e.getClass().equals(clazz)

Review comment:
       ```suggestion
           return clazz.isAssignableFrom(e.getClass())
   ```

##########
File path: extensions-core/mysql-metadata-storage/src/test/java/org/apache/druid/metadata/storage/mysql/MySQLConnectorTest.java
##########
@@ -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.druid.metadata.storage.mysql;
+
+import com.mysql.jdbc.exceptions.MySQLTransientException;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.sql.SQLException;
+import java.sql.SQLTransientConnectionException;
+
+public class MySQLConnectorTest
+{
+  @Test
+  public void testIsExceptionTransient()
+  {
+    final String driver = "com.mysql.jdbc.Driver";
+    final ClassLoader loader = getClass().getClassLoader();
+    Assert.assertTrue(MySQLConnector.isTransientException(loader, driver, new MySQLTransientException()));

Review comment:
       can you also add a test case for MySQLTransactionRollbackException (a subclass of MysqlTransientException)?




-- 
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@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] clintropolis commented on pull request #12205: use reflection to check for mysql transient exception type

Posted by GitBox <gi...@apache.org>.
clintropolis commented on pull request #12205:
URL: https://github.com/apache/druid/pull/12205#issuecomment-1023643553


   ci failures are for code coverage, but integration tests are passing (except for known flake #12171) merging anyway, going to merge anyway


-- 
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@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] clintropolis merged pull request #12205: use reflection to check for mysql transient exception type

Posted by GitBox <gi...@apache.org>.
clintropolis merged pull request #12205:
URL: https://github.com/apache/druid/pull/12205


   


-- 
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@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org