Re: shared Locks

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Daniel Schuchardt <daniel_schuchardt(at)web(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: shared Locks
Date: 2005-09-20 10:32:24
Message-ID: 20050920103219.GC8586@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gábor Farkas 2005-09-20 10:40:58 how to read the transaction logs?
Previous Message Daniel Schuchardt 2005-09-20 10:01:46 Re: shared Locks