Re: Sequence moves forward when failover is triggerred

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Sequence moves forward when failover is triggerred
Дата
Msg-id 4FFE1D8B.2020506@ringerc.id.au
обсуждение исходный текст
Ответ на Re: Sequence moves forward when failover is triggerred  (Steve Crawford <scrawford@pinpointresearch.com>)
Список pgsql-general
On 07/12/2012 04:17 AM, Steve Crawford wrote:

> The stickier issue is queuing. You have multiple users and need to
> ensure that you grab an unused check from the book but each concurrent
> user needs to get a different check. "Select from checkbook where not
> check_used order by check_no limit 1 for update" seems like a
> reasonable approach but if two users run it simultaneously the first
> user will get 1 check and succeed while the second user will attempt
> to lock same check record, block until the first user completes then
> recheck and find the selected record no longer
> meets the check_used criteria so the second user will see zero records
> returned.
In short-transaction systems where the blocking isn't an issue it's
often fine to just re-try when you don't get a result. Much simpler than
advisory locking tricks.

Using a SERIALIZABLE transaction should also work AFAIK, causing a
serialization failure and forcing the app to re-issue the transaction.

--
Craig Ringer

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: question about installation
Следующее
От: Toby Corkindale
Дата:
Сообщение: Re: Bug? Prepared queries continue to use search_path from their preparation time