DeadLocks...

From: <tom(at)tacocat(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: DeadLocks...
Date: 2007-06-14 14:09:24
Message-ID: Whfp99GX.1181830164.4231220.tom@tacocat.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I found a problem with my application which only occurs under high loads
(isn't that always the case?).

snippets of perl...

insert into tokens (token)
select values.token
from (values TOKEN_LIST_STRING) as values(token)
left outer join tokens t using (token)
where t.token_idx is null

$sql =~ s/TOKEN_LIST_STRING/$string/
where $string is of the form (('one'),('two'))

This works 99% of the time.

But everyone once in a long while it seems that I hit simultaneaous
execute() statements that deadlock on the insertion.

Right now I know of no other way to handle this than to eval{ } the
execution and if it fails, sleep random milliseconds and retry... "wash
rinse repeat" for some number of times.

Is there any better way of doing this or some other means to manage
DEADLOCK?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gregory Stark 2007-06-14 14:37:33 Re: DeadLocks..., DeadLocks...
Previous Message g.hintermayer 2007-06-14 12:58:18 Re: precision of epoch