can while loop in ClockSweepTick function be kind of infinite loop in some cases?

Поиск
Список
Период
Сортировка
От 斯波隼斗
Тема can while loop in ClockSweepTick function be kind of infinite loop in some cases?
Дата
Msg-id CAA_WrMnXrOoQNaR6XUkTWjQ_-CZ3qA4KHK+7_OyypQAkEfNrxg@mail.gmail.com
обсуждение исходный текст
Ответы Re: can while loop in ClockSweepTick function be kind of infinite loop in some cases?  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
This question is about ClockSweepTick function and the code is below.

 The value of expected, NBuffers, wrapped variable is fixed in the while loop, so that when the value of expected variable is not equal to StrategyControl->nextVictimBuffer, CAS operation fails and the while loop will be run kind-of infinitely. 
It is possible for this problem to occur when ClockSweepTick function is concurrently called and nextVictimBuffer is incremented by other process before CAS operation in the loop (ex: in this case, the value of expected variable is NBuffers+1 while the value of nextVictimBuffer variable is NBuffers+2. so CAS operation fails) 
I think. `expected = originalVictim + 1;` line should be in while loop (before acquiring spin lock) so that, even in the case above, expected variable is incremented for each loop and CAS operation will be successful at some point. 
Is my understanding correct? If so, I will send PR for fixing this issue.

Thank you in advance
Hayato Shiba



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

Предыдущее
От: Paul Ramsey
Дата:
Сообщение: Re: [PATCH] random_normal function
Следующее
От: "Drouvot, Bertrand"
Дата:
Сообщение: Re: Strengthen pg_waldump's --save-fullpage tests