diff --git a/docs/format/wal.md b/docs/format/wal.md index ca3fae39d..6127fd050 100644 --- a/docs/format/wal.md +++ b/docs/format/wal.md @@ -1,6 +1,6 @@ # WAL Disk Format -The write ahead log operates in segments that that are numbered and sequential, +The write ahead log operates in segments that are numbered and sequential, e.g. `000000`, `000001`, `000002`, etc., and are limited to 128MB by default. A segment is written to in pages of 32KB. Only the last page of the most recent segment may be partial. A WAL record is an opaque byte slice that gets split up into sub-records @@ -17,13 +17,21 @@ Notable deviations are that the record fragment is encoded as: └───────────┴──────────┴────────────┴──────────────┘ ``` +The type flag has the following states: + +* `0`: rest of page will be empty +* `1`: a full record encoded in a single fragment +* `2`: first fragment of a record +* `3`: middle fragment of a record +* `4`: final fragment of a record + ## Record encoding The records written to the write ahead log are encoded as follows: ### Series records -Series records encode the labels that identifier a series and its unique ID. +Series records encode the labels that identifies a series and its unique ID. ``` ┌────────────────────────────────────────────┐ diff --git a/fileutil/fileutil.go b/fileutil/fileutil.go index 397858958..a3eb2a7ac 100644 --- a/fileutil/fileutil.go +++ b/fileutil/fileutil.go @@ -27,9 +27,6 @@ func ReadDir(dirpath string) ([]string, error) { // Rename safely renames a file. func Rename(from, to string) error { - if err := os.RemoveAll(to); err != nil { - return err - } if err := os.Rename(from, to); err != nil { return err } diff --git a/wal/wal.go b/wal/wal.go index 90228184a..c2b333da0 100644 --- a/wal/wal.go +++ b/wal/wal.go @@ -140,7 +140,7 @@ func OpenReadSegment(fn string) (*Segment, error) { // WAL is a write ahead log that stores records in segment files. // It must be read from start to end once before logging new data. -// If an erroe occurs during read, the repair procedure must be called +// If an error occurs during read, the repair procedure must be called // before it's safe to do further writes. // // Segments are written to in pages of 32KB, with records possibly split