Re: Lock table, Select for update and Serialization error

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: Lock table, Select for update and Serialization error
Дата
Msg-id AFCCBB403D7E7A4581E48F20AF3E5DB202CB25FF@EXADV1.host.magwien.gv.at
обсуждение исходный текст
Ответ на Lock table, Select for update and Serialization error  (sudhir <sudhirj@cse.iitb.ac.in>)
Ответы Re: Lock table, Select for update and Serialization error  (sudhir <sudhirj@cse.iitb.ac.in>)
Список pgsql-general
> As per postgres docs, 'Select for update' is used to obtain row level
> locks where as 'lock table' is used to obtain table level locks.
>
> Under serializable isolation level, select for update gives error if
> rows selected have been modified concurrently.
> but 'lock table' does not give such error even though some of the rows

> in the table are modified by concurrent transaction.
>
> Is this the expected behavior?

LOCK TABLE should never give you an error, except for a deadlock
resolution
error.

LOCK TABLE will just wait until there is no lock on the table that is
incompatible with the requested lock, then it will obtain the lock and
return.

LOCK TABLE does not modify tables or rows and so you cannot get a
serialization error, which is only issued when you run serializable
and try to modify a row that is newer than your transaction begin time.

On the other hand, LOCK TABLE will not necessarily prevent you from
subsequently receiving serialization errors if you do not request
an exclusive lock on the table.

Does that answer your questions?

Yours,
Laurenz Albe

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

Предыдущее
От: Dave Page
Дата:
Сообщение: Re: What is "Postgresql Hot"?
Следующее
От: Philippe Amelant
Дата:
Сообщение: Re: Postgresql 8.2.4 crash with tsearch2