raft: write entry 0 into log

This commit is contained in:
Yicheng Qin
2014-09-12 12:23:43 -07:00
parent ff7f340bba
commit a9af70c52b
5 changed files with 23 additions and 13 deletions

View File

@ -32,15 +32,16 @@ WAL files are placed inside of the directory in the following format:
$seq-$index.wal
The first WAL file to be created will be 0000000000000000-0000000000000000.wal
indicating an initial sequence of 0 and an initial raft index of 0.
indicating an initial sequence of 0 and an initial raft index of 0. The first
entry written to WAL MUST have raft index 0.
Periodically a user will want to "cut" the WAL and place new entries into a new
file. This will increment an internal sequence number and cause a new file to
be created. If the last raft index saved was 0x20 and this is the first time
Cut has been called on this WAL then the sequence will increment from 0x0 to
0x1. The new file will be: 0000000000000001-0000000000000020.wal. If a second
Cut is issues 0x10 entries later then the file will be called:
0000000000000002-0000000000000030.wal.
0x1. The new file will be: 0000000000000001-0000000000000021.wal. If a second
Cut issues 0x10 entries with incremental index later then the file will be called:
0000000000000002-0000000000000031.wal.
At a later time a WAL can be opened at a particular raft index: