Skip to content

Commit

Permalink
Check for deleted ranges in proposeRaftCommandImpl.
Browse files Browse the repository at this point in the history
Fixes a race between ProposeRaftCommand and the replicaGCQueue.

Closes cockroachdb#2880
  • Loading branch information
bdarnell committed Oct 22, 2015
1 parent 260d8c6 commit 0d98ac9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion storage/client_raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,6 @@ func TestStoreRangeRebalance(t *testing.T) {
// cannot cause other removed nodes to recreate their ranges.
func TestReplicateRogueRemovedNode(t *testing.T) {
defer leaktest.AfterTest(t)
t.Skip("TODO(bdarnell): https://github.com/cockroachdb/cockroach/issues/2880")

mtc := startMultiTestContext(t, 3)
defer mtc.Stop()
Expand Down
11 changes: 8 additions & 3 deletions storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1399,9 +1399,14 @@ func (s *Store) ProposeRaftCommand(idKey cmdIDKey, cmd roachpb.RaftCommand) <-ch

// proposeRaftCommandImpl runs on the processRaft goroutine.
func (s *Store) proposeRaftCommandImpl(idKey cmdIDKey, cmd roachpb.RaftCommand) <-chan error {
// Lazily create group. TODO(bdarnell): make this non-lazy
err := s.multiraft.CreateGroup(cmd.RangeID)
if err != nil {
// If the range has been removed since the proposal started, drop it now.
if _, ok := s.replicas[cmd.RangeID]; !ok {
ch := make(chan error, 1)
ch <- roachpb.NewRangeNotFoundError(cmd.RangeID)
return ch
}
// Lazily create group.
if err := s.multiraft.CreateGroup(cmd.RangeID); err != nil {
ch := make(chan error, 1)
ch <- err
return ch
Expand Down

0 comments on commit 0d98ac9

Please sign in to comment.