We're updating the issue view to help you get more done. 

JVM does not exit after applying query timeout to a statement

Description

The following test hangs forever if it is executed with MariaDB Java client. With MySQL Connector/J it works all right.
It does not matter whether the timeout is actually reached or not.
Adding stmt.close() also does not help.
Please note that the same code executed via JUnit does not hang.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 import java.sql.DriverManager; import java.sql.Connection; import java.sql.Statement; public class QueryTimeout { public static void main (String argv[]) { String dsn = "jdbc:mysql://localhost:3306/test?user=root"; try { Connection conn = DriverManager.getConnection(dsn); Statement stmt = conn.createStatement(); stmt.setQueryTimeout(1); stmt.execute("select 1"); conn.close(); } catch (Exception e) { e.printStackTrace(); } } }
1 2 3 revision-id: wlad@montyprogram.com-20130212213004-52xak8ynair4uct4 revno: 406 branch-nick: mariadb-java-client

jstack output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 Full thread dump OpenJDK 64-Bit Server VM (20.0-b12 mixed mode): "Attach Listener" daemon prio=10 tid=0x00000000015d7800 nid=0x6a3b runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "DestroyJavaVM" prio=10 tid=0x00007ff01c0df000 nid=0x6a1c waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "Timer-0" prio=10 tid=0x00007ff01c0de800 nid=0x6a28 in Object.wait() [0x00007ff02362d000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000eb6f4880> (a java.util.TaskQueue) at java.lang.Object.wait(Object.java:502) at java.util.TimerThread.mainLoop(Timer.java:505) - locked <0x00000000eb6f4880> (a java.util.TaskQueue) at java.util.TimerThread.run(Timer.java:484) Locked ownable synchronizers: - None "Low Memory Detector" daemon prio=10 tid=0x00007ff01c004800 nid=0x6a25 runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C2 CompilerThread1" daemon prio=10 tid=0x00007ff01c002000 nid=0x6a24 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "C2 CompilerThread0" daemon prio=10 tid=0x0000000001669800 nid=0x6a23 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "Signal Dispatcher" daemon prio=10 tid=0x0000000001668800 nid=0x6a22 runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE Locked ownable synchronizers: - None "Finalizer" daemon prio=10 tid=0x0000000001649800 nid=0x6a21 in Object.wait() [0x00007ff0246a1000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000eb561310> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:133) - locked <0x00000000eb561310> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:149) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177) Locked ownable synchronizers: - None "Reference Handler" daemon prio=10 tid=0x0000000001642000 nid=0x6a20 in Object.wait() [0x00007ff0247a2000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000eb5611e8> (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Object.java:502) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133) - locked <0x00000000eb5611e8> (a java.lang.ref.Reference$Lock) Locked ownable synchronizers: - None "VM Thread" prio=10 tid=0x000000000163b000 nid=0x6a1f runnable "GC task thread#0 (ParallelGC)" prio=10 tid=0x00000000015e2800 nid=0x6a1d runnable "GC task thread#1 (ParallelGC)" prio=10 tid=0x00000000015e4000 nid=0x6a1e runnable "VM Periodic Task Thread" prio=10 tid=0x00007ff01c007000 nid=0x6a26 waiting on condition JNI global references: 878

Environment

java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~11.10.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

Status

Assignee

Vladislav Vaintroub

Reporter

Elena Stepanova

Labels

None

External issue ID

None

External issue ID

None

Fix versions

Affects versions

1.1.0

Priority

Major