From: | Manfred Koizar <mkoi-pg(at)aon(dot)at> |
---|---|
To: | johnsw(at)wardbrook(dot)com |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Transaction Question |
Date: | 2003-12-04 16:55:00 |
Message-ID: | 2jnusv4aqscrqjavdg8915l88hplspv8at@email.aon.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Wed, 3 Dec 2003 08:08:49 -0000 (GMT), "John Sidney-Woollett"
<johnsw(at)wardbrook(dot)com> wrote:
>Issue - nested transactions
>This is an issue for us because some procedures make use of a function
>which issues a row level lock on a table (select ... for update) in order
>to read and then update a counter, and which then commits to release the
>lock. The nested function returns the new counter value on return.
AFAICS nested transactions - at least in the way we plan to implement
them - won't help, because subtransaction commit will not release locks.
We see a subtransaction as part of the main transaction. If a
subtransaction commits but the main transaction aborts, the
subtransaction's effects are rolled back.
START TRANSACTION; -- main xact
...
START TRANSACTION; -- sub xact
UPDATE t SET n=n+1 WHERE i=42;
This locks the row with i=42, because if another transaction wants to
update this row, it cannot know whether to start with the old or the new
value of n before our transaction commits or rolls back.
COMMIT; --sub xact
Here we are still in the main transaction. Nothing has changed for
other backends, because they still don't know whether our main
transaction will succeed or fail. So we have to keep the lock...
>Is there a simple/elegant solution to this problem?
Perhaps dblink? Just a thought, I don't have any personal experience
with it.
Servus
Manfred
From | Date | Subject | |
---|---|---|---|
Next Message | Matthew Lunnon | 2003-12-04 17:27:43 | multiple PostgresQL installations |
Previous Message | Lamar Owen | 2003-12-04 16:42:06 | Re: [Fedora Core 1] yum repositories with 7.4? |
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2003-12-04 16:59:06 | Re: tuning questions |
Previous Message | Andrew Dunstan | 2003-12-04 16:52:48 | Re: Minor (very) feature request... |