Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: bump go.etcd.io/etcd #38913

Merged
merged 3 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions pkg/roachpb/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/duration"
"github.com/cockroachdb/cockroach/pkg/util/encoding"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/cockroachdb/cockroach/pkg/util/randutil"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
"github.com/gogo/protobuf/proto"
"github.com/kr/pretty"
"github.com/stretchr/testify/require"
)

func makeTS(walltime int64, logical int32) hlc.Timestamp {
Expand Down Expand Up @@ -1559,3 +1562,31 @@ func TestUpdateObservedTimestamps(t *testing.T) {
})
}
}

func TestChangeReplicasTrigger_String(t *testing.T) {
defer leaktest.AfterTest(t)()

l := ReplicaType_LEARNER
v := ReplicaType_VOTER
repl := ReplicaDescriptor{NodeID: 1, StoreID: 2, ReplicaID: 3, Type: &l}
crt := ChangeReplicasTrigger{
ChangeType: ADD_REPLICA,
Replica: repl,
Desc: &RangeDescriptor{
RangeID: 1,
StartKey: RKey("a"),
EndKey: RKey("b"),
InternalReplicas: []ReplicaDescriptor{
repl,
{NodeID: 4, StoreID: 5, ReplicaID: 6, Type: &v},
{NodeID: 7, StoreID: 8, ReplicaID: 9, Type: &l},
},
NextReplicaID: 10,
Generation: proto.Int64(5),
GenerationComparable: proto.Bool(true),
},
}
act := crt.String()
exp := `ADD_REPLICA((n1,s2):3LEARNER): updated=(n4,s5):6,(n1,s2):3LEARNER,(n7,s8):9LEARNER next=10`
require.Equal(t, exp, act)
}
17 changes: 16 additions & 1 deletion pkg/roachpb/metadata_replicas.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

package roachpb

import "sort"
import (
"fmt"
"sort"
"strings"
)

// ReplicaDescriptors is a set of replicas, usually the nodes/stores on which
// replicas of a range are stored.
Expand All @@ -29,6 +33,17 @@ func MakeReplicaDescriptors(replicas []ReplicaDescriptor) ReplicaDescriptors {
return ReplicaDescriptors{wrapped: replicas}
}

func (d ReplicaDescriptors) String() string {
var buf strings.Builder
for i, desc := range d.wrapped {
if i > 0 {
buf.WriteByte(',')
}
fmt.Fprint(&buf, desc)
}
return buf.String()
}

