improve readability

Signed-off-by: Clement <gh.2lgqz@aleeas.com>
This commit is contained in:
Clement 2024-09-13 10:18:03 +08:00
parent b51d3cbe8f
commit 63364244aa

View File

@ -1598,11 +1598,14 @@ func TestIsActive(t *testing.T) {
} }
} }
// newDummyPutReqReady creates a dummy raft.Ready. // newDummyPutReqReady creates a raft.Ready.
// //
// In unit tests, EtcdServer doesn't append raft log entries upon start like the full-featured etcd does. // In unit tests, a manually created EtcdServer doesn't append raft log
// This can crash the program when creating a raft log snapshot due to no available entries. // entries on startup like the full-featured etcd does in bootstrap.
// To append raft log entries, we can send a newDummyPutReqReady() to raft.Node's readyc after the server starts. // This can crash the program when creating a raft log snapshot if there
// are no available entries.
// To work around this, we can send a newDummyPutReqReady() to raft.Node's readyc
// after the server starts to ensure the entries are appended.
func newDummyPutReqReady() raft.Ready { func newDummyPutReqReady() raft.Ready {
req := &pb.InternalRaftRequest{ req := &pb.InternalRaftRequest{
Header: &pb.RequestHeader{ID: 1}, Header: &pb.RequestHeader{ID: 1},