Re: [HACKERS] It sorta works, but I'm confused about locking

Поиск
Список
Период
Сортировка
От Vadim Mikheev
Тема Re: [HACKERS] It sorta works, but I'm confused about locking
Дата
Msg-id 36142A59.311E12C9@krs.ru
обсуждение исходный текст
Ответ на Re: [HACKERS] It sorta works, but I'm confused about locking  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [HACKERS] It sorta works, but I'm confused about locking
Список pgsql-hackers
Tom Lane wrote:
>
> > I can imagine some cases where you would want to get a lock and keep it
> > until the end of the transaction, and other times when you would want to
> > release it before transaction end.
>
> I guess I'm not understanding something.  How can it ever be correct
> practice to release a lock before transaction end?  For example, if I
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Postgres does this for system tables only.

> write some changes in a table, and then release the lock, wouldn't that
> allow other backends to see the not-yet-committed changes?  What if I
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No. Backend uses xmin/xmax to know is tuple visible or not.

> then abort my transaction?  Now the other backends have acted on
> information they should never have seen at all.

Backend will see that xmin(xmax) is not committed.

Vadim

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Proper cleanup at backend exit
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] rules ON SELECT