From: Peter <peter@greatnowhere.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Totally weird behaviour in org.postgresql.Driver
Date: Fri, 13 Mar 2009 11:27:44 +0200
Message-ID: <49ba2711$0$1341$834e42db@reader.greatnowhere.com> (raw)
References: <49b7bfef$0$1343$834e42db@reader.greatnowhere.com>
<49B7CBB6.5020800@opencloud.com>
<49b7ced9$0$1343$834e42db@reader.greatnowhere.com>
<Pine.BSO.4.64.0903112335400.25261@leary.csoft.net>
<002201c9a2f9$edd47510$c97d5f30$@com>
<491f66a50903120342j67e87c7dob10cfdc23580c8f4@mail.gmail.com>
<003001c9a315$a68a9330$f39fb990$@com>
> Couple things.... do you really need to synchronize twice in every method
> ???
> Have you looked at dbcp or c3po instead of re-inventing the wheel ?
>
> Can you supply us with a test case which does exhibit the bug ?
I'm fairly sure this is JVM/Tomcat bug I'm dealing with here. The test case
below was configured to run on every request received by servlet, but only
started exhibiting the weird behaviour after few hours of heavy load:
import java.sql.*;
import java.util.logging.Logger;
import org.postgresql.ds.PGSimpleDataSource;
public class PGTester {
public static void main() {
org.postgresql.ds.PGSimpleDataSource _ds=new
org.postgresql.ds.PGSimpleDataSource();
_ds.setDatabaseName("mydb");
_ds.setServerName("myhost");
_ds.setPortNumber(5432);
for (int i=0; i<20; i++) {
Connector con = new Connector(i+1,_ds);
new Thread(con, "Conn" ).start();
}
}
private static class Connector implements Runnable {
@SuppressWarnings("unused")
private int _num;
private PGSimpleDataSource _ds;
Connector(int n, PGSimpleDataSource ds) {
_num = n;
_ds = ds;
}
public void run() {
for (int i=0; i<100; i++) {
try {
Connection conn = _ds.getConnection("user","pass");
// System.out.println("Connector " + _num + " made connection #" +
(i+1));
conn.close();
} catch (Exception e) {
Logger.getLogger(this.getClass().getName()).severe(e.getMessage());
}
}
}
}
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: peter@greatnowhere.com
Subject: Re: Totally weird behaviour in org.postgresql.Driver
In-Reply-To: <49ba2711$0$1341$834e42db@reader.greatnowhere.com>
References: <49b7bfef$0$1343$834e42db@reader.greatnowhere.com> <49B7CBB6.5020800@opencloud.com> <49b7ced9$0$1343$834e42db@reader.greatnowhere.com> <Pine.BSO.4.64.0903112335400.25261@leary.csoft.net> <002201c9a2f9$edd47510$c97d5f30$@com> <491f66a50903120342j67e87c7dob10cfdc23580c8f4@mail.gmail.com> <003001c9a315$a68a9330$f39fb990$@com> <49ba2711$0$1341$834e42db@reader.greatnowhere.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox