18747 Commits

Author SHA1 Message Date
Benjamin Wang
f77b8a735f etcdserver: populate HashRevision when responding to leader or client's HashKV request
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-14 08:33:44 +08:00
Benjamin Wang
228f493c76 rpc.proto: regenerate rpc.proto related files
Run
1. ./script/genproto.sh
2. ./scripts/update_proto_annotations.sh

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-14 08:33:44 +08:00
Benjamin Wang
cd746de14e rpc.proto: added a new field hash_revision into HashKVResponse
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-14 08:33:44 +08:00
Tobias Grieger
4c8244622e
Merge pull request #14717 from falser101/fix/testify 2022-11-13 23:08:30 +01:00
Tobias Grieger
de97f6aa3d raft: tidy up the unit tests some more
Use `t.Run` for each test case, and make some tests more idiomatic.

Signed-off-by: Tobias Grieger <tobias.b.grieger@gmail.com>
2022-11-13 22:34:47 +01:00
jianfei.zhang
1f4f70723f feat: use testify packages in tests
Signed-off-by: jianfei.zhang <jianfei.zhang@daocloud.io>
2022-11-13 23:38:57 +08:00
Marek Siarkowicz
0e4bf4ac4e
Merge pull request #14730 from ahrtr/rev_inconsistency_20221111
etcdserver: call the OnPreCommitUnsafe in unsafeCommit
2022-11-13 13:34:39 +01:00
Marek Siarkowicz
2a6e57d4fc
Merge pull request #14741 from ahrtr/update_readme_20221112
README: remove Tobias Grieger from the Emeritus Maintainers list
2022-11-13 12:21:52 +01:00
Benjamin Wang
e8097fe030 README: remove Tobias Grieger from the Emeritus Maintainers list
Tobias Grieger is actively working on etcd/raft, and has already
been added back as a raft maintainer, so no reason to keep him
in the Emeritus Maintainers list.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-13 13:15:49 +08:00
Benjamin Wang
62cba5b4f1
Merge pull request #14725 from clarkfw/functional-options-pattern-EtcdProcessClusterConfig-2022-11-11
tests: refactor `EtcdProcessClusterConfig` using Functional Options Pattern
2022-11-13 07:00:10 +08:00
Clark
caaeee2920 tests: refactor EtcdProcessClusterConfig with Functional Options Pattern
replace some initialisations with `DefaultConfig`, `NewConfig` and `EPClusterOption`

Signed-off-by: Clark <fwyongxing@gmail.com>
2022-11-13 00:27:41 +08:00
Benjamin Wang
bdd5347313
Merge pull request #14719 from nvanbenschoten/nvanbenschoten/nextCommittedEnts
raft: rename raftLog.nextEnts to raftLog.nextCommittedEnts
2022-11-12 02:51:30 +08:00
Nathan VanBenschoten
3711fde822 raft: rename raftLog.nextEnts to raftLog.nextCommittedEnts
Also rename hasNextEnts to hasNextCommittedEnts.
Also rename maxNextEntsSize to maxNextCommittedEntsSize.

Pure refactor.

Signed-off-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
2022-11-11 13:21:20 -05:00
Tobias Grieger
22d930b3d5
Merge pull request #14722 from nvanbenschoten/nvanbenschoten/unusedReadyContainsUpdates 2022-11-11 16:25:46 +01:00
Tobias Grieger
910b81b153
Merge pull request #14720 from nvanbenschoten/nvanbenschoten/clarifyUnstableStableTo 2022-11-11 16:25:37 +01:00
Benjamin Wang
da619c3567
Merge pull request #14718 from ahrtr/fix_e2e_datadir_20221110
test: Create a subdirectory for each member when DataDirPath is specified
2022-11-11 19:15:06 +08:00
Benjamin Wang
dbc7204610 test: Create a subdirectory for each member when DataDirPath is specified
When e2e test cases specify the DataDirPath and there are more than
one member in the cluster, we need to create a subdirectory for each
member. Otherwise all members share the same directory and accordingly
lead to conflict.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-11 18:48:42 +08:00
Benjamin Wang
5a3ef953eb etcdserver: call the OnPreCommitUnsafe in unsafeCommit
`unsafeCommit` is called by both `(*batchTxBuffered) commit` and
`(*backend) defrag`. When users perform the defragmentation
operation, etcd doesn't update the consistent index. If etcd
crashes(e.g. panicking) in the process for whatever reason, then
etcd replays the WAL entries starting from the latest snapshot,
accordingly it may re-apply entries which might have already been
applied, eventually the revision isn't consistent with other members.

