BUG ? dead lock in connector/J 3.0.8
am 28.07.2003 17:21:35 von Andreas------=_NextPart_000_0069_01C3552C.B237F700
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello,
the following code fragment seems to cause a dead lock in Connector/J =
3.0.8.
static Connection con =3D null;
public static void main (String args[]) throws Exception
{
Driver driver =3D (Driver) =
Class.forName("com.mysql.jdbc.Driver").newInstance();
con =3D driver.connect("jdbc:mysql://.../...", null);
new Thread() {
public void run() {
try {
Statement stat =3D con.createStatement();
while(true) {
stat.executeQuery("select 1").close();
System.out.println("select 1");
}
} catch (Exception e) {}
}
}.start();
while(true) {
Statement stat =3D con.createStatement();
stat.setMaxRows(1);
System.out.println("setMaxRows");
stat.close();
}
}
The code is very useless, I know. But it shows the problem. The problem =
occurs within a complex application and I reduced it
on these couple of lines.
The point is that two threads use simultaneously use same connection =
with different statements. A thread creates one statement and sends =
selects only, closing implicit resultset. Main loop seems to cause the =
deadlock by creating permanently new statements, call method setMaxRow =
and close statement again.
I would expect to get many of output on stdout because of two threads =
running... But after 5 or 10 lines of output nothing happens...
Blocking occurs very fast (within a second). After deadlock every select =
or insert send on the same connection will block.
If I use LIMIT clause in query everything is fine, but I want to use =
method setMaxRows to be independent from used database ;-)
New statement on each query I need to wrap statement and resultset by my =
own classes...
I've tried connector/J 3.0.6 and 3.0.8, java 1.3.1, java 1.4.1. Windoze =
or Linux, it doesn't matter...
Dead lock occured on multi processor system, but on single it's the =
same.
I think and hope this isn't a theoretical problem only. At the moment =
I've worked around it in my wrapper classes. But it was very hard to =
find and I think it would be nice to have a solution in next releases ?
Please tell me, if it is really a bug, if it is known or if I am to =
stupid ?!?
Thanks,
Andreas Mühlbradt
------=_NextPart_000_0069_01C3552C.B237F700--