PL/pgsql locking policy - Mailing list pgsql-general

From Richard Emberson
Subject PL/pgsql locking policy
Date
Msg-id 3C9E529D.DA5E4C96@phc.net
Whole thread Raw
Responses Re: PL/pgsql locking policy
List pgsql-general
If you have a PL/pgsql procedure that first reads from a given table to
verify a condition and
then if the condition is true write to that same table ... and at the
same time you want other
processes to be able to simply read from the table, what is the best
locking policy within the procedure?

While ACCESS EXCLUSIVE MODE prevents others from reading.
allowing other to read means that two process might be concurrently
reading (verifying) within
the procedure, reach the same condition value, and then both attempt to
write data.

Is it better to simply have a helper table, a table created just for
this one procedure, the only mechanism
where writing to the table actually occurs, and use this helper table as
the locking mechanism.

Richard


pgsql-general by date:

Previous
From: Richard Emberson
Date:
Subject: Re: Large Object Location in 7.3
Next
From: Bruce Momjian
Date:
Subject: Re: Large Object Location in 7.3