Re: Sporadic query not returning anything..how to diagnose?

Поиск
Список
Период
Сортировка
От Heiko Wundram
Тема Re: Sporadic query not returning anything..how to diagnose?
Дата
Msg-id 4ED500E8.5060603@modelnine.org
обсуждение исходный текст
Ответ на Sporadic query not returning anything..how to diagnose?  (Phoenix Kiula <phoenix.kiula@gmail.com>)
Список pgsql-general
Am 29.11.2011 16:46, schrieb Phoenix Kiula:
> About 5% of the times (in situations of high traffic), this is not
> returning a value in my PHP code. Because it's not found, the code
> tries to INSERT a new record and there's a duplicate key error, which
> is in the logs. The traffic to the site is much higher than the number
> of these entries in my log, which means it's only happening
> sometimes--my guess is for 5% of all queries, which is still quite
> significant (about 60,000 a day).

As the two statements aren't atomic (i.e., after the select, how do you
make sure that no other process accessing the DB has a chance to
select/insert, before the [delayed] insert of the primary process gets
executed)? This is a common form of race-condition.

In the spirit of "it's easier to ask forgiveness than permission", just
do the insert and evaluate the result (i.e., whether a record was
actually inserted) to get at the same information and the same effect as
with the two statements you're currently executing.

--
--- Heiko.

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

Предыдущее
От: Phoenix Kiula
Дата:
Сообщение: Sporadic query not returning anything..how to diagnose?
Следующее
От: "J.V."
Дата:
Сообщение: Re: stored function data structures - difficulty