Re: Order of granting with many waiting on one lock

Поиск
Список
Период
Сортировка
От Pavan Deolasee
Тема Re: Order of granting with many waiting on one lock
Дата
Msg-id CABOikdOMUvOwW-0QqiKodHQOvX-uqcyE+DiN0+PcAPJZGNtSzg@mail.gmail.com
обсуждение исходный текст
Ответ на Order of granting with many waiting on one lock  (Chris Angelico <rosuav@gmail.com>)
Ответы Re: Order of granting with many waiting on one lock  (Chris Angelico <rosuav@gmail.com>)
Список pgsql-general
On Mon, Feb 11, 2013 at 12:26 PM, Chris Angelico <rosuav@gmail.com> wrote:
> Is there any sort of guarantee that all
> the processes will eventually get a turn, or could two processes
> handball the lock to each other and play keepings-off against the
> other eighteen?
>

That should not happen. There are instances when a lock requester will
be promoted ahead of others to avoid deadlock, but in the scenario you
described, no single process will starve forever. See following
comment in ProcSleep() function under src/backend/storage/lmgr/proc.c
which is self-explanatory.

/*
     * Determine where to add myself in the wait queue.
     *
     * Normally I should go at the end of the queue.  However, if I already
     * hold locks that conflict with the request of any previous waiter, put
     * myself in the queue just in front of the first such waiter. This is not
     * a necessary step, since deadlock detection would move me to before that
     * waiter anyway; but it's relatively cheap to detect such a conflict
     * immediately, and avoid delaying till deadlock timeout.
     *
     * Special case: if I find I should go in front of some waiter, check to
     * see if I conflict with already-held locks or the requests before that
     * waiter.  If not, then just grant myself the requested lock immediately.
     * This is the same as the test for immediate grant in LockAcquire, except
     * we are only considering the part of the wait queue before my insertion
     * point.
     */

Thanks,
Pavan

--
Pavan Deolasee
http://www.linkedin.com/in/pavandeolasee

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

Предыдущее
От: Chris Angelico
Дата:
Сообщение: Order of granting with many waiting on one lock
Следующее
От: Chris Angelico
Дата:
Сообщение: Re: Order of granting with many waiting on one lock