740 Commits

Author SHA1 Message Date
Peter Mattis
c1948f2940 raft: grow the inflights buffer instead of preallocating
Grow the inflights buffer as needed instead of preallocating it to its
max size. This avoids preallocating a lot of unnecessary
space (8*MaxInflightMsgs) when using lots of raft groups while still
allowing for a reasonable MaxInflightMsgs configuration.
2016-09-06 18:07:01 -04:00
Peter Mattis
4a33aa3917 raft: use a singleton global rand
rand.NewSource creates a 4872 byte object. With a small number of raft
groups in a process this isn't a problem. With 10k raft groups we'd use
46MB for these random sources. The only usage is in
raft.resetRandomizedElectionTimeout which isn't performance critical.

Fixes #6347.
2016-09-05 09:03:18 -04:00
Ben Darnell
a7a867c1e6 raft: Allow an election immediately after start with checkQuorum
Previously, the checkQuorum flag required an election timeout to
expire before a node could cast its first vote. This change permits
the node to cast a vote at any time when the leader is not known,
including immediately after startup.
2016-08-30 08:28:41 +08:00
sharat
9b3b1f80dd raft: handled panic for Term due to IOB
Instead of raising panic, returning an error instead for better handling

#6215
2016-08-18 23:11:38 +05:30
Gyu-Ho Lee
de06dc1272 Merge pull request #6155 from gyuho/raft-leader-transfer
*: expose Raft leader transfer
2016-08-11 08:03:28 -07:00
siddontang
f8ee322b08 raft: fix overflow 2016-08-11 09:24:49 +08:00
Gyu-Ho Lee
e64ef3f261 raft: add 'TransferLeadership' to Node interface 2016-08-10 16:25:22 -07:00
Gyu-Ho Lee
f4141f0f51 raft: handle 'MsgTransferLeader' in follower 2016-08-10 16:24:29 -07:00
Xiang Li
5f0c122496 raft: fix getting unapplied log entries 2016-08-08 10:44:02 -07:00
Xiang Li
6c3efde51b Merge pull request #6099 from sinsharat/master
raft: handling of applying old snapshots
2016-08-05 07:38:07 -07:00
Xiang Li
c46955b60a Merge pull request #6097 from swingbach/master
raft: fix #6096
2016-08-04 11:40:02 -07:00
sharat
fd757756f5 raft: handling of applying old snapshots
There was a TODO requirement to handle ErrorSnapshotOutOfDate for the
function ApplySnapshot. The same has been implemented

#6090
2016-08-04 21:08:24 +05:30
swingbach@gmail.com
41dee84733 raft: fix #6096 2016-08-04 18:31:22 +08:00
Xiang Li
6e7baab32c Merge pull request #6070 from swingbach/master
raft: fix #6068
2016-08-03 19:59:07 -07:00
swingbach@gmail.com
c0a8da7fd0 raft: minor refactor 2016-08-02 08:46:43 +08:00
Xiang Li
8d12017fe2 raft: better doc 2016-07-30 21:11:37 -07:00
swingbach@gmail.com
992f628e6e raft: fix #6068 2016-07-30 03:27:29 +08:00
Gyu-Ho Lee
982e18d80b *: regenerate proto with latest grpc-gateway 2016-07-27 13:21:03 -07:00
Xiang Li
a75688bd17 Merge pull request #6039 from xiang90/fix_r
raft: hide Campaign rules on applying all entries
2016-07-26 20:52:09 -07:00
Xiang Li
0d6c028aa2 Merge pull request #6032 from xiang90/gateway
fix a few issues in grpc gateway
2016-07-25 16:48:38 -07:00
Xiang Li
484f579905 raft: hide Campaign rules on applying all entries 2016-07-25 15:53:39 -07:00
Xiang Li
fffa484a9f *: regenerate proto for adding deleterange 2016-07-23 16:17:44 -07:00
Gyu-Ho Lee
4ff6c72257 raft: replace 'reflect.DeepEqual' with bytes.Equal 2016-07-22 16:34:13 -07:00
Xiang Li
1c5754f02d raft: fix readindex 2016-07-19 15:00:58 -07:00
Gyu-Ho Lee
50be793f09 *: regenerate proto 2016-07-18 09:33:32 -07:00
Gyu-Ho Lee
5b92e17e86 *: regenerate proto files 2016-07-15 13:24:19 -07:00
Xiang Li
7432e9fbe9 Merge pull request #5809 from swingbach/master
raft: make leader transferring workable when quorum check is on
2016-07-12 09:46:18 -07:00
Xiang Li
b2c1112288 Merge pull request #5921 from xiang90/r
raft: do not change RecentActive when resetState for progress
2016-07-12 06:54:14 -07:00
swingbach@gmail.com
c36a40ca15 raft: introduce top-level context in message struct 2016-07-12 16:14:06 +08:00
Xiang Li
eb08f2274e raft: do not change RecentActive when resetState for progress 2016-07-11 21:12:14 -07:00
Gyu-Ho Lee
6f3a40cb53 raft: set leader id in stepFollower
Follower has already set its leader ID from
previous append messages from the leader, but
to be consistent,  this adds a line to set its
leader id from leader snapshot message.
2016-07-11 16:37:31 -07:00
swingbach@gmail.com
0d9b6ba0ab raft: fix a few problems 2016-07-11 14:59:53 +08:00
Gyu-Ho Lee
c396b6aaaa raft: remove unnecessary type-cast, else-clause 2016-07-09 22:01:19 -07:00
Jared Hulbert
90889ebc0f raftpb: atomic access alignment
The Entry struct has misaligned fields that are accessed atomically.  The
misalignment is caused by the EntryType enum which the Protocol Buffers
spec forces to be a 32bit int.

