Re: Changing the transaction isolation level within the stored

Поиск
Список
Период
Сортировка
От Markus Schaber
Тема Re: Changing the transaction isolation level within the stored
Дата
Msg-id 43D8C5CF.6030000@logix-tt.com
обсуждение исходный текст
Ответ на Re: Changing the transaction isolation level within the stored  (Andrew Sullivan <ajs@crankycanuck.ca>)
Ответы Re: Changing the transaction isolation level within the stored  (Andrew Sullivan <ajs@crankycanuck.ca>)
Список pgsql-sql
Hi, Andrew,

Andrew Sullivan wrote:

>>AFAIK, in PostgreSQL normal SQL commands cannot create deadlocks at all,
>>the only way to introduce deadlocks is to issue LOCK commands to take
>>locks manually. And for this rare case, PostgreSQL contains a deadlock
>>detection routine that will abort one of the insulting transactions, and
>>the others can proceed.
> 
> You can too.  Consider this:
> 
> t1                                        t2
> 
> BEGIN;                                    BEGIN;
> UPDATE table1 SET col1=                   UPDATE table2 SET col1=
>      col1+5;                                  (SELECT col3 FROM
> DELETE FROM table2 WHERE                          table3);
>     col1 = col1+6;                    UPDATE table1 SET col1 =
>                                          col1 +5;
> COMMIT;                                   COMMIT;

Hmm, are you shure that this is correct? The delete will always delete 0
rows.

http://www.postgresql.org/docs/8.0/static/transaction-iso.html#XACT-SERIALIZABLE
contains a nice example in '12.2.2.1. Serializable Isolation versus True
Serializability' that you should probably read.

> Suppose these are concurrent.  The problem here is that each
> transaction need something in the other transaction either to
> complete or rollback before the work can proceed.  So one of them has
> to lose.

Despite the fact that I don't see such a collision in your example:

Depending on the transaction isolation level and exact timings,
colliding queries may lead to different results or even one transaction
aborted, but there is no deadlock under MVCC.

Not needing such locks is the whole point in using MVCC at all.

Markus

-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org


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

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: question with times and intervals
Следующее
От: andrew
Дата:
Сообщение: Re: filtering after join