Refer to discussion in https://github.com/etcd-io/etcd/pull/14685

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-11 10:57:15 +08:00
Marek Siarkowicz
2f558ca0db
Merge pull request #14714 from serathius/linearizability-data-dir
tests: Preserve data dir from failed linearizability tests
2022-11-10 13:58:23 +01:00
Marek Siarkowicz
04caec5960 tests: Preserve data dir from failed linearizability tests
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2022-11-10 11:05:59 +01:00
Nathan VanBenschoten
e0beef6830 raft: delete unused Ready.containsUpdates method
Signed-off-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
2022-11-09 22:25:34 -05:00
Nathan VanBenschoten
c18d79df37 raft: clarify conditions in unstable.stableTo
No change in behavior, but clarify interaction with unstable snapshot.

Signed-off-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
2022-11-09 22:12:49 -05:00
Benjamin Wang
0bff3ade4d
Merge pull request #14704 from chenyahui/mutex_unlock_state
etcdclient: check mutex state in Unlock method of concurrency.Mutex
2022-11-10 10:38:03 +08:00
Benjamin Wang
ccec27be62
Merge pull request #14592 from nvanbenschoten/nvanbenschoten/nilSnapMsg
raft: make Message.Snapshot nullable, halve struct size
2022-11-10 05:47:21 +08:00
Nathan VanBenschoten
0f9d7a4f95 raft: make Message.Snapshot nullable, halve struct size
This commit makes the rarely used `raftpb.Message.Snapshot` field nullable.
In doing so, it reduces the memory size of a `raftpb.Message` message from
264 bytes to 128 bytes — a 52% reduction in size.

While this commit does not change the protobuf encoding, it does change
how that encoding is used. `(gogoproto.nullable) = false` instruct the
generated proto marshaling logic to always encode a value for the field,
even if that value is empty. `(gogoproto.nullable) = true` instructs the
generated proto marshaling logic to omit an encoded value for the field
if the field is nil.

This raises compatibility concerns in both directions. Messages encoded
by new binary versions without a `Snapshot` field will be decoded as an
empty field by old binary versions. In other words, old binary versions
can't tell the difference. However, messages encoded by old binary versions
with an empty Snapshot field will be decoded as a non-nil, empty field by
new binary versions. As a result, new binary versions need to be prepared
to handle such messages.

While Message.Snapshot is not intentionally part of the external interface
of this library, it was possible for users of the library to access it and
manipulate it. As such, this change may be considered a breaking change.

Signed-off-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
2022-11-09 17:35:52 +00:00
Tobias Grieger
00820f0fc9
Merge pull request #14708 from pavelkalinnikov/testify_demo 2022-11-09 15:26:26 +01:00
Marek Siarkowicz
0d4a516d11
Merge pull request #14710 from tjungblu/downgrade_binary
Take binary version in Downgrade/Upgrade Test
2022-11-09 13:44:15 +01:00
Thomas Jungblut
0daf153b4f Take binary version in Downgrade/Upgrade Test
This fix avoids the assumption of knowing the current version of the
binary. We can query the binary with the version flag to get the actual
version of the given binary we upgrade and downgrade to. The
respectively reported versions should match what is returned by the
version endpoint.

Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
2022-11-09 10:41:07 +01:00
Benjamin Wang
6ac76c5991
Merge pull request #14707 from ahrtr/mix_version_snapshot_20221108
test: support mix versions sending snapshot test
2022-11-09 17:38:14 +08:00
Benjamin Wang
b32cd938b3 test: add mix versions sending snapshot test
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-09 16:04:22 +08:00
Benjamin Wang
080effc935 test: enhance StartNewProc to accept one more parameter: EtcdProcessClusterConfig
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-09 16:04:22 +08:00
Pavel Kalinnikov
765a2660bc raft/tracker: use testify packages in tests
This commit removes the verbose comparisons in tests, in favor of using
assert/require helpers from the testify packages.

Signed-off-by: Pavel Kalinnikov <pavel@cockroachlabs.com>
2022-11-08 23:08:54 +00:00
Benjamin Wang
49ecea5dae
Merge pull request #14633 from pavelkalinnikov/send_empty_append
raft: send empty appends when replication is paused
2022-11-09 06:51:46 +08:00
Pavel Kalinnikov
1ea13494eb raft/tracker: rename and comment MsgApp paused field
Make the field name and comment clearer on the fact that it's used both in
StateProbe and StateReplicate. The old name ProbeSent was slightly confusing,
and also triggered thinking that it's used only in StateProbe.

