On 17.07.2013 15:24, Andres Freund wrote:
> On 2013-07-17 15:46:00 +0530, Amit Kapila wrote:
>> Few doubts while reading the code:
>>
>> 1. Why in function WALInsertSlotAcquireOne(int slotno), it does
>> START_CRIT_SECTION() to
>> Lock out cancel/die interrupts, whereas other places call
>> HOLD_INTERRUPTS()
>
> A crit section does more than just stopping interrupts. They also ensure
> that errors that occur while inside one get converted to a PANIC. That
> seems apt for SlotAcquire/Release. Although the comments could possibly
> improved a bit.
Agreed. The comment was copied from LWLockAcquire(), which only does
HOLD_INTERRUPTS(). The crucial difference between LWLockAcquire() and
WALInsertSlotAcquire() is that there is no automatic cleanup mechanism
on abort for the WAL insertion slots like there is for lwlocks. Added a
sentence to the comment to mention that.
>> 3.
>> static bool
>> ReserveXLogSwitch(..)
>>
>> In above function header, why EndPos_p/StartPos_p is used when
>> function arguments are EndPos/StartPos?
>
> I guess that's bitrot...
Yep, fixed.
Thanks for the review!
- Heikki