Skip to content

Commit

Permalink
kvserver: use Step for conf changes as well
Browse files Browse the repository at this point in the history
ProposeConfChange just calls MarshalConfChange followed by Step, and
by inlining this in our codebase we gain the ability to figure out if
raft rejected our ConfChange. We will need this in a follow-up commit.
  • Loading branch information
tbg committed Jul 5, 2023
1 parent 3d1760f commit 4e050d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
16 changes: 12 additions & 4 deletions pkg/kv/kvserver/replica_proposal_buf.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ type proposerRaft interface {
Step(raftpb.Message) error
Status() raft.Status
BasicStatus() raft.BasicStatus
ProposeConfChange(raftpb.ConfChangeI) error
Campaign() error
}

Expand Down Expand Up @@ -563,9 +562,18 @@ func (b *propBuf) FlushLockedWithRaftGroup(
continue
}

if err := raftGroup.ProposeConfChange(
cc,
); err != nil && !errors.Is(err, raft.ErrProposalDropped) {
typ, data, err := raftpb.MarshalConfChange(cc)
if err != nil {
firstErr = err
continue
}
msg := raftpb.Message{Type: raftpb.MsgProp, Entries: []raftpb.Entry{
{
Type: typ,
Data: data,
},
}}
if err := raftGroup.Step(msg); err != nil && !errors.Is(err, raft.ErrProposalDropped) {
// Silently ignore dropped proposals (they were always silently
// ignored prior to the introduction of ErrProposalDropped).
// TODO(bdarnell): Handle ErrProposalDropped better.
Expand Down
5 changes: 0 additions & 5 deletions pkg/kv/kvserver/replica_proposal_buf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ func (t testProposerRaft) BasicStatus() raft.BasicStatus {
return t.status.BasicStatus
}

func (t testProposerRaft) ProposeConfChange(i raftpb.ConfChangeI) error {
// TODO(andrei, nvanbenschoten): Capture the message and test against it.
return nil
}

func (t *testProposerRaft) Campaign() error {
t.campaigned = true
return nil
Expand Down

0 comments on commit 4e050d0

Please sign in to comment.