Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Reinartz <[email protected]>
  • Loading branch information
Fabian Reinartz committed Jul 20, 2018
1 parent 3e76f01 commit b81e0fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
12 changes: 10 additions & 2 deletions docs/format/wal.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.

```
┌────────────────────────────────────────────┐
Expand Down
3 changes: 0 additions & 3 deletions fileutil/fileutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion wal/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b81e0fb

Please sign in to comment.