Commit 844d7517 authored by craig[bot]'s avatar craig[bot]

Merge #32954

32954: storage: add interfaces for copysets r=tbg a=mvijaykarthik

Copysets significantly reduce the probability of data loss
in the presence of multi node failures. The RFC for copysets
is presented in https://github.com/cockroachdb/cockroach/pull/32816.

This commit adds interfaces and protos for copysets.
The implementation added later will have two independent tracks:
1. Assignment and persistance of store_id-copyset_id mapping.
2. Rebalancer changes to rebalance replicas into copysets.

Release note: None
Co-authored-by: 's avatarVijay Karthik <[email protected]>
parents b9242838 09fb386e
// Copyright 2019 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
package copysets
import "context"
// CopysetID is a custom type for a cockroach copyset ID.
// Copyset is a group of stores where a range should be contained within
// if copyset based rebalancing is enabled.
type CopysetID int32
// Reader is used to read copysets in the cluster.
type Reader interface {
// forRF returns copysets for the given replication factor.
forRF(ctx context.Context, replicationFactor int32) (*Copysets, error)
}
// Maintainer maintains and assigns copysets to stores.
// TODO(hassan): implement Maintainer.
type Maintainer struct {
}
// Ensure Maintainer implements Reader.
var _ Reader = &Maintainer{}
// forRF returns copysets for the given replication factor.
func (cs *Maintainer) forRF(ctx context.Context, replicationFactor int32) (*Copysets, error) {
return nil, nil
}
This diff was suppressed by a .gitattributes entry.
// Copyright 2019 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
syntax = "proto3";
package cockroach.storage.copysets;
option go_package = "copysets";
import "gogoproto/gogo.proto";
// CopysetStrategy has the set of supported copyset-store allocation strategies.
enum CopysetStrategy {
// MAXIMIZE_DIVERSITY is a strategy which tries to maximize locality diversity
// when creating copysets from a store list.
MAXIMIZE_DIVERSITY = 0;
// MINIMIZE_MOVEMENT is a strategy which tries to minimize changes to
// existing copysets when generating new copysets on store list changes.
// It does not guarantee optimal locality diversity but tries to avoid
// stores with same localities within copysets.
MINIMIZE_MOVEMENT = 1;
}
// AllCopysets contains the map between replication factor to
// its copysets.
message AllCopysets {
// Map from replication factors to copysets.
map<int32, Copysets> by_rf = 1 [(gogoproto.nullable) = false];
// Strategy used for store-copyset allocation.
CopysetStrategy strategy = 2;
}
// Copysets contains copysets for a particular replication factor.
// If copysets based rebalancing is enabled, the replicas of a range will
// be contained within a copy set. Each store belongs to a single copyset.
// Copyset based rebalancing significantly improves failure tolerance.
message Copysets {
// Map from CopysetID to a Copyset (set of stores in the copyset).
map<int32, Copyset> sets = 1 [(gogoproto.nullable) = false,
(gogoproto.castkey) = "CopysetID"];
// Replication factor of copy sets.
int32 replication_factor = 2;
}
// Copyset contains the set of stores belonging to the same copyset.
message Copyset{
// Map of StoreIDs.
map<int32, bool> ids = 1 [
(gogoproto.castkey) = "github.com/cockroachdb/cockroach/pkg/roachpb.StoreID"];
}
// Copyright 2019 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
/*
Package copysets proves an implementation of copysets presented in
https://web.stanford.edu/~skatti/pubs/usenix13-copysets.pdf.
Stores are divided into sets of nodes of size replication factor (for each
replication factor) and ranges reside within a single copyset in steady state.
This significantly reduces the probability of data loss in large clusters since
as long as a quorum of nodes are alive within each copyset, there is no loss
of data.
*/
package copysets
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment