Skip site navigation (1) Skip section navigation (2)

Re: Deadlock detection

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: PostgreSQL - JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Deadlock detection
Date: 2009-01-21 10:48:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Oliver Jowett wrote:

> If you want a minimally invasive approach (in terms of rewriting driver
> code) and some extra overhead isn't a problem then I would suggest
> something like this:
> (1) spawn a separate write thread for each connection; it reads from an
> unbounded buffer
> (2)instead of writes from the thread running a query going directly to
> the real stream, they instead go into the buffer (without blocking), and
> the corresponding write thread picks them up for immediate writing
> (3) implement OutputStream.flush() to wait for the buffer to empty,
> *with a timeout*. If you hit the timeout while waiting to flush, then
> you've detected a potential deadlock case and can dump out some state
> and then continue anyway.

Also, if it wasn't obvious, I'm thinking you do this by a custom
OutputStream implementation that just sits on top of the real stream;
you don't need to change any of the callers so it's just a bit of setup
code then the vast majority of the driver guts are unchanged. You could
even make it conditional on a connection parameter ..


In response to

pgsql-jdbc by date

Next:From: Simon RiggsDate: 2009-01-21 11:30:40
Subject: Re: Deadlock detection
Previous:From: Oliver JowettDate: 2009-01-21 10:38:05
Subject: Re: Deadlock detection

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group