Moving the order of the fields without renumbering them in the .proto file
seems to align the go structure without changing the wire format.
2016-07-08 11:13:53 -07:00
Jared Hulbert
df94f58462 raft: atomic access alignment
The relevant structures are properly aligned, however, there is no comment
highlighting the need to keep it aligned as is present elsewhere in the
codebase.

Adding note to keep alignment, in line with similar comments in the codebase.
2016-07-08 11:05:41 -07:00
Gyu-Ho Lee
9e0de02fde raft: fix minor grammar, remove TODO
- test 'Term' panic cases (remove TODO)
- fix minor grammar in 'Node' godoc
2016-07-05 07:21:52 -07:00
Gyu-Ho Lee
881a120453 raft: minor updates and clean up in log.go
- remove redundant test case in log_test.go
- fix test case comment ('equal or larger')
- lastnewi after matching index and term
2016-07-04 16:52:17 -07:00
Xiang Li
8d99a666f9 Merge pull request #5854 from xiang90/r_f
raft: add features section to readme file
2016-07-03 18:00:31 -07:00
Xiang Li
c76dcc5190 raft: add features section to readme file 2016-07-03 17:59:59 -07:00
Gyu-Ho Lee
9b5e99efe0 raft: remove unnecessary reflect.DeepEqual in test 2016-07-03 13:42:26 -07:00
Xiang Li
40c4a7894d *: support return prev deleted kv 2016-07-01 14:01:48 -07:00
Gyu-Ho Lee
2cc2372165 raft: give correct offset in unstable test
`unstable.entries[i] has raft log position i+unstable.offset`

So, this fixes some test cases by giving them correct
offsets.
2016-06-29 12:29:36 -07:00
swingbach@gmail.com
e020b2a228 raft: make leader transferring workable when quorum check is on 2016-06-29 18:24:58 +08:00
zhonglin6666
df31eab136 raft: simplify truncateAndAppend
truncateAndAppend no need the value of 'after' with subbing one
2016-06-28 18:53:12 -07:00
Xiang Li
5f1c763993 Merge pull request #5553 from swingbach/master
raft: implemented read-only query when quorum check is on
2016-06-28 12:47:43 -07:00
swingbach@gmail.com
0faae33ace raft: implemented read-only query when quorum check is on 2016-06-28 10:52:53 +08:00
Gyu-Ho Lee
6a48961895 raft: len(entries) before Lock, use firstIndex
- To avoid unnecessary locking in case len(entries) == 0
- use firstIndex method
2016-06-24 23:50:00 -07:00
Gyu-Ho Lee
33f7e7583b raft: fix comment,method name to needSnapshotAbort
And 'maybeSnapshotAbort' does not 'unset'
the pendingSnapshot. 'resetState', which is called after this
metho, is the one that unsets pendingSnapshot. So this changes
the method name.
2016-06-24 07:54:10 -07:00
Xiang Li
848f539536 raft: make tick unblock and fix potential live lock 2016-06-16 08:01:06 -07:00
Xiang Li
5a7b7f7595 main: add grpc-gateway support
Now etcd can serve HTTP json request at /v3alpha/
2016-06-14 17:09:06 -07:00