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

storage: prepare for kv.atomic_replication_changes=true #40370

Merged
merged 15 commits into from
Sep 4, 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
255 changes: 128 additions & 127 deletions pkg/roachpb/api.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pkg/roachpb/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ message AdminUnsplitResponse {
// now encompass all keys from its original start key to the end key
// of the subsumed range. If AdminMerge is called on the final range
// in the key space, it is a noop.
// The request must be addressed to the start key of the left hand side.
message AdminMergeRequest {
option (gogoproto.equal) = true;

Expand Down
18 changes: 18 additions & 0 deletions pkg/roachpb/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ func (a Attributes) String() string {
return strings.Join(a.Attrs, ",")
}

// NewRangeDescriptor returns a RangeDescriptor populated from the input.
func NewRangeDescriptor(
rangeID RangeID, start, end RKey, replicas ReplicaDescriptors,
) *RangeDescriptor {
repls := append([]ReplicaDescriptor(nil), replicas.All()...)
for i := range repls {
repls[i].ReplicaID = ReplicaID(i + 1)
}
desc := &RangeDescriptor{
RangeID: rangeID,
StartKey: start,
EndKey: end,
NextReplicaID: ReplicaID(len(repls) + 1),
}
desc.SetReplicas(MakeReplicaDescriptors(repls))
return desc
}

// RSpan returns the RangeDescriptor's resolved span.
func (r *RangeDescriptor) RSpan() RSpan {
return RSpan{Key: r.StartKey, EndKey: r.EndKey}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/client_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ func TestStoreRangeMergeDeadFollowerDuringTxn(t *testing.T) {

args := adminMergeArgs(lhsDesc.StartKey.AsRawKey())
_, pErr := client.SendWrapped(ctx, store0.TestSender(), args)
expErr := "merge of range into .* failed: waiting for all right-hand replicas to catch up"
expErr := "merge failed: waiting for all right-hand replicas to catch up"
if !testutils.IsPError(pErr, expErr) {
t.Fatalf("expected %q error, but got %v", expErr, pErr)
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/storage/merge_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ func (mq *mergeQueue) process(
humanizeutil.IBytes(mergedStats.Total()),
mergedQPS,
)
_, pErr := lhsRepl.AdminMerge(ctx, roachpb.AdminMergeRequest{}, reason)
_, pErr := lhsRepl.AdminMerge(ctx, roachpb.AdminMergeRequest{
RequestHeader: roachpb.RequestHeader{Key: lhsRepl.Desc().StartKey.AsRawKey()},
}, reason)
switch err := pErr.GoError(); err.(type) {
case nil:
case *roachpb.ConditionFailedError:
Expand Down
Loading