> It seems that
__wt_log_force_write doesn't necessarily write to OS buffers when the slot to be switched is not in the `done` state. So this sounds confusing, because __wt_log_force_write doesn't do writes, just switch a slot ?
The writing of the slot is in 'wt_log_release'. On a 'wt_log_force_write' when the slot is not in the "done" state that means that there is a thread actively using the slot at that moment in time. Therefore, this active thread will be the one to call 'wt_log_release' instead of the thread that forced the switch in 'wt_log_force_write'. So yes, in some circumstances the caller will not actually do the write, but it forces the switch which will for that slot to be written whenever immediately upon not being in use.
> In __log_slot_close, these codes are quite unclear to me:
When switching out the active slot to a new active slot. The thread doing the switch first has to close the existing active slot, and then initialize one of the free slots as the new active slot. After the existing active slot is closed to new threads joining, that slot's information is finalized with the amount of data that this slot represents. So this slot has a starting LSN. We compute how much data was written in this slot while it was the active slot. We add that into the LSN value to get our ending LSN. We then set the 'alloc_lsn' to reflect the new end of the log as the starting LSN of the next active slot. So each slot represents a contiguous slice of the write-ahead log.