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

Repair refactor #3521

Merged
merged 10 commits into from
Aug 14, 2023
3 changes: 1 addition & 2 deletions docs/source/sctool/partials/sctool_repair.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ options:
default_value: "1"
usage: |
How many token ranges per shard to repair in a single Scylla node at the same time.
It can be a decimal between (0,1), in that case it specifies percent of shards that can be repaired in parallel on a repair master node.
Zero (0) is a special value, the number of token ranges is adjusted to the maximum supported by node (see max_repair_ranges_in_parallel in Scylla logs).
Changing the intensity impacts repair granularity if you need to resume it, the higher the value the more work on resume.
- name: interval
Expand All @@ -79,7 +78,7 @@ options:
For example, if you select '--interval 7d' task would run weekly at the '--start-date' time.
- name: keyspace
shorthand: K
default_value: '[]'
default_value: '[*,!system_traces]'
usage: |+
A list of `glob` patterns separated by a comma used to include or exclude tables.
The patterns match keyspaces and tables, separate the keyspace name from the table name with a dot e.g. 'keyspace,!keyspace.table_prefix_*'.
Expand Down
1 change: 0 additions & 1 deletion docs/source/sctool/partials/sctool_repair_control.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ options:
default_value: "1"
usage: |
How many token ranges per shard to repair in a single Scylla node at the same time.
It can be a decimal between (0,1), in that case it specifies percent of shards that can be repaired in parallel on a repair master node.
Zero (0) is a special value, the number of token ranges is adjusted to the maximum supported by node (see max_repair_ranges_in_parallel in Scylla logs).
Changing the intensity impacts repair granularity if you need to resume it, the higher the value the more work on resume.
- name: parallel
Expand Down
3 changes: 1 addition & 2 deletions docs/source/sctool/partials/sctool_repair_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ options:
default_value: "1"
usage: |
How many token ranges per shard to repair in a single Scylla node at the same time.
It can be a decimal between (0,1), in that case it specifies percent of shards that can be repaired in parallel on a repair master node.
Zero (0) is a special value, the number of token ranges is adjusted to the maximum supported by node (see max_repair_ranges_in_parallel in Scylla logs).
Changing the intensity impacts repair granularity if you need to resume it, the higher the value the more work on resume.
- name: interval
Expand All @@ -78,7 +77,7 @@ options:
For example, if you select '--interval 7d' task would run weekly at the '--start-date' time.
- name: keyspace
shorthand: K
default_value: '[]'
default_value: '[*,!system_traces]'
usage: |+
A list of `glob` patterns separated by a comma used to include or exclude tables.
The patterns match keyspaces and tables, separate the keyspace name from the table name with a dot e.g. 'keyspace,!keyspace.table_prefix_*'.
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/scylla-manager/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (s *server) makeServices() error {
s.config.Repair,
metrics.NewRepairMetrics().MustRegister(),
s.clusterSvc.Client,
s.clusterSvc.GetSession,
s.logger.Named("repair"),
)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/command/flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ func (w Wrapper) Keyspace(p *[]string) {
w.fs.StringSliceVarP(p, "keyspace", "K", nil, usage["keyspace"])
}

func (w Wrapper) KeyspaceWithDefaultV(p *[]string, dv []string) {
w.fs.StringSliceVarP(p, "keyspace", "K", dv, usage["keyspace"])
}

