Durable is a package, written in the Go programming language, that
contains an implementation of a journal that may be used for
write-ahead logging, and a utility for atomically writing files.
The atomic file utility follows guidelines inferred from [1] to
achieve atomic writes on a variety of filesystems.
The journal allocates and overwrites fixed-size files, called
volumes, using fdatasync for durability. The contents of each volume
optionally contain a table of contents, written just before closing
the volume, to identify what journal entries are present in the
volume. CRCs are used throughout to detect corruption. An incomplete
final entry, as could be caused by a power failure, and a corrupted
final entry are distinguished by the use of a 32-bit magic number
written at a known location in each disk sector.
If you are interested in using this package, would like to report a
bug, or wish to see additions or changes, please submit a pull request
or contact me at ben at woozlesaurus dot com.
Durable’s API is not yet frozen, and I am planning one
backwards-incompatible change to it. Should you wish to have a frozen
version of the API, please submit a pull request or email me.
[1] Pillai, T.S., Chidambaram, V., Alagappan, R., Al-Kiswany, S.,
Arpaci-Dusseau, A.C. and Arpaci-Dusseau, R.H., 2014, October. All File
Systems Are Not Created Equal: On the Complexity of Crafting
Crash-Consistent Applications. In OSDI (pp. 433-448).