Skip to content

Transaction Log

tbarker9comcast edited this page Apr 21, 2014 · 5 revisions

==== Before applying any update to the in-memory state it is first written to some persistent storage, then applied to memory asynchronously. It is important to note that this persistent storage must implement an ordering of the updates so that the updates can be read from the persistent storage in the order they are applied to the in-memory state. The transaction log is a replaceable component in the system.

At a basic level the transaction log needs to implement a function to write to the transaction log in order, perform an ordered traversal of entries in the log over a range of entries, compact the log, return the next sequece number, and the size of the transaction log.

Updates to the in-memory state are written to persistent storage via the transaction log via invocation of the writeEntry(...) method. Without any method to shrink the size of the log the updates take up increasing amounts of the storage. As updates are no longer needed to be tracked as a result of a subsequent update, Sirius attempts to keep just the last update stored persistently. This is implemented by periodically invoking the compact() function. This allows the storage space used by Sirius to grow as updates are added to the state, then shrink by discarding the older updates that have been superseded by later updates.

Sirius includes an implementation of a transaction log that is fully featured and designed to work at a high level of performance. This implementation utilizes files on disk to store the transaction log events. The included transaction log implements live compaction of these events to keep the size of the log files from growing unchecked.

####SiriusLog Interface The interface for the transaction log is defined as a Scala trait named SiriusLog.

SiriusLog defines the following functions:

  • writeEntry
  • foreach
  • foldLeft
  • foldLeftRange
  • compact

SiriusLog defines the following fields

  • getNextSeq
  • size

The functions foreach and foldLeft have implementeations and do not need to be reimplemented by the the class implementing the log.