Frank,

Frank Pavageau wrote:
> On Fri, Sep 24, 2010 at 2:46 AM, Nikolaos Giannopoulos
> <nikol...@brightminds.org> wrote:
>   
> Huh, no. The socket that is closed is the one to the PostgreSQL
> server, not the one to the browser. There's no application code trying
> to write the HTTP response in the stack between the entry point in
> Hibernate and the throw of the exception in the PSQL JDBC driver,
> hence no opportunity to write on the browser's socket.
>   
Your right. I missed the underlying:

[16/Sep/2010:09:38:15] info ( 2360): CORE3282: stdout: Caused by: 
java.net.SocketException: Connection reset by peer: socket write error
...
[16/Sep/2010:09:38:15] info ( 2360): CORE3282: stdout:* at 
org.postgresql.core.PGStream.flush(PGStream.java:508)*
[16/Sep/2010:09:38:15] info ( 2360): CORE3282:* *stdout: * at 
org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:676)*
[16/Sep/2010:09:38:15] info ( 2360): CORE3282: stdout: *at 
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:191)*

> If it were a "connection closed" message, I'd say that PSQL sets a TTL
> on its connection like MySQL does, but the "connection reset by peer"
> looks like a firewall between the application and the DB which has
> lost track of the open connection, due to it staying idle too long. Or
> maybe Java hasn't noticed that the connection was closed earlier and
> is now only getting a reset status.
>   
I agree. That's why I asked if a load balancer was being used in my 1st 
reply. Cisco and IIRC Big IP for example default to time out idle 
connections at 16 seconds which is great for HTTP but can be disastrous 
to any connection pool that comes under heavy or bursts of load. The 
question is equally valid if there are any firewalls.

> Anyway, to mitigate that, you could set your connection pool to close
> connections that have stayed idle too long. And actually it seems your
> c3p0 is at least partially configured to do so with the
> c3p0.idle_test_period parameter. I don't use it and don't know it, but
> isn't there another parameter to declare the max idle time which
> doesn't have a decent default value ? With DBCP (the standard pool
> used by Tomcat but also usable directly through Hibernate, as c3p0 is
> here), a typical configuration to do that would be (somewhat matching
> yours) :
> maxActive = 20
> maxIdle = -1
> minIdle = 5
> maxWait = 100
> minEvictableIdleTimeMillis = 300000 (5 minutes idle before getting closed)
> timeBetweenEvictionRunsMillis = 30000 (check every 30 seconds for idle
> connections to close)
>
> However, since you're getting connection resets, I'd really set
> minIdle (or c3p0.min_size) to 0, since keeping 5 connections opened no
> matter what could keep some opened forever, while the DB closes it on
> the other end, be it because of a time to live or a time to idle
> setting. Once your application sees some activity again, it can
> probably wait for the time to re-establish a connection. Unless it
> only sees short bursts of intense activity, in which case you might
> want to change the setting on the DB side.
>   
Since he is getting connection resets shouldn't he try to determine why 
they are happening and correct that vs. finding ways for his pool to 
stay empty?

In my experience if you don't truly figure out why these things are 
happening they won't go away and will bite you down the road... a day, a 
week, a month, a year later... but they typically need to be understood 
and resolved. Perhaps its a good temporary measure but I would be more 
interested in seeing it happen again and collecting as much diagnostic 
information as I can from the OS, the network, the processes, etc... - 
essentially a snapshot of state of all related components in time - as I 
mentioned in the other reply than trying to figure out how to tweak your 
connection pools so as to inhibit this issue from surfacing... .

Just an opinion of course.

--Nikolaos


> Frank
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>   


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to