Re: "deadlock detected" documentation

Поиск
Список
Период
Сортировка
От Matt Mello
Тема Re: "deadlock detected" documentation
Дата
Msg-id 3EC3E53C.9070800@spaceship.com
обсуждение исходный текст
Ответ на Re: "deadlock detected" documentation  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: "deadlock detected" documentation
Список pgsql-sql
Okay, so one last question on this...

If I do the following, assuming I haven't applied the patch, will it 
still result in a deadlock (in other words, does this only happen with 
multi-record updates, or can it happen with independent single-record 
updates inside transactions)?

THREAD1:                                                THREAD2:

BEGIN;
update txn set ... where txn.terminalid = 1;
                                                          BEGIN;                    update txn set ... where
txn.terminalid= 2;
 

(I anticipate the next statement will give me a deadlock.)

update txn set ... where txn.terminalid = 2;
                    update txn set ... where txn.terminalid = 1;
COMMIT;
                                                         COMMIT;

Thanks, again!


Tom Lane wrote:
> Matt Mello <alien@spaceship.com> writes:
> 
>>I see.  One item I forgot to mention ...  Both update statements have a 
>>where clause containing txn.terminalid=38.  Txn.terminalid is a foreign 
>>key column in that table (txn.terminalid->terminal.terminalid).  Could 
>>this be the source of the trouble?
> 
> 
> Not per se.  The problem depends on which rows get updated and in what
> sequence --- the contents of the WHERE clause aren't the issue, except
> insofar as they determine the set of rows to be updated.
> 
>             regards, tom lane
> 
> 

-- 
Matt Mello
512-350-6900



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

Предыдущее
От: Alvar Freude
Дата:
Сообщение: Re: SQL Parser
Следующее
От: "Cyber Join"
Дата:
Сообщение: select 3 characters