41.5 Flushing the log

Flushing the log

For maximum transaction throughput, we normally only flush a segment when it is completely full. ie we buffer it in memory. Then the entire segment, including the segment trailer is written in one go – with a single call to WriteFile(). 

Without battery protected RAM to hold the buffered segments, there is a risk of losing data if the system crashes. Therefore, occasionally there may be a need to flush the log. This will typically flush a partially full segment to the end of the log. For space efficiency, we support appending additional log records to the same segment at a later time. 

The application programmer should be aware that committing a transaction doesn’t imply that the log is flushed. The Ceda framework will automatically flush the log so that data never remains in the cache for longer than a few seconds (this is configurable) to reduce data loss on power failure.

The lazy writer is signalled when a full segment is available to be written to disk.