Address comments

Signed-off-by: Fabian Reinartz <freinartz@google.com>
This commit is contained in:
Fabian Reinartz 2018-07-20 02:26:12 -04:00
parent 3e76f0163e
commit b81e0fbf2a
3 changed files with 11 additions and 6 deletions

View file

@ -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.
```
┌────────────────────────────────────────────┐

View file

@ -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
}

View file

@ -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