Re: shared Locks - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: shared Locks
Date
Msg-id 20050920103219.GC8586@svana.org
Whole thread Raw
In response to Re: shared Locks  (Daniel Schuchardt <daniel_schuchardt@web.de>)
Responses Re: shared Locks
List pgsql-general
On Tue, Sep 20, 2005 at 12:01:46PM +0200, Daniel Schuchardt wrote:
> Martijn van Oosterhout schrieb:
> >I think you'll find that locks are held to the end of the transaction.
> >You're not holding a transaction open but not doing anything, are you?
> >
> >
> Yes you'r right here. Because we use Cursor Fetch, every statement
> starts a transaction. So your right I tested it and this forces a table
> lock. Hm... i will look how to do this in another way.

Just COMMIT when you're done. This does kill the cursor though...

If you put a timeout in your app so that it commits that transaction
after, say, 30 seconds idle then your ALTER commands will only wait for
a while. Although, your ALTER will in turn block the following users...

Is your biggest problem that people tend to leave connections open
overnight or something? I simple timeout would work fine if there you
only want to make changes when there are just a few active users.
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

pgsql-general by date:

Previous
From: Daniel Schuchardt
Date:
Subject: Re: shared Locks
Next
From: Gábor Farkas
Date:
Subject: how to read the transaction logs?