Re:Reader/Reader blocking in reader/writer locks
by kazinator on Wednesday May 08, 2019 @02:26PM
(#19861551)
> What to do about it?
Design with RCU, if you can.
> Time out writer acquisitions.
> If potentially starving writers is acceptable, adding a timeout to write-side acquisitions will bound how long readers can be forced to pause. GoCardless’ library for online Rails migrations implements this option for Postgres, and also discusses the challenges and implications a bit.
This is nearly the same as simply not having writer priority. If "potentially starving writers is acceptable", that implies we can consider reader-priority locks, which do exactly that: potentially starve writers.
Under writer priority, we hold back new readers so that the old readers can leave and let the waiting writer in. If we balk when the new readers are blocked for too long, and bump the writer, then it's simply not writer priority any more.
Design with RCU, if you can.
> Time out writer acquisitions.
> If potentially starving writers is acceptable, adding a timeout to write-side acquisitions will bound how long readers can be forced to pause. GoCardless’ library for online Rails migrations implements this option for Postgres, and also discusses the challenges and implications a bit.
This is nearly the same as simply not having writer priority. If "potentially starving writers is acceptable", that implies we can consider reader-priority locks, which do exactly that: potentially starve writers.
Under writer priority, we hold back new readers so that the old readers can leave and let the waiting writer in. If we balk when the new readers are blocked for too long, and bump the writer, then it's simply not writer priority any more.