Re: Q about transactions - Mailing list pgsql-general

From Tom Lane
Subject Re: Q about transactions
Date
Msg-id 7488.1050329413@sss.pgh.pa.us
Whole thread Raw
In response to Re: Q about transactions  ("Ben-Nes Michael" <miki@canaan.co.il>)
List pgsql-general
"Ben-Nes Michael" <miki@canaan.co.il> writes:
> When I want to insert a branch to the tree I need:
> 1. select lft, rgt from the table to find where to insert
> 2. using update I open a gap in the tree ( offset all the lft, rgt above the
> location by two )
> 3. using insert I add a new branch.

> so "select for updates" seem inappropriate as I select only one row as I
> understood it lock only this row.
> Read Committed is also bad as if the second transaction will use select
> before the first transaction ran the update the select will be useless.
> so it seems that Serializable isolation is the solution, or am I wrong ?

Yeah.  Use serializable mode, and be prepared to cope with "can't
serialize" errors (a retry loop around the whole transaction is the
standard answer to that).

            regards, tom lane


pgsql-general by date:

Previous
From: Tony Grant
Date:
Subject: Re: Anyone in Brisbane, Australia, and decent with Linux
Next
From: "scott.marlowe"
Date:
Subject: Re: Index information and log disable...