DeadLocks... - Mailing list pgsql-general

From
Subject DeadLocks...
Date
Msg-id Whfp99GX.1181830164.4231220.tom@tacocat.net
Whole thread Raw
Responses Re: DeadLocks..., DeadLocks...  (Gregory Stark <stark@enterprisedb.com>)
Re: DeadLocks...  (Scott Marlowe <smarlowe@g2switchworks.com>)
List 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?

pgsql-general by date:

Previous
From: g.hintermayer@inode.at
Date:
Subject: Re: precision of epoch
Next
From: Gregory Stark
Date:
Subject: Re: DeadLocks..., DeadLocks...