// Unwrap returns every replica in the set. It is a placeholder for code that
// used to work on a slice of replicas until learner replicas are added. At that
// point, all uses of Unwrap will be migrated to All/Voters/Learners.
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ func (s *statusServer) Ranges(
state.Progress[id] = serverpb.RaftState_Progress{
Match: progress.Match,
Next: progress.Next,
Paused: progress.Paused,
Paused: progress.IsPaused(),
PendingSnapshot: progress.PendingSnapshot,
State: progress.State.String(),
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/storage/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/tracker"
)

const (
Expand Down Expand Up @@ -1196,7 +1197,7 @@ func replicaIsBehind(raftStatus *raft.Status, replicaID roachpb.ReplicaID) bool
// behind the actual commit index of the range.
if progress, ok := raftStatus.Progress[uint64(replicaID)]; ok {
if uint64(replicaID) == raftStatus.Lead ||
(progress.State == raft.ProgressStateReplicate &&
(progress.State == tracker.StateReplicate &&
progress.Match >= raftStatus.Commit) {
return false
}
Expand All @@ -1214,8 +1215,8 @@ func simulateFilterUnremovableReplicas(
brandNewReplicaID roachpb.ReplicaID,
) []roachpb.ReplicaDescriptor {
status := *raftStatus
status.Progress[uint64(brandNewReplicaID)] = raft.Progress{
State: raft.ProgressStateReplicate,
status.Progress[uint64(brandNewReplicaID)] = tracker.Progress{
State: tracker.StateReplicate,
Match: status.Commit,
}
return filterUnremovableReplicas(&status, replicas, brandNewReplicaID)
Expand Down
29 changes: 15 additions & 14 deletions pkg/storage/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/olekukonko/tablewriter"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/tracker"
)

const firstRange = roachpb.RangeID(1)
Expand Down Expand Up @@ -825,10 +826,10 @@ func TestAllocatorRebalanceTarget(t *testing.T) {
rangeInfo := rangeInfoForRepl(repl, desc)

status := &raft.Status{
Progress: make(map[uint64]raft.Progress),
Progress: make(map[uint64]tracker.Progress),
}
for _, replica := range replicas {
status.Progress[uint64(replica.NodeID)] = raft.Progress{
status.Progress[uint64(replica.NodeID)] = tracker.Progress{
Match: 10,
}
}
Expand Down Expand Up @@ -5154,18 +5155,18 @@ func TestFilterBehindReplicas(t *testing.T) {
for _, c := range testCases {
t.Run("", func(t *testing.T) {
status := &raft.Status{
Progress: make(map[uint64]raft.Progress),
Progress: make(map[uint64]tracker.Progress),
}
status.Lead = c.leader
status.Commit = c.commit
var replicas []roachpb.ReplicaDescriptor
for j, v := range c.progress {
p := raft.Progress{
p := tracker.Progress{
Match: v,
State: raft.ProgressStateReplicate,
State: tracker.StateReplicate,
}
if v == 0 {
p.State = raft.ProgressStateProbe
p.State = tracker.StateProbe
}
replicaID := uint64(j + 1)
status.Progress[replicaID] = p
Expand Down Expand Up @@ -5222,20 +5223,20 @@ func TestFilterUnremovableReplicas(t *testing.T) {
for _, c := range testCases {
t.Run("", func(t *testing.T) {
status := &raft.Status{
Progress: make(map[uint64]raft.Progress),
Progress: make(map[uint64]tracker.Progress),
}
// Use an invalid replica ID for the leader. TestFilterBehindReplicas covers
// valid replica IDs.
status.Lead = 99
status.Commit = c.commit
var replicas []roachpb.ReplicaDescriptor
for j, v := range c.progress {
p := raft.Progress{
p := tracker.Progress{
Match: v,
State: raft.ProgressStateReplicate,
State: tracker.StateReplicate,
}
if v == 0 {
p.State = raft.ProgressStateProbe
p.State = tracker.StateProbe
}
replicaID := uint64(j + 1)
status.Progress[replicaID] = p
Expand Down Expand Up @@ -5277,20 +5278,20 @@ func TestSimulateFilterUnremovableReplicas(t *testing.T) {
for _, c := range testCases {
t.Run("", func(t *testing.T) {
status := &raft.Status{
Progress: make(map[uint64]raft.Progress),
Progress: make(map[uint64]tracker.Progress),
}
// Use an invalid replica ID for the leader. TestFilterBehindReplicas covers
// valid replica IDs.
status.Lead = 99
status.Commit = c.commit
var replicas []roachpb.ReplicaDescriptor
for j, v := range c.progress {
p := raft.Progress{
p := tracker.Progress{
Match: v,
State: raft.ProgressStateReplicate,
State: tracker.StateReplicate,
}
if v == 0 {
p.State = raft.ProgressStateProbe
p.State = tracker.StateProbe
}
replicaID := uint64(j + 1)
status.Progress[replicaID] = p
Expand Down
11 changes: 6 additions & 5 deletions pkg/storage/raft_log_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/tracker"
)

const (
Expand Down Expand Up @@ -209,7 +210,7 @@ func newTruncateDecision(ctx context.Context, r *Replica) (truncateDecision, err
if pr, ok := raftStatus.Progress[raftStatus.Lead]; ok {
// TODO(tschottdorf): remove this line once we have picked up
// https://github.com/etcd-io/etcd/pull/10279
pr.State = raft.ProgressStateReplicate
pr.State = tracker.StateReplicate
raftStatus.Progress[raftStatus.Lead] = pr
}

Expand All @@ -229,7 +230,7 @@ func newTruncateDecision(ctx context.Context, r *Replica) (truncateDecision, err

func updateRaftProgressFromActivity(
ctx context.Context,
prs map[uint64]raft.Progress,
prs map[uint64]tracker.Progress,
replicas []roachpb.ReplicaDescriptor,
lastUpdate lastUpdateTimesMap,
now time.Time,
Expand Down Expand Up @@ -285,7 +286,7 @@ type truncateDecision struct {
func (td *truncateDecision) raftSnapshotsForIndex(index uint64) int {
var n int
for _, p := range td.Input.RaftStatus.Progress {
if p.State != raft.ProgressStateReplicate {
if p.State != tracker.StateReplicate {
// If the follower isn't replicating, we can't trust its Match in
// the first place. But note that this shouldn't matter in practice
// as we already take care to not cut off these followers when
Expand Down Expand Up @@ -427,7 +428,7 @@ func computeTruncateDecision(input truncateDecisionInput) truncateDecision {
// overlapping bounds that put significant stress on the Raft snapshot
// queue.
if progress.RecentActive {
if progress.State == raft.ProgressStateProbe {
if progress.State == tracker.StateProbe {
decision.ProtectIndex(decision.Input.FirstIndex, truncatableIndexChosenViaProbingFollower)
} else {
decision.ProtectIndex(progress.Match, truncatableIndexChosenViaFollowers)
Expand Down Expand Up @@ -475,7 +476,7 @@ func computeTruncateDecision(input truncateDecisionInput) truncateDecision {
func getQuorumIndex(raftStatus *raft.Status) uint64 {
match := make([]uint64, 0, len(raftStatus.Progress))
for _, progress := range raftStatus.Progress {
if progress.State == raft.ProgressStateReplicate {
if progress.State == tracker.StateReplicate {
match = append(match, progress.Match)
} else {
match = append(match, 0)
Expand Down
Loading