Re: Select For Update question

From: Barry Lind <blind(at)xythos(dot)com>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Select For Update question
Date: 2003-03-26 16:40:16
Message-ID: 3E81D7F0.2010604@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Jean-Christian Imbeault wrote:
> I know this is not specifically postgres related, but if my application
> crashes after putting a lock on some rows, I have notice that postgres
> releases the locks.
>
> Is the behaviour reliable? I.e. can feel safe in that if my application
> crashes any locks it held will be released?
>

Yes you can rely on this behavior. The only thing that may be
unpredictable is when the locks will be released. If the application
"crashes" the locks should be cleaned up when the application cleans up
its resources in dealing with the "crash" (i.e. rolling back open
connections and exiting somewhat gracefully). If however it is a true
"crash", such as java seg faulting, or someone killing the process, then
the server will detect that the client socket connection was lost and
clean up. This may not happen immediately, it may take a while for the
server to realize the client is no longer there.

This does get a bit more complicated if you are using connection pools.
If you have a connection checked out of the pool and your code catches
an unexpected exception and continues processing, but forgets to
rollback or return the connection to the connection pool, then that
connection will remain open and the transaction and locks will not be
released.

thanks,
--Barry

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Cristina Surroca 2003-03-26 19:54:13 : URGENT: problem installing Ant
Previous Message Jean-Christian Imbeault 2003-03-26 08:05:43 Re: Select For Update question