Uploaded image for project: 'Apache Storm'
  1. Apache Storm
  2. STORM-2527

Initialize java.sql.DriverManager earlier to avoid deadlock between DriverManager static initializer and driver static initializer

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0, 1.1.1, 1.2.0
    • Component/s: storm-jdbc
    • Labels:
      None

      Description

      I met deadlock issue while using JDBC, and found out DriverManager static initializer and specific driver's static initializer can call each other.
      (DriverManager loads all java.sql.Driver implementations in static initializer, whereas PhoenixDriver calls DriverManager explicitly in static initializer.)

      Since some other drivers may do the similar thing, instead of relying on driver implementation, we just would be better to initialize DriverManager so that we can avoid initialization of DriverManager and Driver concurrently.

      "Thread-17-641-JDBC-RDB-executor[4 4]" #52 prio=5 os_prio=0 tid=0x00007f8aedb6f800 nid=0x742 in Object.wait() [0x00007f8a99036000]
         java.lang.Thread.State: RUNNABLE
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at java.lang.Class.newInstance(Class.java:442)
      	at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
      	at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
      	at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
      	at java.sql.DriverManager$2.run(DriverManager.java:603)
      	at java.sql.DriverManager$2.run(DriverManager.java:583)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at java.sql.DriverManager.loadInitialDrivers(DriverManager.java:583)
      	at java.sql.DriverManager.<clinit>(DriverManager.java:101)
      	at com.mysql.jdbc.Driver.<clinit>(Driver.java:49)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at java.lang.Class.newInstance(Class.java:442)
      	at com.zaxxer.hikari.HikariConfig.setDriverClassName(HikariConfig.java:326)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.zaxxer.hikari.util.PropertyElf.setProperty(PropertyElf.java:163)
      	at com.zaxxer.hikari.util.PropertyElf.setTargetFromProperties(PropertyElf.java:62)
      	at com.zaxxer.hikari.HikariConfig.<init>(HikariConfig.java:128)
      	at org.apache.storm.jdbc.common.HikariCPConnectionProvider.prepare(HikariCPConnectionProvider.java:46)
      	- locked <0x0000000080c72b48> (a org.apache.storm.jdbc.common.HikariCPConnectionProvider)
      	at org.apache.storm.jdbc.bolt.AbstractJdbcBolt.prepare(AbstractJdbcBolt.java:49)
      	at org.apache.storm.jdbc.bolt.JdbcInsertBolt.prepare(JdbcInsertBolt.java:78)
      	at org.apache.storm.daemon.executor$fn__6951$fn__6964.invoke(executor.clj:794)
      	at org.apache.storm.util$async_loop$fn__555.invoke(util.clj:482)
      	at clojure.lang.AFn.run(AFn.java:22)
      	at java.lang.Thread.run(Thread.java:745)
      
      "Thread-7-631-JDBC-PHOENIX-executor[3 3]" #42 prio=5 os_prio=0 tid=0x00007f8aed6ea000 nid=0x738 in Object.wait() [0x00007f8a99a42000]
         java.lang.Thread.State: RUNNABLE
      	at org.apache.phoenix.jdbc.PhoenixDriver.<clinit>(PhoenixDriver.java:128)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at java.lang.Class.newInstance(Class.java:442)
      	at com.zaxxer.hikari.HikariConfig.setDriverClassName(HikariConfig.java:326)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.zaxxer.hikari.util.PropertyElf.setProperty(PropertyElf.java:163)
      	at com.zaxxer.hikari.util.PropertyElf.setTargetFromProperties(PropertyElf.java:62)
      	at com.zaxxer.hikari.HikariConfig.<init>(HikariConfig.java:128)
      	at org.apache.storm.jdbc.common.HikariCPConnectionProvider.prepare(HikariCPConnectionProvider.java:46)
      	- locked <0x0000000080b98f60> (a org.apache.storm.jdbc.common.HikariCPConnectionProvider)
      	at org.apache.storm.jdbc.bolt.AbstractJdbcBolt.prepare(AbstractJdbcBolt.java:49)
      	at org.apache.storm.jdbc.bolt.JdbcInsertBolt.prepare(JdbcInsertBolt.java:78)
      	at org.apache.storm.daemon.executor$fn__6951$fn__6964.invoke(executor.clj:794)
      	at org.apache.storm.util$async_loop$fn__555.invoke(util.clj:482)
      	at clojure.lang.AFn.run(AFn.java:22)
      	at java.lang.Thread.run(Thread.java:745)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kabhwan Jungtaek Lim
                Reporter:
                kabhwan Jungtaek Lim
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 40m
                  1h 40m