func (w Wrapper) Location(p *[]string) {
w.fs.StringSliceVarP(p, "location", "L", nil, usage["location"])
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/command/repair/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (cmd *command) init() {
w := flag.Wrap(cmd.Flags())
w.Cluster(&cmd.cluster)
w.Datacenter(&cmd.dc)
w.Keyspace(&cmd.keyspace)
w.KeyspaceWithDefaultV(&cmd.keyspace, []string{"*", "!system_traces"})
w.FailFast(&cmd.failFast)
w.Unwrap().StringVar(&cmd.host, "host", "", "")
w.Unwrap().BoolVar(&cmd.ignoreDownHosts, "ignore-down-hosts", false, "")
Expand Down
1 change: 0 additions & 1 deletion pkg/command/repair/repaircontrol/res.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ long: |

intensity: |
How many token ranges per shard to repair in a single Scylla node at the same time.
It can be a decimal between (0,1), in that case it specifies percent of shards that can be repaired in parallel on a repair master node.
Zero (0) is a special value, the number of token ranges is adjusted to the maximum supported by node (see max_repair_ranges_in_parallel in Scylla logs).
Changing the intensity impacts repair granularity if you need to resume it, the higher the value the more work on resume.

Expand Down
1 change: 0 additions & 1 deletion pkg/command/repair/res.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ignore-down-hosts: |

intensity: |
How many token ranges per shard to repair in a single Scylla node at the same time.
It can be a decimal between (0,1), in that case it specifies percent of shards that can be repaired in parallel on a repair master node.
Zero (0) is a special value, the number of token ranges is adjusted to the maximum supported by node (see max_repair_ranges_in_parallel in Scylla logs).
Changing the intensity impacts repair granularity if you need to resume it, the higher the value the more work on resume.

Expand Down
129 changes: 0 additions & 129 deletions pkg/dht/murmur3partitioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,139 +4,10 @@ package dht

import (
"math"
"math/big"
)

// Full token range.
const (
Murmur3MinToken = int64(math.MinInt64)
Murmur3MaxToken = int64(math.MaxInt64)
)

// Murmur3Partitioner see
// https://github.com/scylladb/scylla/blob/master/dht/murmur3_partitioner.hh
// https://github.com/scylladb/scylla/blob/master/dht/murmur3_partitioner.cc
type Murmur3Partitioner struct {
shardCount uint
shardingIgnoreMsbBits uint
shardStart []uint64
}

// NewMurmur3Partitioner creates a new Murmur3Partitioner instance.
func NewMurmur3Partitioner(shardCount, shardingIgnoreMsbBits uint) *Murmur3Partitioner {
if shardCount <= 1 {
shardingIgnoreMsbBits = 0
}

p := &Murmur3Partitioner{
shardCount: shardCount,
shardingIgnoreMsbBits: shardingIgnoreMsbBits,
}
p.initZeroBasedShardStart()

return p
}

func (p *Murmur3Partitioner) initZeroBasedShardStart() {
p.shardStart = make([]uint64, p.shardCount)

if p.shardCount == 1 {
return
}

var (
t uint64
token = new(big.Int)
shards = new(big.Int)
)
shards.SetUint64(uint64(p.shardCount))

for s := uint(0); s < p.shardCount; s++ {
// uint64_t token = (uint128_t(s) << 64) / shards;
token.SetUint64(uint64(s))
token.Lsh(token, 64)
token.Div(token, shards)
// token >>= sharding_ignore_msb_bits;
t = token.Uint64()
t >>= p.shardingIgnoreMsbBits

// Token is the start of the next shard, and can be slightly before due
// to rounding errors adjust.
for p.zeroBasedShardOf(t) != s {
t++
}
p.shardStart[s] = t
}
}

func (p *Murmur3Partitioner) zeroBasedShardOf(t uint64) uint {
var (
token = new(big.Int)
shards = new(big.Int)
)
// token <<= sharding_ignore_msb_bits;
token.SetUint64(t << p.shardingIgnoreMsbBits)

// (uint128_t(token) * shards) >> 64;
shards.SetUint64(uint64(p.shardCount))
token.Mul(token, shards)
token.Rsh(token, 64)

return uint(token.Uint64())
}

// ShardCount returns the number of shards.
func (p *Murmur3Partitioner) ShardCount() uint {
return p.shardCount
}

// ShardOf returns shard the token belongs to.
func (p *Murmur3Partitioner) ShardOf(t int64) uint {
return p.zeroBasedShardOf(zeroBased(t))
}

// PrevShard returns id of a previous shard in a round robin fashion.
func (p *Murmur3Partitioner) PrevShard(shard uint) uint {
prev := shard
if prev == 0 {
prev = p.ShardCount()
}
return prev - 1
}

// TokenForPrevShard returns the start token for the shard -1.
func (p *Murmur3Partitioner) TokenForPrevShard(t int64, shard uint) int64 {
z := zeroBased(t)
s := p.zeroBasedShardOf(z)

if p.shardingIgnoreMsbBits == 0 {
if shard > s {
return Murmur3MinToken
}
return unzeroBased(p.shardStart[shard])
}

l := z >> (64 - p.shardingIgnoreMsbBits)
if shard > s {
l--
}
l <<= 64 - p.shardingIgnoreMsbBits

return unzeroBased(l | p.shardStart[shard])
}

func zeroBased(t int64) uint64 {
mid := uint64(1 << 63)
if t >= 0 {
return mid + uint64(t)
}
return mid - uint64(-t)
}

func unzeroBased(z uint64) int64 {
mid := uint64(1 << 63)
if z >= mid {
return int64(z - mid)
}
return -int64(mid - z)
}
131 changes: 0 additions & 131 deletions pkg/dht/murmur3partitioner_test.go

This file was deleted.

Loading