Skip to content

Instantly share code, notes, and snippets.

@tamird
Created September 11, 2016 22:56
Show Gist options
  • Save tamird/9fc5bfa46418aa53b2e420a38bc61612 to your computer and use it in GitHub Desktop.
Save tamird/9fc5bfa46418aa53b2e420a38bc61612 to your computer and use it in GitHub Desktop.
diff --git a/storage/addressing_test.go b/storage/addressing_test.go
index cd96e54..a432d65 100644
--- a/storage/addressing_test.go
+++ b/storage/addressing_test.go
@@ -137,7 +137,7 @@ func TestUpdateRangeAddressing(t *testing.T) {
t.Fatal(err)
}
}
- if err := store.DB().Run(b); err != nil {
+ if err := store.DB().Run(context.TODO(), b); err != nil {
t.Fatal(err)
}
// Scan meta keys directly from engine.
diff --git a/storage/allocator.go b/storage/allocator.go
index 0387851..7e93478 100644
--- a/storage/allocator.go
+++ b/storage/allocator.go
@@ -20,16 +20,23 @@ package storage
import (
"fmt"
+ "math"
"golang.org/x/net/context"
"github.com/cockroachdb/cockroach/config"
"github.com/cockroachdb/cockroach/roachpb"
"github.com/cockroachdb/cockroach/util"
+ "github.com/cockroachdb/cockroach/util/envutil"
"github.com/cockroachdb/cockroach/util/log"
"github.com/pkg/errors"
)
+// RebalanceThreshold defines the threshold for rebalancing decisions.
+//
+// TODO(bram,petermattis): fix TestStoreRangeRebalance and unexport this.
+var RebalanceThreshold = envutil.EnvOrDefaultFloat("COCKROACH_REBALANCE_THRESHOLD", 0.05)
+
const (
// maxFractionUsedThreshold: if the fraction used of a store descriptor
// capacity is greater than this value, it will never be used as a rebalance
@@ -304,19 +311,27 @@ func (a Allocator) shouldRebalance(
) bool {
const replicaInbalanceTolerance = 1
- // Moving a replica from the given store makes its range count converge on
- // the mean range count.
- //
// TODO(peter,bram,cuong): The FractionUsed check seems suspicious. When a
// node becomes fuller than maxFractionUsedThreshold we will always select it
// for rebalancing. This is currently utilized by tests.
- shouldRebalance := store.Capacity.FractionUsed() >= maxFractionUsedThreshold || (float64(store.Capacity.RangeCount)-sl.candidateCount.mean) >= replicaInbalanceTolerance
+
+ // The store requires rebalancing if its range count is larger than
+ // mean*(1+RebalanceThreshold).
+ target := int32(math.Ceil(sl.candidateCount.mean * (1 + RebalanceThreshold)))
+ shouldRebalance := store.Capacity.FractionUsed() >= maxFractionUsedThreshold ||
+ store.Capacity.RangeCount > target
+ if shouldRebalance {
+ // Require that moving a replica from the given store makes its range count
+ // converge on the mean range count. This only affects clusters with a
+ // small number of ranges.
+ shouldRebalance = (float64(store.Capacity.RangeCount) - sl.candidateCount.mean) >= replicaInbalanceTolerance
+ }
if log.V(2) {
log.Infof(context.TODO(),
- "%d: should-rebalance=%t: fraction-used=%.2f range-count=%d (mean=%.1f)",
+ "%d: should-rebalance=%t: fraction-used=%.2f range-count=%d (mean=%.1f, target=%d)",
store.StoreID, shouldRebalance, store.Capacity.FractionUsed(),
- store.Capacity.RangeCount, sl.candidateCount.mean)
+ store.Capacity.RangeCount, sl.candidateCount.mean, target)
}
return shouldRebalance
}
diff --git a/storage/allocator_test.go b/storage/allocator_test.go
index f8f3c15..b3d4d66 100644
--- a/storage/allocator_test.go
+++ b/storage/allocator_test.go
@@ -544,7 +544,7 @@ func TestAllocatorRebalanceByCount(t *testing.T) {
{
StoreID: 4,
Node: roachpb.NodeDescriptor{NodeID: 4},
- Capacity: roachpb.StoreCapacity{Capacity: 100, Available: 98, RangeCount: 5},
+ Capacity: roachpb.StoreCapacity{Capacity: 100, Available: 98, RangeCount: 2},
},
}
gossiputil.NewStoreGossiper(g).GossipStores(stores, t)
@@ -1236,49 +1236,49 @@ func Example_rebalancing() {
// generation 6: 2 9%, 0 0%, 0 0%, 0 0%, 0 0%, 0 0%, 0 0%, 0 0%, 0 0%, 0 0%, 0 0%, 0 0%, 0 0%, 7 21%, 4 23%, 5 15%, 4 2%, 2 3%, 3 19% 2 5%
// generation 8: 3 7%, 0 0%, 0 0%, 0 0%, 0 0%, 0 0%, 6 14%, 0 0%, 0 0%, 0 0%, 0 0%, 0 0%, 8 14%, 7 12%, 4 15%, 5 9%, 4 4%, 3 2%, 3 13% 3 5%
// generation 10: 4 5%, 10 13%, 0 0%, 0 0%, 0 0%, 0 0%, 6 8%, 0 0%, 0 0%, 0 0%, 0 0%, 7 9%, 8 5%, 7 9%, 4 9%, 5 8%, 4 6%, 4 3%, 4 12% 4 6%
- // generation 12: 5 6%, 10 9%, 7 6%, 0 0%, 0 0%, 0 0%, 6 5%, 12 13%, 0 0%, 0 0%, 0 0%, 7 7%, 8 3%, 7 6%, 5 7%, 5 7%, 5 4%, 5 5%, 5 9% 5 5%
- // generation 14: 7 6%, 10 5%, 7 4%, 7 9%, 0 0%, 0 0%, 7 5%, 12 8%, 7 6%, 0 0%, 0 0%, 7 4%, 8 3%, 7 4%, 7 6%, 7 7%, 7 4%, 7 5%, 7 9% 7 6%
- // generation 16: 8 5%, 10 4%, 8 4%, 8 7%, 16 11%, 4 4%, 8 5%, 12 5%, 8 6%, 0 0%, 0 0%, 8 4%, 8 1%, 8 4%, 8 5%, 8 7%, 8 4%, 8 4%, 8 9% 8 4%
- // generation 18: 10 5%, 10 3%, 10 4%, 10 6%, 16 9%, 6 4%, 10 6%, 12 4%, 10 5%, 3 0%, 4 1%, 10 4%, 10 2%, 10 3%, 10 5%, 10 7%, 10 4%, 10 4%, 10 7% 10 5%
- // generation 20: 12 5%, 12 4%, 12 3%, 12 6%, 16 8%, 8 4%, 12 6%, 12 4%, 12 5%, 7 2%, 8 3%, 12 4%, 12 3%, 12 4%, 12 5%, 12 6%, 12 5%, 12 4%, 12 6% 12 5%
- // generation 22: 14 5%, 14 3%, 14 4%, 14 5%, 16 7%, 11 5%, 14 6%, 14 3%, 14 5%, 10 2%, 10 3%, 14 4%, 14 3%, 14 4%, 14 5%, 14 6%, 14 5%, 14 4%, 14 6% 14 5%
- // generation 24: 16 5%, 16 4%, 16 4%, 16 5%, 16 7%, 13 5%, 16 6%, 16 4%, 16 5%, 13 2%, 13 3%, 16 4%, 16 3%, 16 3%, 16 5%, 16 6%, 16 5%, 16 5%, 16 5% 16 4%
- // generation 26: 18 4%, 18 4%, 18 5%, 18 5%, 18 7%, 15 5%, 18 6%, 18 4%, 18 5%, 15 3%, 15 3%, 18 4%, 18 4%, 18 3%, 18 5%, 18 6%, 18 5%, 18 5%, 18 5% 18 4%
- // generation 28: 20 4%, 20 4%, 20 4%, 20 5%, 20 7%, 17 5%, 20 6%, 20 4%, 20 5%, 17 3%, 17 3%, 20 4%, 20 4%, 20 3%, 20 5%, 20 6%, 20 5%, 20 5%, 20 5% 20 4%
- // generation 30: 22 4%, 22 4%, 22 4%, 22 5%, 22 6%, 19 5%, 22 6%, 22 4%, 22 5%, 19 3%, 19 3%, 22 4%, 22 4%, 22 3%, 22 5%, 22 5%, 22 5%, 22 5%, 22 5% 22 5%
- // generation 32: 24 4%, 24 4%, 24 4%, 24 5%, 24 6%, 21 5%, 24 5%, 24 4%, 24 5%, 21 3%, 21 3%, 24 4%, 24 4%, 24 3%, 24 5%, 24 5%, 24 5%, 24 5%, 24 5% 24 4%
- // generation 34: 26 4%, 26 4%, 26 4%, 26 5%, 26 5%, 23 4%, 26 5%, 26 4%, 26 5%, 23 3%, 23 3%, 26 4%, 26 4%, 26 3%, 26 5%, 26 6%, 26 5%, 26 5%, 26 5% 26 5%
- // generation 36: 28 4%, 28 4%, 28 4%, 28 5%, 28 6%, 25 4%, 28 5%, 28 4%, 28 5%, 25 3%, 25 4%, 28 4%, 28 4%, 28 3%, 28 5%, 28 5%, 28 5%, 28 5%, 28 5% 28 5%
- // generation 38: 30 4%, 30 5%, 30 4%, 30 5%, 30 6%, 27 4%, 30 5%, 30 4%, 30 5%, 27 4%, 27 3%, 30 4%, 30 4%, 30 3%, 30 6%, 30 5%, 30 5%, 30 5%, 30 5% 30 5%
- // generation 40: 32 4%, 32 5%, 32 4%, 32 5%, 32 6%, 29 4%, 32 5%, 32 4%, 32 5%, 29 4%, 29 4%, 32 4%, 32 4%, 32 3%, 32 5%, 32 5%, 32 5%, 32 5%, 32 5% 32 4%
- // generation 42: 34 4%, 34 5%, 34 4%, 34 5%, 34 6%, 31 4%, 34 5%, 34 4%, 34 5%, 31 4%, 31 4%, 34 4%, 34 4%, 34 3%, 34 5%, 34 5%, 34 5%, 34 5%, 34 4% 34 4%
- // generation 44: 36 4%, 36 5%, 36 4%, 36 5%, 36 6%, 33 4%, 36 5%, 36 4%, 36 5%, 33 4%, 33 4%, 36 4%, 36 4%, 36 4%, 36 5%, 36 5%, 36 5%, 36 5%, 36 4% 36 4%
- // generation 46: 38 4%, 38 5%, 38 4%, 38 5%, 38 6%, 35 4%, 38 5%, 38 4%, 38 5%, 35 4%, 35 4%, 38 4%, 38 4%, 38 4%, 38 5%, 38 5%, 38 5%, 38 5%, 38 4% 38 4%
- // generation 48: 40 4%, 40 4%, 40 4%, 40 5%, 40 6%, 37 4%, 40 5%, 40 4%, 40 5%, 37 4%, 37 4%, 40 4%, 40 4%, 40 4%, 40 5%, 40 5%, 40 5%, 40 5%, 40 4% 40 4%
- // generation 50: 42 4%, 42 5%, 42 4%, 42 5%, 42 6%, 39 4%, 42 5%, 42 4%, 42 5%, 39 4%, 39 4%, 42 4%, 42 4%, 42 4%, 42 5%, 42 5%, 42 5%, 42 5%, 42 4% 42 4%
- // generation 52: 44 4%, 44 4%, 44 4%, 44 5%, 44 6%, 41 4%, 44 5%, 44 4%, 44 5%, 41 4%, 41 4%, 44 4%, 44 4%, 44 4%, 44 5%, 44 5%, 44 5%, 44 5%, 44 4% 44 4%
- // generation 54: 46 4%, 46 4%, 46 4%, 46 5%, 46 6%, 43 4%, 46 5%, 46 4%, 46 5%, 43 4%, 43 4%, 46 4%, 46 4%, 46 4%, 46 5%, 46 5%, 46 5%, 46 5%, 46 4% 46 4%
- // generation 56: 48 4%, 48 4%, 48 4%, 48 5%, 48 6%, 45 4%, 48 5%, 48 4%, 48 5%, 45 4%, 45 4%, 48 4%, 48 4%, 48 4%, 48 5%, 48 5%, 48 5%, 48 5%, 48 4% 48 4%
- // generation 58: 50 4%, 50 4%, 50 4%, 50 5%, 50 6%, 47 4%, 50 5%, 50 4%, 50 5%, 47 4%, 47 4%, 50 4%, 50 5%, 50 4%, 50 5%, 50 5%, 50 5%, 50 5%, 50 4% 50 4%
- // generation 60: 52 4%, 52 5%, 52 4%, 52 5%, 52 6%, 49 4%, 52 5%, 52 4%, 52 5%, 49 4%, 49 4%, 52 4%, 52 5%, 52 4%, 52 5%, 52 5%, 52 5%, 52 5%, 52 4% 52 4%
- // generation 62: 54 4%, 54 5%, 54 4%, 54 5%, 54 5%, 51 4%, 54 5%, 54 4%, 54 5%, 51 4%, 51 4%, 54 4%, 54 5%, 54 4%, 54 5%, 54 5%, 54 5%, 54 5%, 54 4% 54 4%
- // generation 64: 56 4%, 56 5%, 56 4%, 56 5%, 56 5%, 53 4%, 56 5%, 56 4%, 56 5%, 53 4%, 53 4%, 56 4%, 56 5%, 56 4%, 56 5%, 56 5%, 56 5%, 56 5%, 56 4% 56 4%
- // generation 66: 58 4%, 58 4%, 58 4%, 58 5%, 58 5%, 55 4%, 58 5%, 58 4%, 58 5%, 55 4%, 55 4%, 58 4%, 58 5%, 58 4%, 58 5%, 58 5%, 58 5%, 58 5%, 58 4% 58 5%
- // generation 68: 60 4%, 60 5%, 60 4%, 60 5%, 60 5%, 57 4%, 60 5%, 60 4%, 60 5%, 57 4%, 57 4%, 60 4%, 60 5%, 60 4%, 60 5%, 60 5%, 60 5%, 60 5%, 60 4% 60 5%
- // generation 70: 62 4%, 62 5%, 62 4%, 62 5%, 62 5%, 59 4%, 62 5%, 62 4%, 62 5%, 59 4%, 59 4%, 62 4%, 62 5%, 62 4%, 62 5%, 62 5%, 62 5%, 62 5%, 62 4% 62 5%
- // generation 72: 64 4%, 64 5%, 64 4%, 64 5%, 64 5%, 61 4%, 64 5%, 64 4%, 64 5%, 61 4%, 61 4%, 64 4%, 64 5%, 64 4%, 64 5%, 64 5%, 64 4%, 64 5%, 64 4% 64 5%
- // generation 74: 66 4%, 66 5%, 66 4%, 66 5%, 66 5%, 63 4%, 66 5%, 66 4%, 66 5%, 63 4%, 63 4%, 66 4%, 66 5%, 66 4%, 66 5%, 66 5%, 66 4%, 66 5%, 66 4% 66 4%
- // generation 76: 68 4%, 68 5%, 68 4%, 68 5%, 68 5%, 65 4%, 68 5%, 68 4%, 68 5%, 65 4%, 65 4%, 68 4%, 68 4%, 68 4%, 68 5%, 68 5%, 68 4%, 68 5%, 68 4% 68 5%
- // generation 78: 70 4%, 70 5%, 70 4%, 70 5%, 70 5%, 67 4%, 70 5%, 70 4%, 70 5%, 67 4%, 67 4%, 70 4%, 70 4%, 70 4%, 70 5%, 70 5%, 70 5%, 70 5%, 70 4% 70 4%
- // generation 80: 72 4%, 72 5%, 72 4%, 72 5%, 72 5%, 69 4%, 72 5%, 72 4%, 72 5%, 69 4%, 69 4%, 72 4%, 72 4%, 72 4%, 72 5%, 72 5%, 72 4%, 72 5%, 72 4% 72 5%
- // generation 82: 74 4%, 74 5%, 74 4%, 74 5%, 74 5%, 71 4%, 74 5%, 74 4%, 74 5%, 71 4%, 71 4%, 74 4%, 74 4%, 74 4%, 74 5%, 74 5%, 74 4%, 74 5%, 74 4% 74 5%
- // generation 84: 76 4%, 76 5%, 76 4%, 76 5%, 76 5%, 73 4%, 76 5%, 76 4%, 76 5%, 73 4%, 73 4%, 76 4%, 76 4%, 76 4%, 76 5%, 76 5%, 76 4%, 76 5%, 76 4% 76 5%
- // generation 86: 78 4%, 78 5%, 78 4%, 78 5%, 78 5%, 75 4%, 78 5%, 78 4%, 78 5%, 75 4%, 75 4%, 78 4%, 78 4%, 78 4%, 78 5%, 78 5%, 78 4%, 78 5%, 78 4% 78 4%
- // generation 88: 80 4%, 80 5%, 80 4%, 80 5%, 80 5%, 77 4%, 80 5%, 80 4%, 80 5%, 77 4%, 77 4%, 80 4%, 80 4%, 80 4%, 80 5%, 80 5%, 80 5%, 80 5%, 80 4% 80 4%
- // generation 90: 81 4%, 81 5%, 81 4%, 81 5%, 81 5%, 78 4%, 81 5%, 81 5%, 81 5%, 78 4%, 78 4%, 81 4%, 81 4%, 81 4%, 81 5%, 81 5%, 81 5%, 81 5%, 81 4% 81 4%
- // generation 92: 81 4%, 81 5%, 81 4%, 81 5%, 81 5%, 78 4%, 81 5%, 81 5%, 81 5%, 78 4%, 78 4%, 81 4%, 81 4%, 81 4%, 81 5%, 81 5%, 81 5%, 81 5%, 81 4% 81 4%
- // generation 94: 81 4%, 81 5%, 81 4%, 81 5%, 81 5%, 78 4%, 81 5%, 81 5%, 81 5%, 78 4%, 78 4%, 81 4%, 81 4%, 81 4%, 81 5%, 81 5%, 81 5%, 81 5%, 81 4% 81 4%
- // generation 96: 81 4%, 81 5%, 81 4%, 81 5%, 81 5%, 78 4%, 81 5%, 81 5%, 81 5%, 78 4%, 78 4%, 81 4%, 81 4%, 81 4%, 81 5%, 81 5%, 81 5%, 81 5%, 81 4% 81 4%
- // generation 98: 81 4%, 81 5%, 81 4%, 81 5%, 81 5%, 78 4%, 81 5%, 81 5%, 81 5%, 78 4%, 78 4%, 81 4%, 81 4%, 81 4%, 81 5%, 81 5%, 81 5%, 81 5%, 81 4% 81 4%
- // Total bytes=839900871, ranges=1611
+ // generation 12: 5 6%, 10 9%, 13 14%, 0 0%, 0 0%, 0 0%, 6 6%, 6 7%, 0 0%, 0 0%, 0 0%, 7 7%, 8 3%, 7 8%, 5 8%, 5 3%, 5 6%, 5 3%, 5 9% 5 4%
+ // generation 14: 7 6%, 10 5%, 13 9%, 6 7%, 0 0%, 0 0%, 7 6%, 7 5%, 7 6%, 0 0%, 0 0%, 7 4%, 8 3%, 7 6%, 7 7%, 7 4%, 7 6%, 7 4%, 7 9% 7 5%
+ // generation 16: 9 7%, 10 5%, 13 6%, 8 7%, 0 0%, 4 3%, 9 5%, 9 5%, 9 6%, 0 0%, 2 1%, 9 5%, 9 3%, 9 5%, 9 8%, 9 4%, 9 6%, 9 4%, 9 7% 9 6%
+ // generation 18: 11 7%, 11 4%, 13 5%, 10 6%, 1 0%, 6 3%, 11 5%, 11 5%, 11 6%, 3 1%, 4 2%, 11 5%, 11 4%, 11 4%, 11 7%, 11 4%, 11 6%, 11 4%, 11 7% 11 6%
+ // generation 20: 13 7%, 13 5%, 13 4%, 12 6%, 5 3%, 8 3%, 13 5%, 13 5%, 13 6%, 5 1%, 6 2%, 13 5%, 13 3%, 13 4%, 13 7%, 13 4%, 13 5%, 13 4%, 13 6% 13 6%
+ // generation 22: 15 6%, 15 4%, 15 4%, 14 6%, 7 2%, 10 3%, 15 5%, 15 4%, 15 5%, 7 2%, 8 3%, 15 5%, 15 4%, 15 4%, 15 6%, 15 5%, 15 5%, 15 5%, 15 6% 15 6%
+ // generation 24: 17 6%, 17 4%, 17 5%, 16 5%, 9 3%, 12 4%, 17 5%, 17 5%, 17 5%, 9 2%, 10 3%, 17 4%, 17 4%, 17 4%, 17 6%, 17 5%, 17 5%, 17 4%, 17 6% 17 6%
+ // generation 26: 19 6%, 19 4%, 19 4%, 18 5%, 11 3%, 14 3%, 19 5%, 19 5%, 19 6%, 11 2%, 12 3%, 19 5%, 19 4%, 19 4%, 19 5%, 19 5%, 19 5%, 19 4%, 19 6% 19 6%
+ // generation 28: 21 6%, 21 4%, 21 4%, 20 5%, 13 3%, 16 3%, 21 5%, 21 5%, 21 6%, 13 2%, 14 3%, 21 4%, 21 4%, 21 4%, 21 6%, 21 4%, 21 5%, 21 4%, 21 5% 21 6%
+ // generation 30: 23 5%, 23 4%, 23 5%, 22 5%, 15 3%, 18 3%, 23 5%, 23 5%, 23 6%, 15 2%, 16 3%, 23 5%, 23 4%, 23 4%, 23 6%, 23 4%, 23 5%, 23 4%, 23 5% 23 6%
+ // generation 32: 25 5%, 25 4%, 25 5%, 24 5%, 17 4%, 20 3%, 25 5%, 25 4%, 25 6%, 17 2%, 18 3%, 25 5%, 25 4%, 25 4%, 25 6%, 25 4%, 25 4%, 25 5%, 25 5% 25 6%
+ // generation 34: 27 5%, 27 4%, 27 5%, 26 5%, 19 4%, 22 4%, 27 5%, 27 5%, 27 6%, 19 3%, 20 3%, 27 5%, 27 4%, 27 4%, 27 5%, 27 5%, 27 4%, 27 5%, 27 5% 27 6%
+ // generation 36: 29 5%, 29 4%, 29 5%, 28 5%, 21 4%, 24 3%, 29 5%, 29 4%, 29 6%, 21 3%, 22 3%, 29 5%, 29 4%, 29 4%, 29 5%, 29 4%, 29 4%, 29 5%, 29 5% 29 6%
+ // generation 38: 31 5%, 31 4%, 31 5%, 30 5%, 23 4%, 26 4%, 31 5%, 31 4%, 31 6%, 23 3%, 24 3%, 31 5%, 31 4%, 31 4%, 31 5%, 31 4%, 31 4%, 31 5%, 31 5% 31 6%
+ // generation 40: 33 5%, 33 4%, 33 5%, 32 4%, 25 4%, 28 4%, 33 6%, 33 5%, 33 6%, 25 3%, 26 3%, 33 5%, 33 4%, 33 4%, 33 5%, 33 4%, 33 4%, 33 5%, 33 5% 33 6%
+ // generation 42: 35 5%, 35 4%, 35 5%, 34 4%, 27 4%, 30 4%, 35 6%, 35 4%, 35 5%, 27 3%, 28 3%, 35 5%, 35 4%, 35 4%, 35 5%, 35 4%, 35 4%, 35 5%, 35 5% 35 6%
+ // generation 44: 37 5%, 37 4%, 37 5%, 36 4%, 29 4%, 32 4%, 37 6%, 37 4%, 37 5%, 29 4%, 30 3%, 37 5%, 37 4%, 37 4%, 37 5%, 37 5%, 37 4%, 37 5%, 37 5% 37 6%
+ // generation 46: 39 5%, 39 4%, 39 5%, 38 4%, 31 4%, 34 4%, 39 5%, 39 4%, 39 5%, 31 4%, 32 3%, 39 5%, 39 4%, 39 4%, 39 5%, 39 5%, 39 4%, 39 5%, 39 5% 39 5%
+ // generation 48: 41 5%, 41 4%, 41 5%, 40 4%, 33 4%, 36 4%, 41 5%, 41 4%, 41 5%, 33 4%, 34 3%, 41 5%, 41 4%, 41 4%, 41 5%, 41 4%, 41 4%, 41 4%, 41 5% 41 6%
+ // generation 50: 43 5%, 43 4%, 43 5%, 42 4%, 35 4%, 38 4%, 43 5%, 43 5%, 43 5%, 35 4%, 36 3%, 43 5%, 43 4%, 43 5%, 43 5%, 43 4%, 43 5%, 43 5%, 43 5% 43 5%
+ // generation 52: 45 5%, 45 4%, 45 5%, 44 4%, 37 4%, 40 4%, 45 5%, 45 4%, 45 5%, 37 4%, 38 3%, 45 4%, 45 4%, 45 4%, 45 5%, 45 4%, 45 5%, 45 5%, 45 5% 45 5%
+ // generation 54: 47 5%, 47 4%, 47 5%, 46 4%, 39 4%, 42 4%, 47 5%, 47 4%, 47 5%, 39 4%, 40 3%, 47 4%, 47 4%, 47 5%, 47 5%, 47 4%, 47 5%, 47 5%, 47 5% 47 5%
+ // generation 56: 49 5%, 49 4%, 49 5%, 48 4%, 41 4%, 44 4%, 49 5%, 49 4%, 49 5%, 41 4%, 42 3%, 49 4%, 49 4%, 49 5%, 49 5%, 49 4%, 49 5%, 49 5%, 49 5% 49 5%
+ // generation 58: 51 5%, 51 4%, 51 5%, 50 4%, 43 4%, 46 4%, 51 5%, 51 4%, 51 5%, 43 4%, 44 3%, 51 4%, 51 4%, 51 4%, 51 5%, 51 4%, 51 5%, 51 5%, 51 5% 51 5%
+ // generation 60: 53 5%, 53 4%, 53 5%, 52 4%, 45 4%, 48 4%, 53 5%, 53 4%, 53 5%, 45 4%, 46 3%, 53 4%, 53 4%, 53 4%, 53 5%, 53 4%, 53 5%, 53 5%, 53 5% 53 5%
+ // generation 62: 55 5%, 55 4%, 55 5%, 54 4%, 47 4%, 50 4%, 55 5%, 55 4%, 55 5%, 47 4%, 48 3%, 55 4%, 55 4%, 55 5%, 55 5%, 55 4%, 55 5%, 55 5%, 55 5% 55 5%
+ // generation 64: 57 5%, 57 5%, 57 5%, 56 4%, 49 4%, 52 4%, 57 5%, 57 4%, 57 5%, 49 4%, 50 3%, 57 4%, 57 4%, 57 5%, 57 5%, 57 5%, 57 5%, 57 5%, 57 5% 57 5%
+ // generation 66: 59 5%, 59 4%, 59 5%, 58 4%, 51 4%, 54 3%, 59 5%, 59 4%, 59 5%, 51 4%, 52 3%, 59 4%, 59 4%, 59 5%, 59 5%, 59 5%, 59 4%, 59 5%, 59 5% 59 5%
+ // generation 68: 61 5%, 61 4%, 61 5%, 60 4%, 53 4%, 56 4%, 61 5%, 61 4%, 61 5%, 53 4%, 54 4%, 61 4%, 61 4%, 61 5%, 61 5%, 61 5%, 61 4%, 61 5%, 61 5% 61 5%
+ // generation 70: 63 5%, 63 4%, 63 5%, 62 4%, 55 4%, 58 3%, 63 5%, 63 4%, 63 5%, 55 4%, 56 4%, 63 4%, 63 4%, 63 5%, 63 5%, 63 5%, 63 4%, 63 5%, 63 5% 63 5%
+ // generation 72: 65 5%, 65 4%, 65 5%, 64 4%, 57 4%, 60 4%, 65 5%, 65 4%, 65 5%, 57 4%, 58 4%, 65 4%, 65 4%, 65 5%, 65 5%, 65 4%, 65 4%, 65 5%, 65 5% 65 5%
+ // generation 74: 67 5%, 67 4%, 67 5%, 66 4%, 59 4%, 62 4%, 67 5%, 67 4%, 67 5%, 59 4%, 60 4%, 67 4%, 67 4%, 67 5%, 67 5%, 67 5%, 67 4%, 67 5%, 67 5% 67 5%
+ // generation 76: 69 5%, 69 4%, 69 5%, 68 4%, 61 4%, 64 4%, 69 5%, 69 4%, 69 5%, 61 4%, 62 4%, 69 4%, 69 4%, 69 5%, 69 5%, 69 5%, 69 4%, 69 5%, 69 5% 69 5%
+ // generation 78: 71 5%, 71 4%, 71 5%, 70 4%, 63 4%, 66 4%, 71 5%, 71 4%, 71 5%, 63 4%, 64 4%, 71 4%, 71 4%, 71 5%, 71 5%, 71 5%, 71 4%, 71 5%, 71 5% 71 5%
+ // generation 80: 73 5%, 73 4%, 73 5%, 72 4%, 65 4%, 68 4%, 73 5%, 73 4%, 73 5%, 65 4%, 66 4%, 73 5%, 73 4%, 73 5%, 73 5%, 73 5%, 73 4%, 73 5%, 73 5% 73 5%
+ // generation 82: 75 5%, 75 4%, 75 5%, 74 4%, 67 4%, 70 4%, 75 5%, 75 4%, 75 5%, 67 4%, 68 4%, 75 5%, 75 5%, 75 4%, 75 5%, 75 5%, 75 4%, 75 5%, 75 5% 75 5%
+ // generation 84: 77 5%, 77 4%, 77 5%, 76 4%, 69 4%, 72 4%, 77 5%, 77 4%, 77 5%, 69 4%, 70 4%, 77 4%, 77 5%, 77 4%, 77 5%, 77 5%, 77 4%, 77 5%, 77 5% 77 5%
+ // generation 86: 79 5%, 79 4%, 79 5%, 78 4%, 71 4%, 74 4%, 79 5%, 79 4%, 79 5%, 71 4%, 72 4%, 79 4%, 79 5%, 79 4%, 79 5%, 79 4%, 79 4%, 79 5%, 79 5% 79 5%
+ // generation 88: 81 5%, 81 4%, 81 5%, 80 4%, 73 4%, 76 4%, 81 5%, 81 4%, 81 5%, 73 4%, 74 4%, 81 4%, 81 5%, 81 4%, 81 5%, 81 5%, 81 4%, 81 5%, 81 5% 81 5%
+ // generation 90: 82 5%, 82 4%, 82 5%, 81 4%, 74 4%, 77 4%, 82 5%, 82 4%, 82 5%, 74 4%, 75 4%, 82 4%, 82 5%, 82 4%, 82 5%, 82 5%, 82 4%, 82 5%, 82 5% 82 5%
+ // generation 92: 82 5%, 82 4%, 82 5%, 81 4%, 74 4%, 77 4%, 82 5%, 82 4%, 82 5%, 74 4%, 75 4%, 82 4%, 82 5%, 82 4%, 82 5%, 82 5%, 82 4%, 82 5%, 82 5% 82 5%
+ // generation 94: 82 5%, 82 4%, 82 5%, 81 4%, 74 4%, 77 4%, 82 5%, 82 4%, 82 5%, 74 4%, 75 4%, 82 4%, 82 5%, 82 4%, 82 5%, 82 5%, 82 4%, 82 5%, 82 5% 82 5%
+ // generation 96: 82 5%, 82 4%, 82 5%, 81 4%, 74 4%, 77 4%, 82 5%, 82 4%, 82 5%, 74 4%, 75 4%, 82 4%, 82 5%, 82 4%, 82 5%, 82 5%, 82 4%, 82 5%, 82 5% 82 5%
+ // generation 98: 82 5%, 82 4%, 82 5%, 81 4%, 74 4%, 77 4%, 82 5%, 82 4%, 82 5%, 74 4%, 75 4%, 82 4%, 82 5%, 82 4%, 82 5%, 82 5%, 82 4%, 82 5%, 82 5% 82 5%
+ // Total bytes=839646296, ranges=1611
}
diff --git a/storage/client_raft_test.go b/storage/client_raft_test.go
index 4dab05e..b7bc8fa 100644
--- a/storage/client_raft_test.go
+++ b/storage/client_raft_test.go
@@ -869,7 +869,7 @@ func getRangeMetadata(key roachpb.RKey, mtc *multiTestContext, t *testing.T) roa
MaxRanges: 1,
})
var reply *roachpb.RangeLookupResponse
- if err := mtc.dbs[0].Run(b); err != nil {
+ if err := mtc.dbs[0].Run(context.TODO(), b); err != nil {
t.Fatalf("error getting range metadata: %s", err)
} else {
reply = b.RawResponse().Responses[0].GetInner().(*roachpb.RangeLookupResponse)
@@ -1705,6 +1705,11 @@ func TestStoreRangeRemoveDead(t *testing.T) {
func TestStoreRangeRebalance(t *testing.T) {
defer leaktest.AfterTest(t)()
+ defer func(threshold float64) {
+ storage.RebalanceThreshold = threshold
+ }(storage.RebalanceThreshold)
+ storage.RebalanceThreshold = 0
+
// Start multiTestContext with replica rebalancing enabled.
sc := storage.TestStoreContext()
sc.AllocatorOptions = storage.AllocatorOptions{
diff --git a/storage/gc_queue.go b/storage/gc_queue.go
index 896ce12..a57e97b 100644
--- a/storage/gc_queue.go
+++ b/storage/gc_queue.go
@@ -577,9 +577,7 @@ func (*gcQueue) purgatoryChan() <-chan struct{} {
// pushTxn attempts to abort the txn via push. The wait group is signaled on
// completion.
-func pushTxn(db *client.DB, now hlc.Timestamp, txn *roachpb.Transaction,
- typ roachpb.PushTxnType) {
-
+func pushTxn(db *client.DB, now hlc.Timestamp, txn *roachpb.Transaction, typ roachpb.PushTxnType) {
// Attempt to push the transaction which created the intent.
pushArgs := &roachpb.PushTxnRequest{
Span: roachpb.Span{
@@ -592,7 +590,7 @@ func pushTxn(db *client.DB, now hlc.Timestamp, txn *roachpb.Transaction,
}
b := &client.Batch{}
b.AddRawRequest(pushArgs)
- if err := db.Run(b); err != nil {
+ if err := db.Run(context.TODO(), b); err != nil {
log.Warningf(context.TODO(), "push of txn %s failed: %s", txn, err)
return
}
diff --git a/storage/intent_resolver.go b/storage/intent_resolver.go
index c951bf5..b6b005b 100644
--- a/storage/intent_resolver.go
+++ b/storage/intent_resolver.go
@@ -227,7 +227,7 @@ func (ir *intentResolver) maybePushTransactions(
b := &client.Batch{}
b.AddRawRequest(pushReqs...)
var pErr *roachpb.Error
- if err := ir.store.db.Run(b); err != nil {
+ if err := ir.store.db.Run(ctx, b); err != nil {
pErr = b.MustPErr()
}
ir.mu.Lock()
@@ -296,15 +296,15 @@ func (ir *intentResolver) processIntentsAsync(r *Replica, intents []intentsWithA
// poison.
if err := ir.resolveIntents(ctxWithTimeout, resolveIntents,
true /* wait */, true /* poison */); err != nil {
- log.Warningf(context.TODO(), "%s: failed to resolve intents: %s", r, err)
+ log.Warningf(ctx, "%s: failed to resolve intents: %s", r, err)
return
}
if pushErr != nil {
- log.Warningf(context.TODO(), "%s: failed to push during intent resolution: %s", r, pushErr)
+ log.Warningf(ctx, "%s: failed to push during intent resolution: %s", r, pushErr)
return
}
}); err != nil {
- log.Warningf(context.TODO(), "failed to resolve intents: %s", err)
+ log.Warningf(ctx, "failed to resolve intents: %s", err)
return
}
} else { // EndTransaction
@@ -322,7 +322,7 @@ func (ir *intentResolver) processIntentsAsync(r *Replica, intents []intentsWithA
// not make it back to the client.
if err := ir.resolveIntents(ctxWithTimeout, item.intents,
true /* wait */, false /* !poison */); err != nil {
- log.Warningf(context.TODO(), "%s: failed to resolve intents: %s", r, err)
+ log.Warningf(ctx, "%s: failed to resolve intents: %s", r, err)
return
}
@@ -363,16 +363,13 @@ func (ir *intentResolver) processIntentsAsync(r *Replica, intents []intentsWithA
Key: txnKey,
})
b.AddRawRequest(&gcArgs)
- if err := ir.store.db.Run(b); err != nil {
- log.Warningf(
- context.TODO(),
- "could not GC completed transaction anchored at %s: %s",
- roachpb.Key(txn.Key), err,
- )
+ if err := ir.store.db.Run(ctx, b); err != nil {
+ log.Warningf(ctx, "could not GC completed transaction anchored at %s: %s",
+ roachpb.Key(txn.Key), err)
return
}
}); err != nil {
- log.Warningf(context.TODO(), "failed to resolve intents: %s", err)
+ log.Warningf(ctx, "failed to resolve intents: %s", err)
return
}
}
@@ -433,7 +430,7 @@ func (ir *intentResolver) resolveIntents(ctx context.Context,
b.AddRawRequest(reqs...)
action := func() error {
// TODO(tschottdorf): no tracing here yet.
- return ir.store.DB().Run(b)
+ return ir.store.DB().Run(ctx, b)
}
if wait || ir.store.Stopper().RunLimitedAsyncTask(ir.sem, func() {
if err := action(); err != nil {
diff --git a/storage/raft_log_queue.go b/storage/raft_log_queue.go
index eafd908..f2b5d8b 100644
--- a/storage/raft_log_queue.go
+++ b/storage/raft_log_queue.go
@@ -208,7 +208,7 @@ func (rlq *raftLogQueue) process(
Index: oldestIndex,
RangeID: r.RangeID,
})
- return rlq.db.Run(b)
+ return rlq.db.Run(ctx, b)
}
return nil
}
diff --git a/storage/replica_gc_queue.go b/storage/replica_gc_queue.go
index 74d7fa7..d42a571 100644
--- a/storage/replica_gc_queue.go
+++ b/storage/replica_gc_queue.go
@@ -166,7 +166,7 @@ func (q *replicaGCQueue) process(
},
MaxRanges: 1,
})
- if err := q.db.Run(b); err != nil {
+ if err := q.db.Run(ctx, b); err != nil {
return err
}
br := b.RawResponse()
diff --git a/storage/store.go b/storage/store.go
index af74f9f..3f59057 100644
--- a/storage/store.go
+++ b/storage/store.go
@@ -2214,7 +2214,7 @@ func (s *Store) maybeUpdateTransaction(txn *roachpb.Transaction, now hlc.Timesta
PusheeTxn: txn.TxnMeta,
PushType: roachpb.PUSH_QUERY,
})
- if err := s.db.Run(b); err != nil {
+ if err := s.db.Run(context.TODO(), b); err != nil {
// TODO(tschottdorf):
// We shouldn't catch an error here (unless it's from the abort cache, in
// which case we would not get the crucial information that we've been
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment