Re: change in LOCK behavior

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: change in LOCK behavior
Дата
Msg-id 201210102242.16451.andres@2ndquadrant.com
обсуждение исходный текст
Ответ на change in LOCK behavior  (Tomas Vondra <tv@fuzzy.cz>)
Ответы Re: change in LOCK behavior
Список pgsql-hackers
On Wednesday, October 10, 2012 10:21:51 PM Tomas Vondra wrote:
> Hi,
> 
> I've just noticed a change of LOCK command behavior between 9.1 and 9.2,
> and I'm not sure whether this is expected or not.
> 
> Let's use a very simple table
> 
>   CREATE TABLE x (id INT);
> 
> Say there are two sessions - A and B, where A performs some operations
> on "x" and needs to protect them with an "ACCESS EXCLUSIVE" lock (e.g.
> it might be a pg_bulkload that acquires such locks, and we need to do
> that explicitly on one or two places).
> 
> Session B is attempting to read the data, but is blocked and waits. On
> 9.1 it sees the commited data (which is what we need) but on 9.2 it sees
> only data commited at the time of the lock attemt.
> 
> Example:
> 
> A: BEGIN;
> A: LOCK x IN ACCESS EXCLUSIVE MODE;
> A: INSERT INTO x VALUES (100);
> B: SELECT * FROM x;
> A: COMMIT;
> 
> Now on 9.1, B receives the value "100" while on 9.2 it gets no rows.
> 
> Is this expected? I suspect the snapshot is read at different time or
> something, but I've checked release notes but I haven't seen anything
> relevant.
> 
> Without getting the commited version of data, the locking is somehow
> pointless for us (unless using a different lock, not the table itself).
That sounds like youre using different isolation levels in 9.1 and 9.2. Is that 
possible? I.e. your 9.1 test uses read committed, and 9.2 uses repeatable read 
or serializable.

Greetings,

Andres
-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: change in LOCK behavior
Следующее
От: Thom Brown
Дата:
Сообщение: Re: change in LOCK behavior