Signed-off-by: Pavel Kalinnikov <pavel@cockroachlabs.com>
2022-11-08 22:21:39 +00:00
Pavel Kalinnikov
467114ed87 raft/tracker: remove unused Inflights.FreeFirstOne
Signed-off-by: Pavel Kalinnikov <pavel@cockroachlabs.com>
2022-11-08 22:21:39 +00:00
Pavel Kalinnikov
4969aa81ae raft: send empty appends when replication is paused
When Inflights to a particular node is full, i.e. MaxInflightMsgs for the
append messages flow is saturated, it is still necessary to continue sending
MsgApp to ensure progress. Currently this is achieved by "forgetting" the first
in-flight message in the window, which frees up quota for one new MsgApp.

This new message is constructed in such a way that it potentially has multiple
entries, or a large entry. The effect of this is that the in-flight limitations
can be exceeded arbitrarily, for as long as the flow to this node continues
being saturated. In particular, if a follower is stuck, the leader will keep
sending entries to it.

This commit makes the MsgApp empty when Inflights is saturated, and prevents
the described leakage of Entries to slow followers.

Signed-off-by: Pavel Kalinnikov <pavel@cockroachlabs.com>
2022-11-08 22:21:39 +00:00
Pavel Kalinnikov
3bc3d2071e raft: extract Progress update on MsgApp to a method
Previously, Progress update on MsgApp send was scattered across raft.go and
tracker/progress.go. This commit better encapsulates this logic in the Progress
type.

Signed-off-by: Pavel Kalinnikov <pavel@cockroachlabs.com>
2022-11-08 22:21:38 +00:00
Pavel Kalinnikov
d5ac7b833f raft: cleanup maybeSendAppend method
- avoid large indented blocks, leave the main block unindented
- declare pb.Message inlined in the sending call

Signed-off-by: Pavel Kalinnikov <pavel@cockroachlabs.com>
2022-11-08 22:21:38 +00:00
Pavel Kalinnikov
5619953f33 raft: elaborate checks in flow control tests
Signed-off-by: Pavel Kalinnikov <pavel@cockroachlabs.com>
2022-11-08 22:21:38 +00:00
Pavel Kalinnikov
0a0f0ae719 raft/rafttest: add test for replication pausing
This commit adds a data-driven test which simulates conditions under which Raft
messages flow to a particular node is throttled while in StateReplicate. The
test demonstrates that MsgApp messages with non-empty Entries may "leak" to a
paused stream every time there is successful heartbeat exchange.

Signed-off-by: Pavel Kalinnikov <pavel@cockroachlabs.com>
2022-11-08 22:21:38 +00:00
Marek Siarkowicz
4d15f5074c
Merge pull request #14711 from clarkfw/functional-options-pattern-EtcdProcessClusterConfig-1
tests: refactor `EtcdProcessClusterConfig` using Functional Options Pattern
2022-11-08 22:47:40 +01:00
Clark
269a0beb41 tests: refactor EtcdProcessClusterConfig with Functional Options Pattern
add `DefaultConfig`, `NewConfig` and `EPClusterOption`

Signed-off-by: Clark <fwyongxing@gmail.com>
2022-11-09 03:37:42 +08:00
chenyahui
5b8c6b548f etcdclient: check mutex state in Unlock method of concurrency.Mutex
Check the values of myKey and myRev first in Unlock method to prevent calling Unlock without Lock. Because this may cause the value of pfx to be deleted by mistake.

Signed-off-by: chenyahui <cyhone@qq.com>
2022-11-08 22:24:52 +08:00
Marek Siarkowicz
f482f7b4a4
Merge pull request #14705 from serathius/raftapi
raft: Remove dependency on etcd api
2022-11-08 14:52:57 +01:00
Marek Siarkowicz
2a1055c7f3 raft: Remove dependency on etcd api
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2022-11-08 13:56:46 +01:00
Benjamin Wang
3e903d0b12
Merge pull request #14706 from ahrtr/version_20221108
etcdserver: fix log typo when checking version compatiblity
2022-11-08 18:56:10 +08:00
Benjamin Wang
2ac149b96a etcdserver: fix log typo when checking version compatiblity
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-08 18:27:46 +08:00
Benjamin Wang
1f863f7961
Merge pull request #14703 from ahrtr/raft_remove_etcd_client_20221108
raft: remove the raft dependency on go.etcd.io/etcd/client/pkg/v3
2022-11-08 18:24:33 +08:00
Benjamin Wang
fe7da79594 raft: remove the raft dependency on go.etcd.io/etcd/client/pkg/v3
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-08 09:20:19 +08:00
Marek Siarkowicz
554b1bd0b0
Merge pull request #14687 from serathius/random-failpoint
tests: Add triggering random go failpoints to linearizability tests
2022-11-07 20:59:39 +01:00