-
Notifications
You must be signed in to change notification settings - Fork 557
/
term
66 lines (56 loc) · 1.12 KB
/
term
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# get_term works on empty engine.
get_term
---
term=0 vote=None
# Storing a 0 term errors.
!set_term 0
---
Panic: can't set term 0
# set_term stores a term and empty vote, writing it to the engine
# and flushing it to durable storage.
set_term 3 oplog=true
get_term
---
engine: set TermVote 0x01 = 0x0300
engine: flush
term=3 vote=None
# set_term stores a term and vote.
set_term 3 7 oplog=true
get_term
---
engine: set TermVote 0x01 = 0x030107
engine: flush
term=3 vote=7
# set_term is idempotent, which doesn't incur an engine write.
set_term 3 7 oplog=true
get_term
---
term=3 vote=7
# Moving the term into the far future is allowed.
set_term 7
get_term
---
term=7 vote=None
# Starting a new term with a vote is allowed.
set_term 9 1
get_term
---
term=9 vote=1
# Regressing the term errors.
!set_term 8
---
Panic: term regression 9 → 8
# Clearing the vote errors.
!set_term 9
---
Panic: can't change vote Some(1) → None
# Changing the vote errors.
!set_term 9 2
---
Panic: can't change vote Some(1) → Some(2)
# The above errors should not have changed the term/vote.
get_term
dump
---
term=9 vote=1
TermVote 0x01 = 0x090101