Documentation ¶
Overview ¶
Package storage is a generated protocol buffer package. It is generated from these files: cockroach/pkg/storage/api.proto cockroach/pkg/storage/liveness.proto cockroach/pkg/storage/raft.proto It has these top-level messages: StoreRequestHeader PollFrozenRequest PollFrozenResponse CollectChecksumRequest CollectChecksumResponse Liveness RaftHeartbeat RaftMessageRequest RaftMessageRequestBatch RaftMessageResponseUnion RaftMessageResponse SnapshotRequest SnapshotResponse ConfChangeContext
Package storage provides access to the Store and Range abstractions. Each Cockroach node handles one or more stores, each of which multiplexes to one or more ranges, identified by [start, end) keys. Ranges are contiguous regions of the keyspace. Each range implements an instance of the Raft consensus algorithm to synchronize participating range replicas.
Each store is represented by a single engine.Engine instance. The ranges hosted by a store all have access to the same engine, but write to only a range-limited keyspace within it. Ranges access the underlying engine via the MVCC interface, which provides historical versioned values.
Example (Rebalancing) ¶
exampleRebalancingCore(false /* useRuleSolver */)
Output: +-----+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+ | gen | store 0 | store 1 | store 2 | store 3 | store 4 | store 5 | store 6 | store 7 | store 8 | store 9 | store 10 | store 11 | store 12 | store 13 | store 14 | store 15 | store 16 | store 17 | store 18 | store 19 | +-----+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+ | 0 | 2 100% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | | 2 | 4 100% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | | 4 | 6 100% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | | 6 | 8 100% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | | 8 | 10 100% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | | 10 | 10 80% | 0 0% | 0 0% | 0 0% | 1 1% | 0 0% | 0 0% | 1 9% | 0 0% | 0 0% | 0 0% | 0 0% | 1 8% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | | 12 | 10 47% | 1 5% | 2 4% | 0 0% | 2 3% | 1 3% | 0 0% | 1 10% | 1 0% | 0 0% | 1 0% | 1 8% | 1 8% | 0 0% | 1 2% | 0 0% | 1 1% | 0 0% | 1 2% | 0 0% | | 14 | 11 22% | 3 5% | 3 5% | 1 0% | 3 4% | 3 7% | 0 0% | 3 8% | 3 6% | 2 1% | 3 3% | 3 7% | 3 8% | 2 3% | 3 6% | 0 0% | 3 3% | 0 0% | 3 4% | 0 0% | | 16 | 13 15% | 5 6% | 4 3% | 4 3% | 4 4% | 5 8% | 3 4% | 4 7% | 4 5% | 4 2% | 4 3% | 4 5% | 4 4% | 4 3% | 4 4% | 2 1% | 5 4% | 4 2% | 5 4% | 2 2% | | 18 | 14 11% | 7 6% | 6 3% | 6 3% | 6 4% | 6 6% | 5 3% | 6 6% | 6 5% | 6 4% | 6 3% | 6 6% | 6 4% | 6 3% | 6 4% | 5 3% | 6 5% | 6 2% | 7 4% | 6 4% | | 20 | 16 10% | 9 6% | 8 3% | 8 4% | 8 4% | 8 5% | 7 4% | 8 6% | 8 5% | 8 4% | 8 4% | 8 6% | 8 4% | 8 3% | 8 5% | 7 2% | 8 4% | 8 3% | 9 4% | 8 4% | | 22 | 18 9% | 11 5% | 10 3% | 10 3% | 10 5% | 10 5% | 9 4% | 10 5% | 10 5% | 10 5% | 10 4% | 10 5% | 10 4% | 10 3% | 10 5% | 9 3% | 10 5% | 10 3% | 11 4% | 10 5% | | 24 | 19 8% | 13 5% | 12 2% | 12 4% | 12 5% | 12 5% | 12 5% | 12 5% | 12 5% | 12 5% | 12 4% | 12 5% | 12 4% | 12 3% | 12 4% | 11 4% | 12 5% | 12 4% | 13 4% | 12 5% | | 26 | 21 7% | 15 5% | 14 3% | 14 4% | 14 5% | 14 5% | 14 5% | 14 5% | 14 5% | 14 5% | 14 4% | 14 5% | 14 4% | 14 4% | 14 4% | 13 4% | 14 4% | 14 4% | 15 4% | 14 5% | | 28 | 22 6% | 17 5% | 16 3% | 16 4% | 16 5% | 16 6% | 16 5% | 16 5% | 16 5% | 16 5% | 16 4% | 16 5% | 16 4% | 16 4% | 16 4% | 16 4% | 16 4% | 16 4% | 17 4% | 16 5% | | 30 | 24 6% | 19 5% | 18 3% | 18 4% | 18 5% | 18 5% | 18 4% | 18 5% | 18 5% | 18 5% | 18 3% | 18 5% | 18 4% | 18 4% | 18 4% | 18 4% | 18 4% | 18 4% | 19 4% | 18 6% | | 32 | 26 6% | 21 5% | 20 3% | 20 4% | 20 5% | 20 6% | 20 4% | 20 5% | 20 5% | 20 5% | 20 3% | 20 5% | 20 4% | 20 4% | 20 5% | 20 4% | 20 4% | 20 4% | 21 4% | 20 6% | | 34 | 28 5% | 23 5% | 22 4% | 22 4% | 22 5% | 22 5% | 22 4% | 22 5% | 22 5% | 22 5% | 22 3% | 22 5% | 22 4% | 22 4% | 22 5% | 22 4% | 22 4% | 22 4% | 23 4% | 22 6% | | 36 | 30 5% | 25 5% | 24 4% | 24 4% | 24 5% | 24 6% | 24 4% | 24 5% | 24 5% | 24 5% | 24 4% | 24 5% | 24 4% | 24 4% | 24 5% | 24 4% | 24 4% | 24 4% | 25 4% | 24 6% | | 38 | 32 5% | 27 5% | 26 4% | 26 4% | 26 5% | 26 5% | 26 4% | 26 5% | 26 5% | 26 5% | 26 4% | 26 5% | 26 4% | 26 4% | 26 5% | 26 4% | 26 4% | 26 4% | 27 4% | 26 6% | | 40 | 34 5% | 29 5% | 28 4% | 28 4% | 28 5% | 28 5% | 28 4% | 28 4% | 28 5% | 28 5% | 28 4% | 28 5% | 28 4% | 28 4% | 28 5% | 28 4% | 28 4% | 28 4% | 29 5% | 28 6% | | 42 | 36 5% | 31 5% | 30 4% | 30 4% | 30 5% | 30 5% | 30 4% | 30 4% | 30 5% | 30 5% | 30 4% | 30 4% | 30 4% | 30 4% | 30 5% | 30 4% | 30 4% | 30 4% | 31 5% | 30 6% | | 44 | 38 5% | 33 5% | 32 4% | 32 4% | 32 5% | 32 5% | 32 4% | 32 4% | 32 5% | 32 5% | 32 4% | 32 5% | 32 4% | 32 4% | 32 5% | 32 4% | 32 4% | 32 4% | 33 5% | 32 6% | | 46 | 40 5% | 35 5% | 34 4% | 34 4% | 34 4% | 34 5% | 34 4% | 34 4% | 34 5% | 34 5% | 34 4% | 34 5% | 34 4% | 34 4% | 34 5% | 34 4% | 34 4% | 34 4% | 35 4% | 34 6% | | 48 | 42 5% | 37 5% | 36 4% | 36 5% | 36 5% | 36 5% | 36 4% | 36 4% | 36 5% | 36 5% | 36 4% | 36 5% | 36 4% | 36 4% | 36 5% | 36 4% | 36 4% | 36 4% | 37 4% | 36 5% | | 50 | 44 5% | 39 5% | 38 4% | 38 5% | 38 4% | 38 5% | 38 5% | 38 5% | 38 5% | 38 4% | 38 4% | 38 5% | 38 4% | 38 4% | 38 5% | 38 3% | 38 4% | 38 4% | 39 5% | 38 5% | | 52 | 46 5% | 41 5% | 40 4% | 40 5% | 40 4% | 40 5% | 40 5% | 40 5% | 40 5% | 40 5% | 40 4% | 40 5% | 40 4% | 40 4% | 40 5% | 40 4% | 40 4% | 40 4% | 41 4% | 40 5% | | 54 | 48 5% | 43 5% | 42 4% | 42 5% | 42 4% | 42 5% | 42 5% | 42 5% | 42 4% | 42 5% | 42 4% | 42 5% | 42 5% | 42 4% | 42 5% | 42 4% | 42 4% | 42 4% | 43 4% | 42 5% | | 56 | 50 5% | 45 5% | 44 4% | 44 5% | 44 4% | 44 5% | 44 5% | 44 5% | 44 5% | 44 5% | 44 4% | 44 5% | 44 5% | 44 4% | 44 5% | 44 4% | 44 4% | 44 4% | 45 4% | 44 5% | | 58 | 52 5% | 47 5% | 46 4% | 46 5% | 46 4% | 46 5% | 46 5% | 46 5% | 46 5% | 46 5% | 46 4% | 46 5% | 46 4% | 46 4% | 46 5% | 46 4% | 46 4% | 46 4% | 47 4% | 46 5% | | 60 | 54 5% | 49 5% | 48 4% | 48 5% | 48 4% | 48 5% | 48 5% | 48 5% | 48 5% | 48 5% | 48 4% | 48 5% | 48 4% | 48 4% | 48 5% | 48 4% | 48 4% | 48 4% | 49 4% | 48 5% | | 62 | 56 5% | 51 5% | 50 4% | 50 5% | 50 4% | 50 5% | 50 5% | 50 5% | 50 5% | 50 5% | 50 4% | 50 5% | 50 4% | 50 4% | 50 5% | 50 4% | 50 4% | 50 4% | 51 4% | 50 5% | | 64 | 58 5% | 53 5% | 52 4% | 52 5% | 52 4% | 52 5% | 52 5% | 52 5% | 52 5% | 52 5% | 52 4% | 52 5% | 52 4% | 52 4% | 52 5% | 52 4% | 52 4% | 52 4% | 53 5% | 52 5% | | 66 | 60 5% | 55 5% | 54 4% | 54 5% | 54 4% | 54 5% | 54 5% | 54 4% | 54 5% | 54 5% | 54 4% | 54 5% | 54 4% | 54 4% | 54 4% | 54 4% | 54 5% | 54 4% | 55 5% | 54 5% | | 68 | 62 5% | 57 5% | 56 4% | 56 5% | 56 4% | 56 5% | 56 5% | 56 4% | 56 5% | 56 5% | 56 4% | 56 5% | 56 4% | 56 4% | 56 4% | 56 4% | 56 5% | 56 4% | 57 5% | 56 5% | | 70 | 64 5% | 59 5% | 58 4% | 58 5% | 58 4% | 58 5% | 58 4% | 58 5% | 58 5% | 58 5% | 58 4% | 58 5% | 58 4% | 58 4% | 58 5% | 58 4% | 58 5% | 58 4% | 59 5% | 58 5% | | 72 | 66 5% | 61 5% | 60 4% | 60 5% | 60 4% | 60 5% | 60 4% | 60 4% | 60 5% | 60 5% | 60 4% | 60 5% | 60 5% | 60 4% | 60 4% | 60 4% | 60 5% | 60 4% | 61 5% | 60 5% | | 74 | 68 5% | 63 5% | 62 4% | 62 5% | 62 4% | 62 5% | 62 4% | 62 4% | 62 5% | 62 5% | 62 4% | 62 5% | 62 5% | 62 4% | 62 5% | 62 4% | 62 5% | 62 4% | 63 5% | 62 5% | | 76 | 70 5% | 65 5% | 64 4% | 64 5% | 64 4% | 64 5% | 64 4% | 64 4% | 64 5% | 64 5% | 64 4% | 64 5% | 64 5% | 64 4% | 64 4% | 64 4% | 64 4% | 64 4% | 65 5% | 64 5% | | 78 | 72 5% | 67 5% | 66 4% | 66 5% | 66 4% | 66 5% | 66 4% | 66 4% | 66 5% | 66 5% | 66 4% | 66 5% | 66 4% | 66 4% | 66 5% | 66 4% | 66 5% | 66 4% | 67 5% | 66 5% | | 80 | 74 5% | 69 5% | 68 4% | 68 5% | 68 4% | 68 5% | 68 4% | 68 4% | 68 5% | 68 5% | 68 4% | 68 5% | 68 4% | 68 4% | 68 5% | 68 4% | 68 5% | 68 4% | 69 5% | 68 5% | | 82 | 76 5% | 71 5% | 70 4% | 70 5% | 70 4% | 70 5% | 70 4% | 70 5% | 70 5% | 70 5% | 70 4% | 70 5% | 70 4% | 70 4% | 70 4% | 70 4% | 70 5% | 70 4% | 71 5% | 70 5% | | 84 | 78 5% | 73 5% | 72 4% | 72 5% | 72 4% | 72 5% | 72 4% | 72 5% | 72 5% | 72 5% | 72 4% | 72 5% | 72 4% | 72 4% | 72 4% | 72 4% | 72 5% | 72 4% | 73 5% | 72 5% | | 86 | 80 5% | 75 5% | 74 4% | 74 5% | 74 4% | 74 5% | 74 4% | 74 5% | 74 5% | 74 5% | 74 4% | 74 5% | 74 4% | 74 4% | 74 5% | 74 4% | 74 4% | 74 4% | 75 5% | 74 5% | | 88 | 82 5% | 77 5% | 76 4% | 76 5% | 76 4% | 76 5% | 76 4% | 76 5% | 76 5% | 76 5% | 76 4% | 76 5% | 76 4% | 76 4% | 76 5% | 76 4% | 76 4% | 76 4% | 77 5% | 76 5% | | 90 | 84 5% | 79 5% | 78 4% | 78 5% | 78 4% | 78 5% | 78 4% | 78 4% | 78 5% | 78 5% | 78 4% | 78 5% | 78 4% | 78 4% | 78 5% | 78 4% | 78 4% | 78 4% | 79 5% | 78 5% | | 92 | 86 5% | 81 5% | 80 4% | 80 5% | 80 4% | 80 5% | 80 4% | 80 4% | 80 5% | 80 5% | 80 4% | 80 5% | 80 4% | 80 4% | 80 5% | 80 4% | 80 5% | 80 4% | 81 5% | 80 5% | | 94 | 88 5% | 83 5% | 82 4% | 82 5% | 82 4% | 82 5% | 82 4% | 82 4% | 82 5% | 82 5% | 82 4% | 82 5% | 82 4% | 82 4% | 82 5% | 82 4% | 82 5% | 82 4% | 83 5% | 82 5% | | 96 | 90 5% | 85 5% | 84 4% | 84 5% | 84 4% | 84 5% | 84 4% | 84 4% | 84 5% | 84 5% | 84 4% | 84 5% | 84 4% | 84 4% | 84 4% | 84 4% | 84 5% | 84 4% | 85 5% | 84 5% | | 98 | 92 5% | 87 5% | 86 4% | 86 5% | 86 4% | 86 5% | 86 4% | 86 4% | 86 5% | 86 5% | 86 4% | 86 5% | 86 4% | 86 4% | 86 5% | 86 4% | 86 5% | 86 4% | 87 5% | 86 5% | +-----+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+ Total bytes=914193506, ranges=1748
Example (RebalancingWithRuleSolver) ¶
exampleRebalancingCore(true /* useRuleSolver */)
Output: +-----+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+ | gen | store 0 | store 1 | store 2 | store 3 | store 4 | store 5 | store 6 | store 7 | store 8 | store 9 | store 10 | store 11 | store 12 | store 13 | store 14 | store 15 | store 16 | store 17 | store 18 | store 19 | +-----+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+ | 0 | 1 88% | 1 11% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | | 2 | 1 32% | 2 24% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 2 21% | 2 20% | | 4 | 2 9% | 2 22% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 0 0% | 3 5% | 1 0% | 2 9% | 2 19% | 2 21% | 3 9% | | 6 | 3 5% | 2 5% | 0 0% | 0 0% | 0 0% | 0 0% | 6 15% | 1 3% | 0 0% | 0 0% | 0 0% | 0 0% | 2 4% | 7 27% | 3 1% | 2 3% | 2 6% | 2 10% | 2 9% | 3 6% | | 8 | 3 4% | 3 5% | 0 0% | 0 0% | 0 0% | 0 0% | 6 9% | 3 2% | 7 8% | 7 6% | 3 7% | 0 0% | 3 4% | 7 17% | 4 3% | 3 2% | 3 6% | 3 9% | 3 6% | 3 5% | | 10 | 5 3% | 5 4% | 0 0% | 0 0% | 5 4% | 5 6% | 6 6% | 5 4% | 7 5% | 7 5% | 5 8% | 0 0% | 5 5% | 7 11% | 5 3% | 5 4% | 5 5% | 5 9% | 5 5% | 5 5% | | 12 | 6 3% | 6 3% | 5 5% | 15 14% | 6 3% | 6 6% | 6 4% | 6 3% | 7 2% | 7 3% | 6 7% | 3 1% | 6 4% | 7 7% | 6 3% | 6 2% | 6 3% | 6 7% | 6 4% | 6 5% | | 14 | 8 4% | 8 4% | 8 6% | 15 10% | 8 2% | 8 4% | 8 5% | 8 4% | 8 3% | 8 2% | 8 6% | 9 5% | 8 3% | 8 5% | 8 4% | 8 3% | 8 4% | 8 7% | 8 4% | 8 6% | | 16 | 11 5% | 10 4% | 10 5% | 15 8% | 10 3% | 10 5% | 10 4% | 10 4% | 10 3% | 10 2% | 10 5% | 11 4% | 10 4% | 10 5% | 10 4% | 10 4% | 10 4% | 10 6% | 10 4% | 11 6% | | 18 | 13 4% | 12 4% | 12 6% | 15 7% | 12 3% | 12 5% | 12 4% | 12 4% | 12 4% | 12 2% | 12 6% | 13 5% | 12 4% | 12 5% | 12 5% | 12 4% | 13 5% | 13 6% | 12 4% | 13 6% | | 20 | 15 4% | 14 4% | 14 6% | 16 6% | 14 3% | 14 5% | 14 5% | 14 4% | 14 4% | 14 3% | 14 6% | 15 4% | 14 4% | 14 4% | 14 5% | 15 4% | 15 5% | 15 6% | 14 4% | 15 5% | | 22 | 17 4% | 16 4% | 16 6% | 18 6% | 16 3% | 16 5% | 16 5% | 16 4% | 16 4% | 16 3% | 16 6% | 17 4% | 16 4% | 16 4% | 16 5% | 17 4% | 17 5% | 17 6% | 16 5% | 17 5% | | 24 | 19 4% | 18 4% | 18 6% | 20 6% | 18 3% | 18 5% | 18 5% | 18 4% | 18 4% | 18 3% | 18 5% | 19 4% | 18 4% | 18 4% | 18 5% | 19 4% | 19 5% | 19 6% | 18 5% | 19 5% | | 26 | 21 4% | 20 4% | 20 5% | 22 5% | 20 3% | 20 5% | 20 4% | 20 4% | 20 4% | 20 4% | 20 5% | 21 5% | 20 4% | 20 4% | 20 5% | 21 3% | 21 5% | 21 6% | 20 5% | 21 5% | | 28 | 23 4% | 22 4% | 22 5% | 24 5% | 22 3% | 22 5% | 22 5% | 22 4% | 22 4% | 22 4% | 22 5% | 23 5% | 22 4% | 22 4% | 22 5% | 23 3% | 23 5% | 23 5% | 22 5% | 23 5% | | 30 | 25 4% | 24 4% | 24 5% | 26 5% | 24 3% | 24 5% | 24 4% | 24 4% | 24 4% | 24 4% | 24 5% | 25 4% | 24 4% | 24 5% | 24 5% | 25 4% | 25 5% | 25 6% | 24 5% | 25 5% | | 32 | 27 4% | 26 5% | 26 5% | 28 5% | 26 3% | 26 5% | 26 4% | 26 4% | 26 4% | 26 4% | 26 5% | 27 4% | 26 4% | 26 4% | 26 5% | 27 4% | 27 5% | 27 5% | 26 5% | 27 4% | | 34 | 29 4% | 28 4% | 28 5% | 30 5% | 28 3% | 28 5% | 28 4% | 28 4% | 28 4% | 28 4% | 28 5% | 29 5% | 28 4% | 28 4% | 28 5% | 29 4% | 29 5% | 29 5% | 28 5% | 29 5% | | 36 | 31 4% | 30 4% | 30 5% | 32 5% | 30 3% | 30 5% | 30 4% | 30 4% | 30 4% | 30 5% | 30 5% | 31 4% | 30 4% | 30 4% | 30 5% | 31 4% | 31 5% | 31 5% | 30 5% | 31 5% | | 38 | 33 4% | 32 4% | 32 5% | 34 5% | 32 4% | 32 4% | 32 4% | 32 4% | 32 4% | 32 5% | 32 5% | 33 4% | 32 5% | 32 4% | 32 5% | 33 4% | 33 6% | 33 5% | 32 5% | 33 5% | | 40 | 35 4% | 34 5% | 34 5% | 36 5% | 34 4% | 34 5% | 34 4% | 34 4% | 34 4% | 34 5% | 34 5% | 35 4% | 34 5% | 34 4% | 34 5% | 35 4% | 35 6% | 35 5% | 34 5% | 35 5% | | 42 | 37 4% | 36 4% | 36 5% | 38 5% | 36 4% | 36 5% | 36 4% | 36 4% | 36 4% | 36 4% | 36 5% | 37 5% | 36 5% | 36 4% | 36 5% | 37 4% | 37 5% | 37 5% | 36 5% | 37 5% | | 44 | 39 4% | 38 4% | 38 5% | 40 5% | 38 4% | 38 5% | 38 4% | 38 4% | 38 4% | 38 4% | 38 5% | 39 4% | 38 5% | 38 4% | 38 5% | 39 4% | 39 5% | 39 5% | 38 5% | 39 5% | | 46 | 41 4% | 40 4% | 40 5% | 42 5% | 40 4% | 40 5% | 40 4% | 40 4% | 40 4% | 40 4% | 40 5% | 41 4% | 40 5% | 40 4% | 40 5% | 41 4% | 41 5% | 41 5% | 40 5% | 41 5% | | 48 | 43 4% | 42 4% | 42 5% | 44 5% | 42 4% | 42 5% | 42 5% | 42 4% | 42 4% | 42 4% | 42 5% | 43 4% | 42 5% | 42 4% | 42 5% | 43 4% | 43 5% | 43 5% | 42 5% | 43 5% | | 50 | 45 4% | 44 4% | 44 5% | 46 5% | 44 4% | 44 5% | 44 5% | 44 4% | 44 4% | 44 4% | 44 5% | 45 4% | 44 5% | 44 4% | 44 4% | 45 4% | 45 5% | 45 5% | 44 5% | 45 5% | | 52 | 47 4% | 46 4% | 46 5% | 48 5% | 46 4% | 46 5% | 46 5% | 46 4% | 46 4% | 46 4% | 46 5% | 47 5% | 46 5% | 46 4% | 46 4% | 47 4% | 47 5% | 47 5% | 46 5% | 47 5% | | 54 | 49 4% | 48 4% | 48 5% | 50 5% | 48 4% | 48 5% | 48 5% | 48 4% | 48 4% | 48 4% | 48 5% | 49 5% | 48 5% | 48 4% | 48 4% | 49 4% | 49 5% | 49 5% | 48 5% | 49 5% | | 56 | 51 4% | 50 4% | 50 5% | 52 5% | 50 4% | 50 5% | 50 5% | 50 5% | 50 4% | 50 4% | 50 5% | 51 5% | 50 5% | 50 4% | 50 4% | 51 4% | 51 5% | 51 5% | 50 5% | 51 5% | | 58 | 53 4% | 52 4% | 52 5% | 54 5% | 52 4% | 52 5% | 52 5% | 52 5% | 52 4% | 52 4% | 52 5% | 53 5% | 52 5% | 52 4% | 52 4% | 53 4% | 53 5% | 53 5% | 52 5% | 53 5% | | 60 | 55 4% | 54 4% | 54 5% | 56 5% | 54 4% | 54 5% | 54 5% | 54 5% | 54 4% | 54 4% | 54 5% | 55 5% | 54 5% | 54 4% | 54 4% | 55 4% | 55 5% | 55 5% | 54 5% | 55 5% | | 62 | 57 4% | 56 4% | 56 5% | 58 5% | 56 4% | 56 5% | 56 5% | 56 5% | 56 4% | 56 4% | 56 5% | 57 5% | 56 5% | 56 4% | 56 5% | 57 4% | 57 5% | 57 5% | 56 5% | 57 5% | | 64 | 59 4% | 58 4% | 58 5% | 60 5% | 58 4% | 58 5% | 58 4% | 58 5% | 58 4% | 58 4% | 58 5% | 59 4% | 58 5% | 58 4% | 58 5% | 59 4% | 59 5% | 59 5% | 58 5% | 59 5% | | 66 | 61 4% | 60 4% | 60 5% | 62 5% | 60 4% | 60 5% | 60 4% | 60 5% | 60 4% | 60 4% | 60 5% | 61 4% | 60 5% | 60 4% | 60 5% | 61 4% | 61 5% | 61 5% | 60 5% | 61 5% | | 68 | 63 4% | 62 4% | 62 5% | 64 5% | 62 4% | 62 5% | 62 4% | 62 5% | 62 4% | 62 4% | 62 5% | 63 4% | 62 5% | 62 4% | 62 5% | 63 4% | 63 5% | 63 5% | 62 5% | 63 5% | | 70 | 65 4% | 64 4% | 64 5% | 66 5% | 64 4% | 64 5% | 64 4% | 64 5% | 64 5% | 64 4% | 64 5% | 65 4% | 64 5% | 64 4% | 64 5% | 65 4% | 65 5% | 65 5% | 64 5% | 65 5% | | 72 | 67 4% | 66 4% | 66 5% | 68 5% | 66 4% | 66 5% | 66 4% | 66 5% | 66 5% | 66 4% | 66 5% | 67 4% | 66 5% | 66 4% | 66 5% | 67 4% | 67 5% | 67 5% | 66 5% | 67 5% | | 74 | 69 4% | 68 4% | 68 5% | 70 5% | 68 4% | 68 5% | 68 4% | 68 5% | 68 5% | 68 4% | 68 5% | 69 4% | 68 5% | 68 4% | 68 5% | 69 4% | 69 5% | 69 5% | 68 5% | 69 5% | | 76 | 71 4% | 70 4% | 70 5% | 72 5% | 70 4% | 70 5% | 70 4% | 70 4% | 70 5% | 70 4% | 70 5% | 71 4% | 70 5% | 70 4% | 70 5% | 71 4% | 71 5% | 71 5% | 70 5% | 71 5% | | 78 | 73 4% | 72 4% | 72 5% | 74 5% | 72 4% | 72 5% | 72 4% | 72 4% | 72 5% | 72 4% | 72 5% | 73 4% | 72 5% | 72 4% | 72 5% | 73 4% | 73 5% | 73 5% | 72 5% | 73 5% | | 80 | 75 4% | 74 4% | 74 5% | 76 5% | 74 4% | 74 5% | 74 4% | 74 5% | 74 5% | 74 4% | 74 5% | 75 4% | 74 5% | 74 4% | 74 5% | 75 4% | 75 5% | 75 5% | 74 5% | 75 5% | | 82 | 77 4% | 76 4% | 76 5% | 78 5% | 76 4% | 76 5% | 76 4% | 76 5% | 76 5% | 76 4% | 76 5% | 77 4% | 76 5% | 76 4% | 76 5% | 77 4% | 77 5% | 77 5% | 76 5% | 77 5% | | 84 | 79 4% | 78 4% | 78 5% | 80 5% | 78 4% | 78 5% | 78 4% | 78 4% | 78 5% | 78 4% | 78 5% | 79 4% | 78 5% | 78 4% | 78 5% | 79 4% | 79 5% | 79 5% | 78 5% | 79 5% | | 86 | 81 4% | 80 4% | 80 5% | 82 5% | 80 4% | 80 5% | 80 4% | 80 4% | 80 4% | 80 4% | 80 5% | 81 4% | 80 5% | 80 4% | 80 5% | 81 4% | 81 5% | 81 5% | 80 5% | 81 5% | | 88 | 83 4% | 82 4% | 82 5% | 84 5% | 82 4% | 82 5% | 82 4% | 82 5% | 82 4% | 82 4% | 82 5% | 83 4% | 82 5% | 82 4% | 82 5% | 83 4% | 83 5% | 83 5% | 82 5% | 83 5% | | 90 | 85 4% | 84 4% | 84 5% | 86 5% | 84 4% | 84 5% | 84 4% | 84 4% | 84 4% | 84 4% | 84 5% | 85 4% | 84 5% | 84 4% | 84 4% | 85 4% | 85 5% | 85 5% | 84 5% | 85 5% | | 92 | 87 4% | 86 4% | 86 5% | 88 5% | 86 4% | 86 5% | 86 4% | 86 4% | 86 4% | 86 4% | 86 5% | 87 4% | 86 5% | 86 4% | 86 4% | 87 4% | 87 5% | 87 5% | 86 5% | 87 5% | | 94 | 89 4% | 88 4% | 88 5% | 90 5% | 88 4% | 88 5% | 88 4% | 88 5% | 88 4% | 88 4% | 88 5% | 89 4% | 88 5% | 88 4% | 88 4% | 89 4% | 89 5% | 89 5% | 88 5% | 89 5% | | 96 | 91 4% | 90 4% | 90 5% | 92 5% | 90 4% | 90 5% | 90 4% | 90 5% | 90 4% | 90 4% | 90 5% | 91 4% | 90 5% | 90 4% | 90 4% | 91 4% | 91 5% | 91 5% | 90 5% | 91 5% | | 98 | 93 4% | 92 4% | 92 5% | 94 5% | 92 4% | 92 5% | 92 4% | 92 4% | 92 4% | 92 4% | 92 5% | 93 4% | 92 5% | 92 4% | 92 4% | 93 4% | 93 5% | 93 5% | 92 5% | 93 5% | +-----+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+ Total bytes=969243192, ranges=1868
Index ¶
- Constants
- Variables
- func ComputeStatsForRange(d *roachpb.RangeDescriptor, e engine.Reader, nowNanos int64) (enginepb.MVCCStats, error)
- func DecodeRaftCommand(data []byte) (storagebase.CmdIDKey, []byte)
- func IsPreemptiveSnapshotError(err error) bool
- func IterateRangeDescriptors(ctx context.Context, eng engine.Reader, ...) error
- func NewReplicaCorruptionError(err error) *roachpb.ReplicaCorruptionError
- func RaftElectionTimeout(raftTickInterval time.Duration, raftElectionTimeoutTicks int) time.Duration
- func RangeLeaseDurations(raftElectionTimeout time.Duration) (rangeLeaseActive time.Duration, rangeLeaseRenewal time.Duration)
- func ReadStoreIdent(ctx context.Context, eng engine.Engine) (roachpb.StoreIdent, error)
- func RegisterConsistencyServer(s *grpc.Server, srv ConsistencyServer)
- func RegisterFreezeServer(s *grpc.Server, srv FreezeServer)
- func RegisterMultiRaftServer(s *grpc.Server, srv MultiRaftServer)
- func TrackRaftProtos() func() []reflect.Type
- type AbortCache
- func (sc *AbortCache) ClearData(e engine.Engine) error
- func (sc *AbortCache) CopyFrom(ctx context.Context, e engine.ReadWriter, ms *enginepb.MVCCStats, ...) (int, error)
- func (sc *AbortCache) CopyInto(e engine.ReadWriter, ms *enginepb.MVCCStats, destRangeID roachpb.RangeID) (int, error)
- func (sc *AbortCache) Del(ctx context.Context, e engine.ReadWriter, ms *enginepb.MVCCStats, ...) error
- func (sc *AbortCache) Get(ctx context.Context, e engine.Reader, txnID uuid.UUID, ...) (bool, error)
- func (sc *AbortCache) Iterate(ctx context.Context, e engine.Reader, f func([]byte, roachpb.AbortCacheEntry))
- func (sc *AbortCache) Put(ctx context.Context, e engine.ReadWriter, ms *enginepb.MVCCStats, ...) error
- type Allocator
- func (a *Allocator) AllocateTarget(constraints config.Constraints, existing []roachpb.ReplicaDescriptor, ...) (*roachpb.StoreDescriptor, error)
- func (a *Allocator) ComputeAction(zone config.ZoneConfig, desc *roachpb.RangeDescriptor) (AllocatorAction, float64)
- func (a Allocator) RebalanceTarget(constraints config.Constraints, existing []roachpb.ReplicaDescriptor, ...) (*roachpb.StoreDescriptor, error)
- func (a Allocator) RemoveTarget(constraints config.Constraints, existing []roachpb.ReplicaDescriptor, ...) (roachpb.ReplicaDescriptor, error)
- func (a *Allocator) ShouldTransferLease(constraints config.Constraints, leaseStoreID roachpb.StoreID, ...) bool
- func (a *Allocator) TransferLeaseTarget(constraints config.Constraints, existing []roachpb.ReplicaDescriptor, ...) roachpb.ReplicaDescriptor
- type AllocatorAction
- type AllocatorOptions
- type CollectChecksumRequest
- func (*CollectChecksumRequest) Descriptor() ([]byte, []int)
- func (m *CollectChecksumRequest) Marshal() (dAtA []byte, err error)
- func (m *CollectChecksumRequest) MarshalTo(dAtA []byte) (int, error)
- func (*CollectChecksumRequest) ProtoMessage()
- func (m *CollectChecksumRequest) Reset()
- func (m *CollectChecksumRequest) Size() (n int)
- func (m *CollectChecksumRequest) String() string
- func (m *CollectChecksumRequest) Unmarshal(dAtA []byte) error
- type CollectChecksumResponse
- func (*CollectChecksumResponse) Descriptor() ([]byte, []int)
- func (m *CollectChecksumResponse) Marshal() (dAtA []byte, err error)
- func (m *CollectChecksumResponse) MarshalTo(dAtA []byte) (int, error)
- func (*CollectChecksumResponse) ProtoMessage()
- func (m *CollectChecksumResponse) Reset()
- func (m *CollectChecksumResponse) Size() (n int)
- func (m *CollectChecksumResponse) String() string
- func (m *CollectChecksumResponse) Unmarshal(dAtA []byte) error
- type CommandQueue
- type ConfChangeContext
- func (*ConfChangeContext) Descriptor() ([]byte, []int)
- func (m *ConfChangeContext) Marshal() (dAtA []byte, err error)
- func (m *ConfChangeContext) MarshalTo(dAtA []byte) (int, error)
- func (*ConfChangeContext) ProtoMessage()
- func (m *ConfChangeContext) Reset()
- func (m *ConfChangeContext) Size() (n int)
- func (m *ConfChangeContext) String() string
- func (m *ConfChangeContext) Unmarshal(dAtA []byte) error
- type ConsistencyClient
- type ConsistencyServer
- type FreezeClient
- type FreezeServer
- type GCInfo
- type IncomingSnapshot
- type KeyRange
- type Liveness
- func (*Liveness) Descriptor() ([]byte, []int)
- func (m *Liveness) Marshal() (dAtA []byte, err error)
- func (m *Liveness) MarshalTo(dAtA []byte) (int, error)
- func (*Liveness) ProtoMessage()
- func (m *Liveness) Reset()
- func (m *Liveness) Size() (n int)
- func (m *Liveness) String() string
- func (m *Liveness) Unmarshal(dAtA []byte) error
- type LivenessMetrics
- type LocalProposalData
- type MultiRaftClient
- type MultiRaftServer
- type MultiRaft_RaftMessageBatchClient
- type MultiRaft_RaftMessageBatchServer
- type MultiRaft_RaftSnapshotClient
- type MultiRaft_RaftSnapshotServer
- type NodeAddressResolver
- type NodeLiveness
- func (nl *NodeLiveness) GetLiveness(nodeID roachpb.NodeID) (Liveness, error)
- func (nl *NodeLiveness) IncrementEpoch(ctx context.Context, nodeID roachpb.NodeID) error
- func (nl *NodeLiveness) IsLive(nodeID roachpb.NodeID) (bool, error)
- func (nl *NodeLiveness) ManualHeartbeat() error
- func (nl *NodeLiveness) Metrics() LivenessMetrics
- func (nl *NodeLiveness) Self() (Liveness, error)
- func (nl *NodeLiveness) StartHeartbeat(ctx context.Context, stopper *stop.Stopper)
- type NotBootstrappedError
- type OutgoingSnapshot
- type OutgoingSnapshotStream
- type PollFrozenRequest
- func (*PollFrozenRequest) Descriptor() ([]byte, []int)
- func (m *PollFrozenRequest) Marshal() (dAtA []byte, err error)
- func (m *PollFrozenRequest) MarshalTo(dAtA []byte) (int, error)
- func (*PollFrozenRequest) ProtoMessage()
- func (m *PollFrozenRequest) Reset()
- func (m *PollFrozenRequest) Size() (n int)
- func (m *PollFrozenRequest) String() string
- func (m *PollFrozenRequest) Unmarshal(dAtA []byte) error
- type PollFrozenResponse
- func (*PollFrozenResponse) Descriptor() ([]byte, []int)
- func (m *PollFrozenResponse) Marshal() (dAtA []byte, err error)
- func (m *PollFrozenResponse) MarshalTo(dAtA []byte) (int, error)
- func (*PollFrozenResponse) ProtoMessage()
- func (m *PollFrozenResponse) Reset()
- func (m *PollFrozenResponse) Size() (n int)
- func (m *PollFrozenResponse) String() string
- func (m *PollFrozenResponse) Unmarshal(dAtA []byte) error
- type ProposalData
- type RaftHeartbeat
- func (*RaftHeartbeat) Descriptor() ([]byte, []int)
- func (m *RaftHeartbeat) Marshal() (dAtA []byte, err error)
- func (m *RaftHeartbeat) MarshalTo(dAtA []byte) (int, error)
- func (*RaftHeartbeat) ProtoMessage()
- func (m *RaftHeartbeat) Reset()
- func (m *RaftHeartbeat) Size() (n int)
- func (m *RaftHeartbeat) String() string
- func (m *RaftHeartbeat) Unmarshal(dAtA []byte) error
- type RaftMessageHandler
- type RaftMessageRequest
- func (*RaftMessageRequest) Descriptor() ([]byte, []int)
- func (*RaftMessageRequest) GetUser() string
- func (m *RaftMessageRequest) Marshal() (dAtA []byte, err error)
- func (m *RaftMessageRequest) MarshalTo(dAtA []byte) (int, error)
- func (*RaftMessageRequest) ProtoMessage()
- func (m *RaftMessageRequest) Reset()
- func (m *RaftMessageRequest) Size() (n int)
- func (m *RaftMessageRequest) String() string
- func (m *RaftMessageRequest) Unmarshal(dAtA []byte) error
- type RaftMessageRequestBatch
- func (*RaftMessageRequestBatch) Descriptor() ([]byte, []int)
- func (m *RaftMessageRequestBatch) Marshal() (dAtA []byte, err error)
- func (m *RaftMessageRequestBatch) MarshalTo(dAtA []byte) (int, error)
- func (*RaftMessageRequestBatch) ProtoMessage()
- func (m *RaftMessageRequestBatch) Reset()
- func (m *RaftMessageRequestBatch) Size() (n int)
- func (m *RaftMessageRequestBatch) String() string
- func (m *RaftMessageRequestBatch) Unmarshal(dAtA []byte) error
- type RaftMessageResponse
- func (*RaftMessageResponse) Descriptor() ([]byte, []int)
- func (m *RaftMessageResponse) Marshal() (dAtA []byte, err error)
- func (m *RaftMessageResponse) MarshalTo(dAtA []byte) (int, error)
- func (*RaftMessageResponse) ProtoMessage()
- func (m *RaftMessageResponse) Reset()
- func (m *RaftMessageResponse) Size() (n int)
- func (m *RaftMessageResponse) String() string
- func (m *RaftMessageResponse) Unmarshal(dAtA []byte) error
- type RaftMessageResponseStream
- type RaftMessageResponseUnion
- func (*RaftMessageResponseUnion) Descriptor() ([]byte, []int)
- func (this *RaftMessageResponseUnion) GetValue() interface{}
- func (m *RaftMessageResponseUnion) Marshal() (dAtA []byte, err error)
- func (m *RaftMessageResponseUnion) MarshalTo(dAtA []byte) (int, error)
- func (*RaftMessageResponseUnion) ProtoMessage()
- func (m *RaftMessageResponseUnion) Reset()
- func (this *RaftMessageResponseUnion) SetValue(value interface{}) bool
- func (m *RaftMessageResponseUnion) Size() (n int)
- func (m *RaftMessageResponseUnion) String() string
- func (m *RaftMessageResponseUnion) Unmarshal(dAtA []byte) error
- type RaftTransport
- func (t *RaftTransport) GetCircuitBreaker(nodeID roachpb.NodeID) *circuit.Breaker
- func (t *RaftTransport) Listen(storeID roachpb.StoreID, handler RaftMessageHandler)
- func (t *RaftTransport) RaftMessageBatch(stream MultiRaft_RaftMessageBatchServer) error
- func (t *RaftTransport) RaftSnapshot(stream MultiRaft_RaftSnapshotServer) error
- func (t *RaftTransport) SendAsync(req *RaftMessageRequest) bool
- func (t *RaftTransport) SendSnapshot(ctx context.Context, storePool *StorePool, header SnapshotRequest_Header, ...) error
- func (t *RaftTransport) Stop(storeID roachpb.StoreID)
- type RangeEventLogType
- type Replica
- func (r *Replica) AdminMerge(ctx context.Context, args roachpb.AdminMergeRequest, ...) (roachpb.AdminMergeResponse, *roachpb.Error)
- func (r *Replica) AdminSplit(ctx context.Context, args roachpb.AdminSplitRequest, ...) (roachpb.AdminSplitResponse, *roachpb.Error)
- func (r *Replica) AdminTransferLease(target roachpb.StoreID) error
- func (r *Replica) BeginTransaction(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.BeginTransactionResponse, error)
- func (r *Replica) ChangeFrozen(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.ChangeFrozenResponse, ProposalData, error)
- func (r *Replica) ChangeReplicas(ctx context.Context, changeType roachpb.ReplicaChangeType, ...) error
- func (r *Replica) CheckConsistency(ctx context.Context, args roachpb.CheckConsistencyRequest, ...) (roachpb.CheckConsistencyResponse, *roachpb.Error)
- func (r *Replica) CloseOutSnap()
- func (r *Replica) ComputeChecksum(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.ComputeChecksumResponse, ProposalData, error)
- func (r *Replica) ConditionalPut(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.ConditionalPutResponse, error)
- func (r *Replica) ContainsKey(key roachpb.Key) bool
- func (r *Replica) ContainsKeyRange(start, end roachpb.Key) bool
- func (r *Replica) Delete(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.DeleteResponse, error)
- func (r *Replica) DeleteRange(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.DeleteRangeResponse, *roachpb.Span, int64, error)
- func (r *Replica) Desc() *roachpb.RangeDescriptor
- func (r *Replica) EndTransaction(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.EndTransactionResponse, ProposalData, error)
- func (r *Replica) Entries(lo, hi, maxBytes uint64) ([]raftpb.Entry, error)
- func (r *Replica) FirstIndex() (uint64, error)
- func (r *Replica) GC(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.GCResponse, ProposalData, error)
- func (r *Replica) Get(ctx context.Context, batch engine.ReadWriter, h roachpb.Header, ...) (roachpb.GetResponse, ProposalData, error)
- func (r *Replica) GetFirstIndex() (uint64, error)
- func (r *Replica) GetMVCCStats() enginepb.MVCCStats
- func (r *Replica) GetMaxBytes() int64
- func (r *Replica) GetReplicaDescriptor() (roachpb.ReplicaDescriptor, error)
- func (r *Replica) GetSnapshot(ctx context.Context) (*OutgoingSnapshot, error)
- func (r *Replica) HeartbeatTxn(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.HeartbeatTxnResponse, error)
- func (r *Replica) Increment(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.IncrementResponse, error)
- func (r *Replica) InitPut(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.InitPutResponse, error)
- func (r *Replica) InitialState() (raftpb.HardState, raftpb.ConfState, error)
- func (r *Replica) IsDestroyed() error
- func (r *Replica) IsFirstRange() bool
- func (r *Replica) IsInitialized() bool
- func (r *Replica) LastIndex() (uint64, error)
- func (r *Replica) LeaseInfo(ctx context.Context, args roachpb.LeaseInfoRequest) (roachpb.LeaseInfoResponse, error)
- func (r *Replica) Less(i btree.Item) bool
- func (r *Replica) Merge(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.MergeResponse, error)
- func (r *Replica) PushTxn(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.PushTxnResponse, error)
- func (r *Replica) Put(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.PutResponse, error)
- func (r *Replica) RaftStatus() *raft.Status
- func (r *Replica) RangeLookup(ctx context.Context, batch engine.ReadWriter, h roachpb.Header, ...) (roachpb.RangeLookupResponse, ProposalData, error)
- func (r *Replica) RequestLease(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.RequestLeaseResponse, ProposalData, error)
- func (r *Replica) ResolveIntent(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.ResolveIntentResponse, error)
- func (r *Replica) ResolveIntentRange(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.ResolveIntentRangeResponse, error)
- func (r *Replica) ReverseScan(ctx context.Context, batch engine.ReadWriter, h roachpb.Header, maxKeys int64, ...) (roachpb.ReverseScanResponse, *roachpb.Span, int64, ProposalData, error)
- func (r *Replica) Scan(ctx context.Context, batch engine.ReadWriter, h roachpb.Header, maxKeys int64, ...) (roachpb.ScanResponse, *roachpb.Span, int64, ProposalData, error)
- func (r *Replica) Send(ctx context.Context, ba roachpb.BatchRequest) (*roachpb.BatchResponse, *roachpb.Error)
- func (r *Replica) SetMaxBytes(maxBytes int64)
- func (r *Replica) Snapshot() (raftpb.Snapshot, error)
- func (r *Replica) SnapshotWithContext(ctx context.Context) (*OutgoingSnapshot, error)
- func (r *Replica) State() storagebase.RangeInfo
- func (r *Replica) String() string
- func (r *Replica) Term(i uint64) (uint64, error)
- func (r *Replica) TransferLease(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.RequestLeaseResponse, ProposalData, error)
- func (r *Replica) TruncateLog(ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, ...) (roachpb.TruncateLogResponse, ProposalData, error)
- type ReplicaDataIterator
- type ReplicaPlaceholder
- type ReplicaSnapshotDiff
- type ReplicaSnapshotDiffSlice
- type Server
- type SnapshotRequest
- func (*SnapshotRequest) Descriptor() ([]byte, []int)
- func (m *SnapshotRequest) Marshal() (dAtA []byte, err error)
- func (m *SnapshotRequest) MarshalTo(dAtA []byte) (int, error)
- func (*SnapshotRequest) ProtoMessage()
- func (m *SnapshotRequest) Reset()
- func (m *SnapshotRequest) Size() (n int)
- func (m *SnapshotRequest) String() string
- func (m *SnapshotRequest) Unmarshal(dAtA []byte) error
- type SnapshotRequest_Header
- func (*SnapshotRequest_Header) Descriptor() ([]byte, []int)
- func (m *SnapshotRequest_Header) Marshal() (dAtA []byte, err error)
- func (m *SnapshotRequest_Header) MarshalTo(dAtA []byte) (int, error)
- func (*SnapshotRequest_Header) ProtoMessage()
- func (m *SnapshotRequest_Header) Reset()
- func (m *SnapshotRequest_Header) Size() (n int)
- func (m *SnapshotRequest_Header) String() string
- func (m *SnapshotRequest_Header) Unmarshal(dAtA []byte) error
- type SnapshotResponse
- func (*SnapshotResponse) Descriptor() ([]byte, []int)
- func (m *SnapshotResponse) Marshal() (dAtA []byte, err error)
- func (m *SnapshotResponse) MarshalTo(dAtA []byte) (int, error)
- func (*SnapshotResponse) ProtoMessage()
- func (m *SnapshotResponse) Reset()
- func (m *SnapshotResponse) Size() (n int)
- func (m *SnapshotResponse) String() string
- func (m *SnapshotResponse) Unmarshal(dAtA []byte) error
- type SnapshotResponseStream
- type SnapshotResponse_Status
- type SnapshotStorePool
- type Store
- func (s *Store) AcquireRaftSnapshot() bool
- func (s *Store) AnnotateCtx(ctx context.Context) context.Context
- func (s *Store) AnnotateCtxWithSpan(ctx context.Context, opName string) (context.Context, opentracing.Span)
- func (s *Store) Attrs() roachpb.Attributes
- func (s *Store) Bootstrap(ident roachpb.StoreIdent) error
- func (s *Store) BootstrapRange(initialValues []roachpb.KeyValue) error
- func (s *Store) Capacity() (roachpb.StoreCapacity, error)
- func (s *Store) Clock() *hlc.Clock
- func (s *Store) ClusterID() uuid.UUID
- func (s *Store) ComputeMetrics(tick int) error
- func (s *Store) ComputeStatsForKeySpan(startKey, endKey roachpb.RKey) (enginepb.MVCCStats, int)
- func (s *Store) DB() *client.DB
- func (s *Store) Descriptor() (*roachpb.StoreDescriptor, error)
- func (s *Store) DrainLeases(drain bool) error
- func (s *Store) Engine() engine.Engine
- func (s *Store) FrozenStatus(collectFrozen bool) (repDescs []roachpb.ReplicaDescriptor)
- func (s *Store) GetReplica(rangeID roachpb.RangeID) (*Replica, error)
- func (s *Store) Gossip() *gossip.Gossip
- func (s *Store) GossipDeadReplicas(ctx context.Context) error
- func (s *Store) GossipStore(ctx context.Context) error
- func (s *Store) HandleRaftRequest(ctx context.Context, req *RaftMessageRequest, ...) *roachpb.Error
- func (s *Store) HandleRaftResponse(ctx context.Context, resp *RaftMessageResponse) error
- func (s *Store) HandleRaftUncoalescedRequest(ctx context.Context, req *RaftMessageRequest, ...) *roachpb.Error
- func (s *Store) HandleSnapshot(header *SnapshotRequest_Header, stream SnapshotResponseStream) error
- func (s *Store) IsDrainingLeases() bool
- func (s *Store) IsStarted() bool
- func (s *Store) LeaseCount() int
- func (s *Store) LookupReplica(start, end roachpb.RKey) *Replica
- func (s *Store) MVCCStats() enginepb.MVCCStats
- func (s *Store) MergeRange(ctx context.Context, subsumingRng *Replica, updatedEndKey roachpb.RKey, ...) error
- func (s *Store) Metrics() *StoreMetrics
- func (s *Store) NewRangeDescriptor(start, end roachpb.RKey, replicas []roachpb.ReplicaDescriptor) (*roachpb.RangeDescriptor, error)
- func (s *Store) NewSnapshot() engine.Reader
- func (s *Store) NotifyBootstrapped()
- func (s *Store) RaftStatus(rangeID roachpb.RangeID) *raft.Status
- func (s *Store) Registry() *metric.Registry
- func (s *Store) ReleaseRaftSnapshot()
- func (s *Store) RemoveReplica(rep *Replica, origDesc roachpb.RangeDescriptor, destroy bool) error
- func (s *Store) ReplicaCount() int
- func (s *Store) Send(ctx context.Context, ba roachpb.BatchRequest) (br *roachpb.BatchResponse, pErr *roachpb.Error)
- func (s *Store) SplitRange(origRng, newRng *Replica) error
- func (s *Store) Start(ctx context.Context, stopper *stop.Stopper) error
- func (s *Store) Stopper() *stop.Stopper
- func (s *Store) StoreID() roachpb.StoreID
- func (s *Store) String() string
- func (s *Store) TestingKnobs() *StoreTestingKnobs
- func (s *Store) Tracer() opentracing.Tracer
- func (s *Store) WaitForInit()
- type StoreConfig
- type StoreList
- type StoreMetrics
- type StorePool
- type StoreRequestHeader
- func (*StoreRequestHeader) Descriptor() ([]byte, []int)
- func (m *StoreRequestHeader) Marshal() (dAtA []byte, err error)
- func (m *StoreRequestHeader) MarshalTo(dAtA []byte) (int, error)
- func (*StoreRequestHeader) ProtoMessage()
- func (m *StoreRequestHeader) Reset()
- func (m *StoreRequestHeader) Size() (n int)
- func (m *StoreRequestHeader) String() string
- func (m *StoreRequestHeader) Unmarshal(dAtA []byte) error
- type StoreTestingKnobs
- type Stores
- func (ls *Stores) AddStore(s *Store)
- func (ls *Stores) FirstRange() (*roachpb.RangeDescriptor, error)
- func (ls *Stores) GetStore(storeID roachpb.StoreID) (*Store, error)
- func (ls *Stores) GetStoreCount() int
- func (ls *Stores) HasStore(storeID roachpb.StoreID) bool
- func (ls *Stores) LookupReplica(start, end roachpb.RKey) (roachpb.RangeID, roachpb.ReplicaDescriptor, error)
- func (ls *Stores) ReadBootstrapInfo(bi *gossip.BootstrapInfo) error
- func (ls *Stores) RemoveStore(s *Store)
- func (ls *Stores) Send(ctx context.Context, ba roachpb.BatchRequest) (*roachpb.BatchResponse, *roachpb.Error)
- func (ls *Stores) VisitStores(visitor func(s *Store) error) error
- func (ls *Stores) WriteBootstrapInfo(bi *gossip.BootstrapInfo) error
- type TimeSeriesDataStore
Examples ¶
Constants ¶
const ( // RaftLogQueueTimerDuration is the duration between truncations. This needs // to be relatively short so that truncations can keep up with raft log entry // creation. RaftLogQueueTimerDuration = 50 * time.Millisecond // RaftLogQueueStaleThreshold is the minimum threshold for stale raft log // entries. A stale entry is one which all replicas of the range have // progressed past and thus is no longer needed and can be truncated. RaftLogQueueStaleThreshold = 100 )
const ( // ReplicaGCQueueInactivityThreshold is the inactivity duration after which // a range will be considered for garbage collection. Exported for testing. ReplicaGCQueueInactivityThreshold = 10 * 24 * time.Hour // 10 days // ReplicaGCQueueCandidateTimeout is the duration after which a range in // candidate Raft state (which is a typical sign of having been removed // from the group) will be considered for garbage collection. ReplicaGCQueueCandidateTimeout = 1 * time.Second )
const ( // TestTimeUntilStoreDead is the test value for TimeUntilStoreDead to // quickly mark stores as dead. TestTimeUntilStoreDead = 5 * time.Millisecond // TestTimeUntilStoreDeadOff is the test value for TimeUntilStoreDead that // prevents the store pool from marking stores as dead. TestTimeUntilStoreDeadOff = 24 * time.Hour )
const ErrMsgConflictUpdatingRangeDesc = "conflict updating range descriptors"
ErrMsgConflictUpdatingRangeDesc is an error message that is returned by AdminSplit when it conflicts with some other process that updates range descriptors.
const ( // MinTSCacheWindow specifies the minimum duration to hold entries in // the cache before allowing eviction. After this window expires, // transactions writing to this node with timestamps lagging by more // than minCacheWindow will necessarily have to advance their commit // timestamp. MinTSCacheWindow = 10 * time.Second )
Variables ¶
var ( ErrInvalidLengthApi = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowApi = fmt.Errorf("proto: integer overflow") )
var ( ErrInvalidLengthLiveness = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowLiveness = fmt.Errorf("proto: integer overflow") )
var ( ErrInvalidLengthRaft = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowRaft = fmt.Errorf("proto: integer overflow") )
var EnableLeaseRebalancing = envutil.EnvOrDefaultBool("COCKROACH_ENABLE_LEASE_REBALANCING", false)
EnableLeaseRebalancing controls whether lease rebalancing is enabled or not. Exported for testing.
var ErrNoLivenessRecord = errors.New("node not in the liveness table")
ErrNoLivenessRecord is returned when asking for liveness information about a node for which nothing is known.
var SnapshotResponse_Status_name = map[int32]string{
0: "UNKNOWN",
1: "ACCEPTED",
2: "APPLIED",
3: "ERROR",
4: "DECLINED",
}
var SnapshotResponse_Status_value = map[string]int32{
"UNKNOWN": 0,
"ACCEPTED": 1,
"APPLIED": 2,
"ERROR": 3,
"DECLINED": 4,
}
Functions ¶
func ComputeStatsForRange ¶
func ComputeStatsForRange( d *roachpb.RangeDescriptor, e engine.Reader, nowNanos int64, ) (enginepb.MVCCStats, error)
ComputeStatsForRange computes the stats for a given range by iterating over all key ranges for the given range that should be accounted for in its stats.
func DecodeRaftCommand ¶
func DecodeRaftCommand(data []byte) (storagebase.CmdIDKey, []byte)
DecodeRaftCommand splits a raftpb.Entry.Data into its commandID and command portions. The caller is responsible for checking that the data is not empty (which indicates a dummy entry generated by raft rather than a real command). Usage is mostly internal to the storage package but is exported for use by debugging tools.
func IsPreemptiveSnapshotError ¶
IsPreemptiveSnapshotError returns true iff the error indicates a preemptive snapshot failed.
func IterateRangeDescriptors ¶
func IterateRangeDescriptors( ctx context.Context, eng engine.Reader, fn func(desc roachpb.RangeDescriptor) (bool, error), ) error
IterateRangeDescriptors calls the provided function with each descriptor from the provided Engine. The return values of this method and fn have semantics similar to engine.MVCCIterate.
func NewReplicaCorruptionError ¶
func NewReplicaCorruptionError(err error) *roachpb.ReplicaCorruptionError
NewReplicaCorruptionError creates a new error indicating a corrupt replica, with the supplied list of errors given as history.
func RaftElectionTimeout ¶
func RaftElectionTimeout( raftTickInterval time.Duration, raftElectionTimeoutTicks int, ) time.Duration
RaftElectionTimeout returns the raft election timeout, as computed from the specified tick interval and number of election timeout ticks. If raftElectionTimeoutTicks is 0, uses the value of defaultRaftElectionTimeoutTicks.
func RangeLeaseDurations ¶
func RangeLeaseDurations( raftElectionTimeout time.Duration, ) (rangeLeaseActive time.Duration, rangeLeaseRenewal time.Duration)
RangeLeaseDurations computes durations for range lease expiration and renewal based on a default multiple of Raft election timeout.
func ReadStoreIdent ¶
ReadStoreIdent reads the StoreIdent from the store. It returns *NotBootstrappedError if the ident is missing (meaning that the store needs to be bootstrapped).
func RegisterConsistencyServer ¶
func RegisterConsistencyServer(s *grpc.Server, srv ConsistencyServer)
func RegisterFreezeServer ¶
func RegisterFreezeServer(s *grpc.Server, srv FreezeServer)
func RegisterMultiRaftServer ¶
func RegisterMultiRaftServer(s *grpc.Server, srv MultiRaftServer)
func TrackRaftProtos ¶
TrackRaftProtos instruments proto marshalling to track protos which are marshalled downstream of raft. It returns a function that removes the instrumentation and returns the list of downstream-of-raft protos.
Types ¶
type AbortCache ¶
type AbortCache struct {
// contains filtered or unexported fields
}
The AbortCache sets markers for aborted transactions to provide protection against an aborted but active transaction not reading values it wrote (due to its intents having been removed).
The AbortCache stores responses in the underlying engine, using keys derived from Range ID and txn ID.
A AbortCache is not thread safe. Access to it is serialized through Raft.
TODO(tschottdorf): we seem to have made a half-hearted attempt at naming this the "AbortSpan" instead, but large parts of the code still call this "AbortCache". We should settle for one and rename everything post-yellow.
func NewAbortCache ¶
func NewAbortCache(rangeID roachpb.RangeID) *AbortCache
NewAbortCache returns a new abort cache. Every range replica maintains an abort cache, not just the lease holder.
func (*AbortCache) ClearData ¶
func (sc *AbortCache) ClearData(e engine.Engine) error
ClearData removes all persisted items stored in the cache.
func (*AbortCache) CopyFrom ¶
func (sc *AbortCache) CopyFrom( ctx context.Context, e engine.ReadWriter, ms *enginepb.MVCCStats, originRangeID roachpb.RangeID, ) (int, error)
CopyFrom copies all the persisted results from the originRangeID abort cache into this one. Note that the cache will not be locked while copying is in progress. Failures decoding individual entries return an error. The copy is done directly using the engine instead of interpreting values through MVCC for efficiency. On success, returns the number of entries (key-value pairs) copied.
func (*AbortCache) CopyInto ¶
func (sc *AbortCache) CopyInto( e engine.ReadWriter, ms *enginepb.MVCCStats, destRangeID roachpb.RangeID, ) (int, error)
CopyInto copies all the results from this abort cache into the destRangeID abort cache. Failures decoding individual cache entries return an error. On success, returns the number of entries (key-value pairs) copied.
func (*AbortCache) Del ¶
func (sc *AbortCache) Del( ctx context.Context, e engine.ReadWriter, ms *enginepb.MVCCStats, txnID uuid.UUID, ) error
Del removes all abort cache entries for the given transaction.
func (*AbortCache) Get ¶
func (sc *AbortCache) Get( ctx context.Context, e engine.Reader, txnID uuid.UUID, entry *roachpb.AbortCacheEntry, ) (bool, error)
Get looks up an abort cache entry recorded for this transaction ID. Returns whether an abort record was found and any error.
func (*AbortCache) Iterate ¶
func (sc *AbortCache) Iterate( ctx context.Context, e engine.Reader, f func([]byte, roachpb.AbortCacheEntry), )
Iterate walks through the abort cache, invoking the given callback for each unmarshaled entry with the key, the transaction ID and the decoded entry. TODO(tschottdorf): should not use a pointer to UUID.
func (*AbortCache) Put ¶
func (sc *AbortCache) Put( ctx context.Context, e engine.ReadWriter, ms *enginepb.MVCCStats, txnID uuid.UUID, entry *roachpb.AbortCacheEntry, ) error
Put writes an entry for the specified transaction ID.
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
Allocator tries to spread replicas as evenly as possible across the stores in the cluster.
func MakeAllocator ¶
func MakeAllocator(storePool *StorePool, options AllocatorOptions) Allocator
MakeAllocator creates a new allocator using the specified StorePool.
func (*Allocator) AllocateTarget ¶
func (a *Allocator) AllocateTarget( constraints config.Constraints, existing []roachpb.ReplicaDescriptor, rangeID roachpb.RangeID, relaxConstraints bool, ) (*roachpb.StoreDescriptor, error)
AllocateTarget returns a suitable store for a new allocation with the required attributes. Nodes already accommodating existing replicas are ruled out as targets. The range ID of the replica being allocated for is also passed in to ensure that we don't try to replace an existing dead replica on a store. If relaxConstraints is true, then the required attributes will be relaxed as necessary, from least specific to most specific, in order to allocate a target.
func (*Allocator) ComputeAction ¶
func (a *Allocator) ComputeAction( zone config.ZoneConfig, desc *roachpb.RangeDescriptor, ) (AllocatorAction, float64)
ComputeAction determines the exact operation needed to repair the supplied range, as governed by the supplied zone configuration. It returns the required action that should be taken and a replica on which the action should be performed.
func (Allocator) RebalanceTarget ¶
func (a Allocator) RebalanceTarget( constraints config.Constraints, existing []roachpb.ReplicaDescriptor, leaseStoreID roachpb.StoreID, rangeID roachpb.RangeID, ) (*roachpb.StoreDescriptor, error)
RebalanceTarget returns a suitable store for a rebalance target with required attributes. Rebalance targets are selected via the same mechanism as AllocateTarget(), except the chosen target must follow some additional criteria. Namely, if chosen, it must further the goal of balancing the cluster.
The supplied parameters are the required attributes for the range, a list of the existing replicas of the range, the store ID of the lease-holder replica and the range ID of the replica being allocated.
The existing replicas modulo the lease-holder replica and any store with dead replicas are candidates for rebalancing. Note that rebalancing is accomplished by first adding a new replica to the range, then removing the most undesirable replica.
Simply ignoring a rebalance opportunity in the event that the target chosen by AllocateTarget() doesn't fit balancing criteria is perfectly fine, as other stores in the cluster will also be doing their probabilistic best to rebalance. This helps prevent a stampeding herd targeting an abnormally under-utilized store.
func (Allocator) RemoveTarget ¶
func (a Allocator) RemoveTarget( constraints config.Constraints, existing []roachpb.ReplicaDescriptor, leaseStoreID roachpb.StoreID, ) (roachpb.ReplicaDescriptor, error)
RemoveTarget returns a suitable replica to remove from the provided replica set. It first attempts to randomly select a target from the set of stores that have greater than the average number of replicas. Failing that, it falls back to selecting a random target from any of the existing replicas. It also will exclude any replica that lives on leaseStoreID.
TODO(mrtracy): removeTarget eventually needs to accept the attributes from the zone config associated with the provided replicas. This will allow it to make correct decisions in the case of ranges with heterogeneous replica requirements (i.e. multiple data centers).
func (*Allocator) ShouldTransferLease ¶
func (a *Allocator) ShouldTransferLease( constraints config.Constraints, leaseStoreID roachpb.StoreID, rangeID roachpb.RangeID, ) bool
ShouldTransferLease returns true if the specified store is overfull in terms of leases with respect to the other stores matching the specified attributes.
func (*Allocator) TransferLeaseTarget ¶
func (a *Allocator) TransferLeaseTarget( constraints config.Constraints, existing []roachpb.ReplicaDescriptor, leaseStoreID roachpb.StoreID, rangeID roachpb.RangeID, checkTransferLeaseSource bool, ) roachpb.ReplicaDescriptor
TransferLeaseTarget returns a suitable replica to transfer the range lease to from the provided list. It excludes the current lease holder replica.
type AllocatorAction ¶
type AllocatorAction int
AllocatorAction enumerates the various replication adjustments that may be recommended by the allocator.
const ( AllocatorNoop AllocatorAction AllocatorRemove AllocatorAdd AllocatorRemoveDead )
These are the possible allocator actions.
func (AllocatorAction) String ¶
func (a AllocatorAction) String() string
type AllocatorOptions ¶
type AllocatorOptions struct { // AllowRebalance allows this store to attempt to rebalance its own // replicas to other stores. AllowRebalance bool // UseRuleSolver enables this store to use the updated rules based // constraint solver instead of the original rebalancer. UseRuleSolver bool }
AllocatorOptions are configurable options which effect the way that the replicate queue will handle rebalancing opportunities.
type CollectChecksumRequest ¶
type CollectChecksumRequest struct { StoreRequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` RangeID github_com_cockroachdb_cockroach_pkg_roachpb.RangeID `` /* 145-byte string literal not displayed */ // checksum_id identifies the corresponding roachpb.ComputeChecksumRequest. ChecksumID github_com_cockroachdb_cockroach_pkg_util_uuid.UUID `` /* 144-byte string literal not displayed */ Checksum []byte `protobuf:"bytes,4,opt,name=checksum,proto3" json:"checksum,omitempty"` }
A CollectChecksumRequest asks the addressed replica for the result of a roachpb.ComputeChecksumRequest.
func (*CollectChecksumRequest) Descriptor ¶
func (*CollectChecksumRequest) Descriptor() ([]byte, []int)
func (*CollectChecksumRequest) Marshal ¶
func (m *CollectChecksumRequest) Marshal() (dAtA []byte, err error)
func (*CollectChecksumRequest) MarshalTo ¶
func (m *CollectChecksumRequest) MarshalTo(dAtA []byte) (int, error)
func (*CollectChecksumRequest) ProtoMessage ¶
func (*CollectChecksumRequest) ProtoMessage()
func (*CollectChecksumRequest) Reset ¶
func (m *CollectChecksumRequest) Reset()
func (*CollectChecksumRequest) Size ¶
func (m *CollectChecksumRequest) Size() (n int)
func (*CollectChecksumRequest) String ¶
func (m *CollectChecksumRequest) String() string
func (*CollectChecksumRequest) Unmarshal ¶
func (m *CollectChecksumRequest) Unmarshal(dAtA []byte) error
type CollectChecksumResponse ¶
type CollectChecksumResponse struct { Checksum []byte `protobuf:"bytes,1,opt,name=checksum,proto3" json:"checksum,omitempty"` // snapshot is set if the roachpb.ComputeChecksumRequest had snapshot = true // and the response checksum is different from the request checksum. Snapshot *cockroach_roachpb1.RaftSnapshotData `protobuf:"bytes,2,opt,name=snapshot" json:"snapshot,omitempty"` }
func (*CollectChecksumResponse) Descriptor ¶
func (*CollectChecksumResponse) Descriptor() ([]byte, []int)
func (*CollectChecksumResponse) Marshal ¶
func (m *CollectChecksumResponse) Marshal() (dAtA []byte, err error)
func (*CollectChecksumResponse) MarshalTo ¶
func (m *CollectChecksumResponse) MarshalTo(dAtA []byte) (int, error)
func (*CollectChecksumResponse) ProtoMessage ¶
func (*CollectChecksumResponse) ProtoMessage()
func (*CollectChecksumResponse) Reset ¶
func (m *CollectChecksumResponse) Reset()
func (*CollectChecksumResponse) Size ¶
func (m *CollectChecksumResponse) Size() (n int)
func (*CollectChecksumResponse) String ¶
func (m *CollectChecksumResponse) String() string
func (*CollectChecksumResponse) Unmarshal ¶
func (m *CollectChecksumResponse) Unmarshal(dAtA []byte) error
type CommandQueue ¶
type CommandQueue struct {
// contains filtered or unexported fields
}
A CommandQueue maintains an interval tree of keys or key ranges for executing commands. New commands affecting keys or key ranges must wait on already-executing commands which overlap their key range.
Before executing, a command invokes GetWait() to acquire a slice of channels belonging to overlapping commands which are already running. Each channel is waited on by the caller for confirmation that all overlapping, pending commands have completed and the pending command can proceed.
After waiting, a command is added to the queue's already-executing set via add(). add accepts a parameter indicating whether the command is read-only. Read-only commands don't need to wait on other read-only commands, so the channels returned via GetWait() don't include read-only on read-only overlapping commands as an optimization.
Once commands complete, remove() is invoked to remove the executing command and close its channel, possibly signaling waiting commands who were gated by the executing command's affected key(s).
CommandQueue is not thread safe.
func NewCommandQueue ¶
func NewCommandQueue(coveringOptimization bool) *CommandQueue
NewCommandQueue returns a new command queue. The boolean specifies whether to enable the covering span optimization. With this optimization, whenever a command consisting of multiple spans is added, a covering span is computed and only that covering span inserted. The individual spans are inserted (i.e. the covering span expanded) only when required by a later overlapping command, the hope being that that occurs infrequently, and that in the common case savings are made due to the reduced number of spans active in the tree. As such, the optimization makes sense for workloads in which commands typically contain many spans, but are spatially disjoint.
func (*CommandQueue) String ¶
func (cq *CommandQueue) String() string
String dumps the contents of the command queue for testing.
type ConfChangeContext ¶
type ConfChangeContext struct { CommandID string `protobuf:"bytes,1,opt,name=command_id,json=commandId" json:"command_id"` // Payload is the application-level command (i.e. an encoded // storagebase.ReplicatedProposalData). Payload []byte `protobuf:"bytes,2,opt,name=payload" json:"payload,omitempty"` // Replica contains full details about the replica being added or removed. Replica cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,3,opt,name=replica" json:"replica"` }
ConfChangeContext is encoded in the raftpb.ConfChange.Context field.
func (*ConfChangeContext) Descriptor ¶
func (*ConfChangeContext) Descriptor() ([]byte, []int)
func (*ConfChangeContext) Marshal ¶
func (m *ConfChangeContext) Marshal() (dAtA []byte, err error)
func (*ConfChangeContext) MarshalTo ¶
func (m *ConfChangeContext) MarshalTo(dAtA []byte) (int, error)
func (*ConfChangeContext) ProtoMessage ¶
func (*ConfChangeContext) ProtoMessage()
func (*ConfChangeContext) Reset ¶
func (m *ConfChangeContext) Reset()
func (*ConfChangeContext) Size ¶
func (m *ConfChangeContext) Size() (n int)
func (*ConfChangeContext) String ¶
func (m *ConfChangeContext) String() string
func (*ConfChangeContext) Unmarshal ¶
func (m *ConfChangeContext) Unmarshal(dAtA []byte) error
type ConsistencyClient ¶
type ConsistencyClient interface {
CollectChecksum(ctx context.Context, in *CollectChecksumRequest, opts ...grpc.CallOption) (*CollectChecksumResponse, error)
}
func NewConsistencyClient ¶
func NewConsistencyClient(cc *grpc.ClientConn) ConsistencyClient
type ConsistencyServer ¶
type ConsistencyServer interface {
CollectChecksum(context.Context, *CollectChecksumRequest) (*CollectChecksumResponse, error)
}
type FreezeClient ¶
type FreezeClient interface {
PollFrozen(ctx context.Context, in *PollFrozenRequest, opts ...grpc.CallOption) (*PollFrozenResponse, error)
}
func NewFreezeClient ¶
func NewFreezeClient(cc *grpc.ClientConn) FreezeClient
type FreezeServer ¶
type FreezeServer interface {
PollFrozen(context.Context, *PollFrozenRequest) (*PollFrozenResponse, error)
}
type GCInfo ¶
type GCInfo struct { // Now is the timestamp used for age computations. Now hlc.Timestamp // Policy is the policy used for this garbage collection cycle. Policy config.GCPolicy // Stats about the userspace key-values considered, namely the number of // keys with GC'able data, the number of "old" intents and the number of // associated distinct transactions. NumKeysAffected, IntentsConsidered, IntentTxns int // TransactionSpanTotal is the total number of entries in the transaction span. TransactionSpanTotal int // Summary of transactions which were found GCable (assuming that // potentially necessary intent resolutions did not fail). TransactionSpanGCAborted, TransactionSpanGCCommitted, TransactionSpanGCPending int // TxnSpanGCThreshold is the cutoff for transaction span GC. Transactions // with a smaller LastActive() were considered for GC. TxnSpanGCThreshold hlc.Timestamp // AbortSpanTotal is the total number of transactions present in the abort cache. AbortSpanTotal int // AbortSpanConsidered is the number of abort cache entries old enough to be // considered for removal. An "entry" corresponds to one transaction; // more than one key-value pair may be associated with it. AbortSpanConsidered int // AbortSpanGCNum is the number of abort cache entries fit for removal (due // to their transactions having terminated). AbortSpanGCNum int // PushTxn is the total number of pushes attempted in this cycle. PushTxn int // ResolveTotal is the total number of attempted intent resolutions in // this cycle. ResolveTotal int // ResolveErrors is the number of successful intent resolutions. ResolveSuccess int // Threshold is the computed expiration timestamp. Equal to `Now - Policy`. Threshold hlc.Timestamp }
GCInfo contains statistics and insights from a GC run.
func RunGC ¶
func RunGC( ctx context.Context, desc *roachpb.RangeDescriptor, snap engine.Reader, now hlc.Timestamp, policy config.GCPolicy, pushTxnFn pushFunc, resolveIntentsFn resolveFunc, ) ([]roachpb.GCRequest_GCKey, GCInfo, error)
RunGC runs garbage collection for the specified descriptor on the provided Engine (which is not mutated). It uses the provided functions pushTxnFn and resolveIntentsFn to clarify the true status of and clean up after encountered transactions. It returns a slice of gc'able keys from the data, transaction, and abort spans.
type IncomingSnapshot ¶
type IncomingSnapshot struct { SnapUUID uuid.UUID // The target RangeDescriptor for this snapshot. RangeDescriptor roachpb.RangeDescriptor // The RocksDB BatchReprs that make up this snapshot. Batches [][]byte // The Raft log entries for this snapshot. LogEntries [][]byte }
IncomingSnapshot contains the data for an incoming streaming snapshot message.
type KeyRange ¶
type KeyRange interface { Desc() *roachpb.RangeDescriptor btree.Item fmt.Stringer // contains filtered or unexported methods }
KeyRange is an interface type for the replicasByKey BTree, to compare Replica and ReplicaPlaceholder.
type Liveness ¶
type Liveness struct { NodeID github_com_cockroachdb_cockroach_pkg_roachpb.NodeID `` /* 141-byte string literal not displayed */ // Epoch is a monotonically-increasing value for node liveness. It // may be incremented if the liveness record expires (current time // is later than the expiration timestamp). Epoch int64 `protobuf:"varint,2,opt,name=epoch,proto3" json:"epoch,omitempty"` // The timestamp at which this liveness record expires. Expiration cockroach_util_hlc.Timestamp `protobuf:"bytes,3,opt,name=expiration" json:"expiration"` }
Liveness holds information about a node's latest heartbeat and epoch.
func (*Liveness) Descriptor ¶
func (*Liveness) ProtoMessage ¶
func (*Liveness) ProtoMessage()
type LivenessMetrics ¶
type LivenessMetrics struct { HeartbeatSuccesses *metric.Counter HeartbeatFailures *metric.Counter EpochIncrements *metric.Counter }
LivenessMetrics holds metrics for use with node liveness activity.
type LocalProposalData ¶
type LocalProposalData struct { // The error resulting from the proposal. Most failing proposals will // fail-fast, i.e. will return an error to the client above Raft. However, // some proposals need to commit data even on error, and in that case we // treat the proposal like a successful one, except that the error stored // here will be sent to the client when the associated batch commits. In // the common case, this field is nil. Err *roachpb.Error Reply *roachpb.BatchResponse Batch engine.Batch // contains filtered or unexported fields }
LocalProposalData is data belonging to a proposal that is only relevant on the node on which the command was proposed.
TODO(tschottdorf): once the WriteBatch is available in the replicated proposal data (i.e. once we really do proposer-evaluted KV), experiment with holding on to the proposer's constructed engine.Batch in this struct, which could give a performance gain.
type MultiRaftClient ¶
type MultiRaftClient interface { RaftMessageBatch(ctx context.Context, opts ...grpc.CallOption) (MultiRaft_RaftMessageBatchClient, error) RaftSnapshot(ctx context.Context, opts ...grpc.CallOption) (MultiRaft_RaftSnapshotClient, error) }
func NewMultiRaftClient ¶
func NewMultiRaftClient(cc *grpc.ClientConn) MultiRaftClient
type MultiRaftServer ¶
type MultiRaftServer interface { RaftMessageBatch(MultiRaft_RaftMessageBatchServer) error RaftSnapshot(MultiRaft_RaftSnapshotServer) error }
type MultiRaft_RaftMessageBatchClient ¶
type MultiRaft_RaftMessageBatchClient interface { Send(*RaftMessageRequestBatch) error Recv() (*RaftMessageResponse, error) grpc.ClientStream }
type MultiRaft_RaftMessageBatchServer ¶
type MultiRaft_RaftMessageBatchServer interface { Send(*RaftMessageResponse) error Recv() (*RaftMessageRequestBatch, error) grpc.ServerStream }
type MultiRaft_RaftSnapshotClient ¶
type MultiRaft_RaftSnapshotClient interface { Send(*SnapshotRequest) error Recv() (*SnapshotResponse, error) grpc.ClientStream }
type MultiRaft_RaftSnapshotServer ¶
type MultiRaft_RaftSnapshotServer interface { Send(*SnapshotResponse) error Recv() (*SnapshotRequest, error) grpc.ServerStream }
type NodeAddressResolver ¶
NodeAddressResolver is the function used by RaftTransport to map node IDs to network addresses.
func GossipAddressResolver ¶
func GossipAddressResolver(gossip *gossip.Gossip) NodeAddressResolver
GossipAddressResolver is a thin wrapper around gossip's GetNodeIDAddress that allows its return value to be used as the net.Addr interface.
type NodeLiveness ¶
type NodeLiveness struct {
// contains filtered or unexported fields
}
NodeLiveness encapsulates information on node liveness and provides an API for querying, updating, and invalidating node liveness. Nodes periodically "heartbeat" the range holding the node liveness system table to indicate that they're available. The resulting liveness information is used to ignore unresponsive nodes while making range quiescense decisions, as well as for efficient, node liveness epoch-based range leases.
func NewNodeLiveness ¶
func NewNodeLiveness( ambient log.AmbientContext, clock *hlc.Clock, db *client.DB, g *gossip.Gossip, livenessThreshold time.Duration, heartbeatInterval time.Duration, ) *NodeLiveness
NewNodeLiveness returns a new instance of NodeLiveness configured with the specified gossip instance.
func (*NodeLiveness) GetLiveness ¶
func (nl *NodeLiveness) GetLiveness(nodeID roachpb.NodeID) (Liveness, error)
GetLiveness returns the liveness record for the specified nodeID. ErrNoLivenessRecord is returned in the event that nothing is yet known about nodeID via liveness gossip.
func (*NodeLiveness) IncrementEpoch ¶
IncrementEpoch is called by nodes on other nodes in order to increment the current liveness epoch, thereby invalidating anything relying on the liveness of the previous epoch. This method does a conditional put on the node liveness record, and if successful, stores the updated liveness record in the nodes map.
TODO(spencer): make sure calls to this method are captured in range lease metrics.
func (*NodeLiveness) IsLive ¶
func (nl *NodeLiveness) IsLive(nodeID roachpb.NodeID) (bool, error)
IsLive returns whether or not the specified node is considered live based on the last receipt of a liveness update via gossip. It is an error if the specified node is not in the local liveness table.
func (*NodeLiveness) ManualHeartbeat ¶
func (nl *NodeLiveness) ManualHeartbeat() error
ManualHeartbeat triggers a heartbeat outside of the normal periodic heartbeat loop. Used for unittesting.
func (*NodeLiveness) Metrics ¶
func (nl *NodeLiveness) Metrics() LivenessMetrics
Metrics returns a struct which contains metrics related to node liveness activity.
func (*NodeLiveness) Self ¶
func (nl *NodeLiveness) Self() (Liveness, error)
Self returns the liveness record for this node. ErrNoLivenessRecord is returned in the event that the node has neither heartbeat its liveness record successfully, nor received a gossip message containing a former liveness update on restart.
func (*NodeLiveness) StartHeartbeat ¶
func (nl *NodeLiveness) StartHeartbeat(ctx context.Context, stopper *stop.Stopper)
StartHeartbeat starts a periodic heartbeat to refresh this node's last heartbeat in the node liveness table.
type NotBootstrappedError ¶
type NotBootstrappedError struct{}
A NotBootstrappedError indicates that an engine has not yet been bootstrapped due to a store identifier not being present.
func (*NotBootstrappedError) Error ¶
func (e *NotBootstrappedError) Error() string
Error formats error.
type OutgoingSnapshot ¶
type OutgoingSnapshot struct { SnapUUID uuid.UUID // The Raft snapshot message to send. Contains SnapUUID as its data. RaftSnap raftpb.Snapshot // The RocksDB snapshot that will be streamed from. EngineSnap engine.Reader // The complete range iterator for the snapshot to stream. Iter *ReplicaDataIterator // contains filtered or unexported fields }
OutgoingSnapshot contains the data required to stream a snapshot to a recipient. Once one is created, it needs to be closed via CloseOutSnap() to prevent resource leakage.
type OutgoingSnapshotStream ¶
type OutgoingSnapshotStream interface { Send(*SnapshotRequest) error Recv() (*SnapshotResponse, error) }
OutgoingSnapshotStream is the minimal interface on a GRPC stream required to send a snapshot over the network.
type PollFrozenRequest ¶
type PollFrozenRequest struct { StoreRequestHeader `protobuf:"bytes,1,opt,name=header,embedded=header" json:"header"` // When true, collect the frozen Replicas, and the thawed ones otherwise. CollectFrozen bool `protobuf:"varint,2,opt,name=collect_frozen,json=collectFrozen,proto3" json:"collect_frozen,omitempty"` }
A PollFrozenRequest asks the addressed Store for its frozen or thawed Replicas.
func (*PollFrozenRequest) Descriptor ¶
func (*PollFrozenRequest) Descriptor() ([]byte, []int)
func (*PollFrozenRequest) Marshal ¶
func (m *PollFrozenRequest) Marshal() (dAtA []byte, err error)
func (*PollFrozenRequest) MarshalTo ¶
func (m *PollFrozenRequest) MarshalTo(dAtA []byte) (int, error)
func (*PollFrozenRequest) ProtoMessage ¶
func (*PollFrozenRequest) ProtoMessage()
func (*PollFrozenRequest) Reset ¶
func (m *PollFrozenRequest) Reset()
func (*PollFrozenRequest) Size ¶
func (m *PollFrozenRequest) Size() (n int)
func (*PollFrozenRequest) String ¶
func (m *PollFrozenRequest) String() string
func (*PollFrozenRequest) Unmarshal ¶
func (m *PollFrozenRequest) Unmarshal(dAtA []byte) error
type PollFrozenResponse ¶
type PollFrozenResponse struct {
Results []cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,1,rep,name=results" json:"results"`
}
A PollFrozenResponse is the response returned from a PollFrozenRequest.
func (*PollFrozenResponse) Descriptor ¶
func (*PollFrozenResponse) Descriptor() ([]byte, []int)
func (*PollFrozenResponse) Marshal ¶
func (m *PollFrozenResponse) Marshal() (dAtA []byte, err error)
func (*PollFrozenResponse) MarshalTo ¶
func (m *PollFrozenResponse) MarshalTo(dAtA []byte) (int, error)
func (*PollFrozenResponse) ProtoMessage ¶
func (*PollFrozenResponse) ProtoMessage()
func (*PollFrozenResponse) Reset ¶
func (m *PollFrozenResponse) Reset()
func (*PollFrozenResponse) Size ¶
func (m *PollFrozenResponse) Size() (n int)
func (*PollFrozenResponse) String ¶
func (m *PollFrozenResponse) String() string
func (*PollFrozenResponse) Unmarshal ¶
func (m *PollFrozenResponse) Unmarshal(dAtA []byte) error
type ProposalData ¶
type ProposalData struct { LocalProposalData MaxLeaseIndex uint64 OriginReplica roachpb.ReplicaDescriptor Cmd *roachpb.BatchRequest storagebase.ReplicatedProposalData WriteBatch *storagebase.WriteBatch }
ProposalData is the result of preparing a Raft proposal. That is, the proposer (which holds the lease, at least in the case in which the command will complete successfully) has evaluated the proposal and is holding on to:
a) changes to be written to disk when applying the command b) changes to the state which may require special handling (i.e. code
execution) on all Replicas
c) data which isn't sent to the followers but the proposer needs for tasks
it must run when the command has applied (such as resolving intents).
func (*ProposalData) MergeAndDestroy ¶
func (p *ProposalData) MergeAndDestroy(q ProposalData) error
MergeAndDestroy absorbs the supplied ProposalData while validating that the resulting ProposalData makes sense. For example, it is forbidden to absorb two lease updates or log truncations, or multiple splits and/or merges.
The passed ProposalData must not be used once passed to Merge.
type RaftHeartbeat ¶
type RaftHeartbeat struct { RangeID github_com_cockroachdb_cockroach_pkg_roachpb.RangeID `` /* 128-byte string literal not displayed */ FromReplicaID github_com_cockroachdb_cockroach_pkg_roachpb.ReplicaID `` /* 150-byte string literal not displayed */ ToReplicaID github_com_cockroachdb_cockroach_pkg_roachpb.ReplicaID `` /* 144-byte string literal not displayed */ Term uint64 `protobuf:"varint,4,opt,name=term" json:"term"` Commit uint64 `protobuf:"varint,5,opt,name=commit" json:"commit"` Quiesce bool `protobuf:"varint,6,opt,name=quiesce" json:"quiesce"` }
RaftHeartbeat is a request that contains the barebones information for a raftpb.MsgHeartbeat raftpb.Message. RaftHeartbeats are coalesced and sent in a RaftMessageRequest, and reconstructed by the receiver into individual raftpb.Message protos.
func (*RaftHeartbeat) Descriptor ¶
func (*RaftHeartbeat) Descriptor() ([]byte, []int)
func (*RaftHeartbeat) Marshal ¶
func (m *RaftHeartbeat) Marshal() (dAtA []byte, err error)
func (*RaftHeartbeat) ProtoMessage ¶
func (*RaftHeartbeat) ProtoMessage()
func (*RaftHeartbeat) Reset ¶
func (m *RaftHeartbeat) Reset()
func (*RaftHeartbeat) Size ¶
func (m *RaftHeartbeat) Size() (n int)
func (*RaftHeartbeat) String ¶
func (m *RaftHeartbeat) String() string
func (*RaftHeartbeat) Unmarshal ¶
func (m *RaftHeartbeat) Unmarshal(dAtA []byte) error
type RaftMessageHandler ¶
type RaftMessageHandler interface { // HandleRaftRequest is called for each incoming Raft message. If it returns // an error it will be streamed back to the sender of the message as a // RaftMessageResponse. If the stream parameter is nil the request should be // processed synchronously. If the stream is non-nil the request can be // processed asynchronously and any error should be sent on the stream. HandleRaftRequest(ctx context.Context, req *RaftMessageRequest, respStream RaftMessageResponseStream) *roachpb.Error // HandleRaftResponse is called for each raft response. Note that // not all messages receive a response. An error is returned if and only if // the underlying Raft connection should be closed. HandleRaftResponse(context.Context, *RaftMessageResponse) error // HandleSnapshot is called for each new incoming snapshot stream, after // parsing the initial SnapshotRequest_Header on the stream. HandleSnapshot(header *SnapshotRequest_Header, respStream SnapshotResponseStream) error }
RaftMessageHandler is the interface that must be implemented by arguments to RaftTransport.Listen.
type RaftMessageRequest ¶
type RaftMessageRequest struct { RangeID github_com_cockroachdb_cockroach_pkg_roachpb.RangeID `` /* 128-byte string literal not displayed */ FromReplica cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,2,opt,name=from_replica,json=fromReplica" json:"from_replica"` ToReplica cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,3,opt,name=to_replica,json=toReplica" json:"to_replica"` Message raftpb.Message `protobuf:"bytes,4,opt,name=message" json:"message"` // Is this a quiesce request? A quiesce request is a MsgHeartbeat // which is requesting the recipient to stop ticking its local // replica as long as the current Raft state matches the heartbeat // Term/Commit. If the Term/Commit match, the recipient is marked as // quiescent. If they don't match, the message is passed along to // Raft which will generate a MsgHeartbeatResp that will unquiesce // the sender. Quiesce bool `protobuf:"varint,5,opt,name=quiesce" json:"quiesce"` // A coalesced heartbeat request is any RaftMessageRequest with a nonzero number of // heartbeats or heartbeat_resps. Heartbeats []RaftHeartbeat `protobuf:"bytes,6,rep,name=heartbeats" json:"heartbeats"` HeartbeatResps []RaftHeartbeat `protobuf:"bytes,7,rep,name=heartbeat_resps,json=heartbeatResps" json:"heartbeat_resps"` }
RaftMessageRequest is the request used to send raft messages using our protobuf-based RPC codec. If a RaftMessageRequest has a non-empty number of heartbeats or heartbeat_resps, the contents of the message field is treated as a dummy message and discarded. A coalesced heartbeat request's replica descriptor's range ID must be zero.
func (*RaftMessageRequest) Descriptor ¶
func (*RaftMessageRequest) Descriptor() ([]byte, []int)
func (*RaftMessageRequest) GetUser ¶
func (*RaftMessageRequest) GetUser() string
GetUser implements security.RequestWithUser. Raft messages are always sent by the node user.
func (*RaftMessageRequest) Marshal ¶
func (m *RaftMessageRequest) Marshal() (dAtA []byte, err error)
func (*RaftMessageRequest) MarshalTo ¶
func (m *RaftMessageRequest) MarshalTo(dAtA []byte) (int, error)
func (*RaftMessageRequest) ProtoMessage ¶
func (*RaftMessageRequest) ProtoMessage()
func (*RaftMessageRequest) Reset ¶
func (m *RaftMessageRequest) Reset()
func (*RaftMessageRequest) Size ¶
func (m *RaftMessageRequest) Size() (n int)
func (*RaftMessageRequest) String ¶
func (m *RaftMessageRequest) String() string
func (*RaftMessageRequest) Unmarshal ¶
func (m *RaftMessageRequest) Unmarshal(dAtA []byte) error
type RaftMessageRequestBatch ¶
type RaftMessageRequestBatch struct {
Requests []RaftMessageRequest `protobuf:"bytes,1,rep,name=requests" json:"requests"`
}
func (*RaftMessageRequestBatch) Descriptor ¶
func (*RaftMessageRequestBatch) Descriptor() ([]byte, []int)
func (*RaftMessageRequestBatch) Marshal ¶
func (m *RaftMessageRequestBatch) Marshal() (dAtA []byte, err error)
func (*RaftMessageRequestBatch) MarshalTo ¶
func (m *RaftMessageRequestBatch) MarshalTo(dAtA []byte) (int, error)
func (*RaftMessageRequestBatch) ProtoMessage ¶
func (*RaftMessageRequestBatch) ProtoMessage()
func (*RaftMessageRequestBatch) Reset ¶
func (m *RaftMessageRequestBatch) Reset()
func (*RaftMessageRequestBatch) Size ¶
func (m *RaftMessageRequestBatch) Size() (n int)
func (*RaftMessageRequestBatch) String ¶
func (m *RaftMessageRequestBatch) String() string
func (*RaftMessageRequestBatch) Unmarshal ¶
func (m *RaftMessageRequestBatch) Unmarshal(dAtA []byte) error
type RaftMessageResponse ¶
type RaftMessageResponse struct { RangeID github_com_cockroachdb_cockroach_pkg_roachpb.RangeID `` /* 128-byte string literal not displayed */ FromReplica cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,2,opt,name=from_replica,json=fromReplica" json:"from_replica"` ToReplica cockroach_roachpb.ReplicaDescriptor `protobuf:"bytes,3,opt,name=to_replica,json=toReplica" json:"to_replica"` Union RaftMessageResponseUnion `protobuf:"bytes,4,opt,name=union" json:"union"` }
RaftMessageResponse may be sent to the sender of a RaftMessageRequest. RaftMessage does not use the usual request/response pattern; it is primarily modeled as a one-way stream of requests. Normal 'responses' are usually sent as new requests on a separate stream in the other direction. RaftMessageResponse is not sent for every RaftMessageRequest, but may be used for certain error conditions.
func (*RaftMessageResponse) Descriptor ¶
func (*RaftMessageResponse) Descriptor() ([]byte, []int)
func (*RaftMessageResponse) Marshal ¶
func (m *RaftMessageResponse) Marshal() (dAtA []byte, err error)
func (*RaftMessageResponse) MarshalTo ¶
func (m *RaftMessageResponse) MarshalTo(dAtA []byte) (int, error)
func (*RaftMessageResponse) ProtoMessage ¶
func (*RaftMessageResponse) ProtoMessage()
func (*RaftMessageResponse) Reset ¶
func (m *RaftMessageResponse) Reset()
func (*RaftMessageResponse) Size ¶
func (m *RaftMessageResponse) Size() (n int)
func (*RaftMessageResponse) String ¶
func (m *RaftMessageResponse) String() string
func (*RaftMessageResponse) Unmarshal ¶
func (m *RaftMessageResponse) Unmarshal(dAtA []byte) error
type RaftMessageResponseStream ¶
type RaftMessageResponseStream interface { Context() context.Context Send(*RaftMessageResponse) error }
RaftMessageResponseStream is the subset of the MultiRaft_RaftMessageServer interface that is needed for sending responses.
type RaftMessageResponseUnion ¶
type RaftMessageResponseUnion struct {
Error *cockroach_roachpb3.Error `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"`
}
func (*RaftMessageResponseUnion) Descriptor ¶
func (*RaftMessageResponseUnion) Descriptor() ([]byte, []int)
func (*RaftMessageResponseUnion) GetValue ¶
func (this *RaftMessageResponseUnion) GetValue() interface{}
func (*RaftMessageResponseUnion) Marshal ¶
func (m *RaftMessageResponseUnion) Marshal() (dAtA []byte, err error)
func (*RaftMessageResponseUnion) MarshalTo ¶
func (m *RaftMessageResponseUnion) MarshalTo(dAtA []byte) (int, error)
func (*RaftMessageResponseUnion) ProtoMessage ¶
func (*RaftMessageResponseUnion) ProtoMessage()
func (*RaftMessageResponseUnion) Reset ¶
func (m *RaftMessageResponseUnion) Reset()
func (*RaftMessageResponseUnion) SetValue ¶
func (this *RaftMessageResponseUnion) SetValue(value interface{}) bool
func (*RaftMessageResponseUnion) Size ¶
func (m *RaftMessageResponseUnion) Size() (n int)
func (*RaftMessageResponseUnion) String ¶
func (m *RaftMessageResponseUnion) String() string
func (*RaftMessageResponseUnion) Unmarshal ¶
func (m *RaftMessageResponseUnion) Unmarshal(dAtA []byte) error
type RaftTransport ¶
type RaftTransport struct { log.AmbientContext // contains filtered or unexported fields }
RaftTransport handles the rpc messages for raft.
The raft transport is asynchronous with respect to the caller, and internally multiplexes outbound messages. Internally, each message is queued on a per-destination queue before being asynchronously delivered.
Callers are required to construct a RaftSender before being able to dispatch messages, and must provide an error handler which will be invoked asynchronously in the event that the recipient of any message closes its inbound RPC stream. This callback is asynchronous with respect to the outbound message which caused the remote to hang up; all that is known is which remote hung up.
func NewDummyRaftTransport ¶
func NewDummyRaftTransport() *RaftTransport
NewDummyRaftTransport returns a dummy raft transport for use in tests which need a non-nil raft transport that need not function.
func NewRaftTransport ¶
func NewRaftTransport( ambient log.AmbientContext, resolver NodeAddressResolver, grpcServer *grpc.Server, rpcContext *rpc.Context, ) *RaftTransport
NewRaftTransport creates a new RaftTransport.
func (*RaftTransport) GetCircuitBreaker ¶
func (t *RaftTransport) GetCircuitBreaker(nodeID roachpb.NodeID) *circuit.Breaker
GetCircuitBreaker returns the circuit breaker controlling connection attempts to the specified node.
func (*RaftTransport) Listen ¶
func (t *RaftTransport) Listen(storeID roachpb.StoreID, handler RaftMessageHandler)
Listen registers a raftMessageHandler to receive proxied messages.
func (*RaftTransport) RaftMessageBatch ¶
func (t *RaftTransport) RaftMessageBatch(stream MultiRaft_RaftMessageBatchServer) error
RaftMessageBatch proxies the incoming requests to the listening server interface.
func (*RaftTransport) RaftSnapshot ¶
func (t *RaftTransport) RaftSnapshot(stream MultiRaft_RaftSnapshotServer) error
RaftSnapshot handles incoming streaming snapshot requests.
func (*RaftTransport) SendAsync ¶
func (t *RaftTransport) SendAsync(req *RaftMessageRequest) bool
SendAsync sends a message to the recipient specified in the request. It returns false if the outgoing queue is full and calls s.onError when the recipient closes the stream.
func (*RaftTransport) SendSnapshot ¶
func (t *RaftTransport) SendSnapshot( ctx context.Context, storePool *StorePool, header SnapshotRequest_Header, snap *OutgoingSnapshot, newBatch func() engine.Batch, ) error
SendSnapshot streams the given outgoing snapshot. The caller is responsible for closing the OutgoingSnapshot.
func (*RaftTransport) Stop ¶
func (t *RaftTransport) Stop(storeID roachpb.StoreID)
Stop unregisters a raftMessageHandler.
type RangeEventLogType ¶
type RangeEventLogType string
RangeEventLogType describes a specific event type recorded in the range log table.
const ( // RangeEventLogSplit is the event type recorded when a range splits. RangeEventLogSplit RangeEventLogType = "split" // RangeEventLogAdd is the event type recorded when a range adds a // new replica. RangeEventLogAdd RangeEventLogType = "add" // RangeEventLogRemove is the event type recorded when a range removes a // replica. RangeEventLogRemove RangeEventLogType = "remove" )
type Replica ¶
type Replica struct { log.AmbientContext // TODO(tschottdorf): Duplicates r.mu.state.desc.RangeID; revisit that. RangeID roachpb.RangeID // Should only be set by the constructor. // contains filtered or unexported fields }
A Replica is a contiguous keyspace with writes managed via an instance of the Raft consensus algorithm. Many ranges may exist in a store and they are unlikely to be contiguous. Ranges are independent units and are responsible for maintaining their own integrity by replacing failed replicas, splitting and merging as appropriate.
func NewReplica ¶
func NewReplica( desc *roachpb.RangeDescriptor, store *Store, replicaID roachpb.ReplicaID, ) (*Replica, error)
NewReplica initializes the replica using the given metadata. If the replica is initialized (i.e. desc contains more than a RangeID), replicaID should be 0 and the replicaID will be discovered from the descriptor.
func (*Replica) AdminMerge ¶
func (r *Replica) AdminMerge( ctx context.Context, args roachpb.AdminMergeRequest, origLeftDesc *roachpb.RangeDescriptor, ) (roachpb.AdminMergeResponse, *roachpb.Error)
AdminMerge extends this range to subsume the range that comes next in the key space. The merge is performed inside of a distributed transaction which writes the left hand side range descriptor (the subsuming range) and deletes the range descriptor for the right hand side range (the subsumed range). It also updates the range addressing metadata. The handover of responsibility for the reassigned key range is carried out seamlessly through a merge trigger carried out as part of the commit of that transaction. A merge requires that the two ranges are collocated on the same set of replicas.
The supplied RangeDescriptor is used as a form of optimistic lock. See the comment of "AdminSplit" for more information on this pattern.
func (*Replica) AdminSplit ¶
func (r *Replica) AdminSplit( ctx context.Context, args roachpb.AdminSplitRequest, desc *roachpb.RangeDescriptor, ) (roachpb.AdminSplitResponse, *roachpb.Error)
AdminSplit divides the range into into two ranges, using either args.SplitKey (if provided) or an internally computed key that aims to roughly equipartition the range by size. The split is done inside of a distributed txn which writes updated left and new right hand side range descriptors, and updates the range addressing metadata. The handover of responsibility for the reassigned key range is carried out seamlessly through a split trigger carried out as part of the commit of that transaction.
The supplied RangeDescriptor is used as a form of optimistic lock. An operation which might split a range should obtain a copy of the range's current descriptor before making the decision to split. If the decision is affirmative the descriptor is passed to AdminSplit, which performs a Conditional Put on the RangeDescriptor to ensure that no other operation has modified the range in the time the decision was being made. TODO(tschottdorf): should assert that split key is not a local key.
See the comment on splitTrigger for details on the complexities.
func (*Replica) AdminTransferLease ¶
AdminTransferLease transfers the LeaderLease to another replica. Only the current holder of the LeaderLease can do a transfer, because it needs to stop serving reads and proposing Raft commands (CPut is a read) after sending the transfer command. If it did not stop serving reads immediately, it would potentially serve reads with timestamps greater than the start timestamp of the new (transferred) lease. More subtly, the replica can't even serve reads or propose commands with timestamps lower than the start of the new lease because it could lead to read your own write violations (see comments on the stasis period in the Lease proto). We could, in principle, serve reads more than the maximum clock offset in the past.
The method waits for any in-progress lease extension to be done, and it also blocks until the transfer is done. If a transfer is already in progress, this method joins in waiting for it to complete if it's transferring to the same replica. Otherwise, a NotLeaseHolderError is returned.
func (*Replica) BeginTransaction ¶
func (r *Replica) BeginTransaction( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.BeginTransactionRequest, ) (roachpb.BeginTransactionResponse, error)
BeginTransaction writes the initial transaction record. Fails in the event that a transaction record is already written. This may occur if a transaction is started with a batch containing writes to different ranges, and the range containing the txn record fails to receive the write batch before a heartbeat or txn push is performed first and aborts the transaction.
func (*Replica) ChangeFrozen ¶
func (r *Replica) ChangeFrozen( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.ChangeFrozenRequest, ) (roachpb.ChangeFrozenResponse, ProposalData, error)
ChangeFrozen freezes or unfreezes the Replica idempotently.
func (*Replica) ChangeReplicas ¶
func (r *Replica) ChangeReplicas( ctx context.Context, changeType roachpb.ReplicaChangeType, repDesc roachpb.ReplicaDescriptor, desc *roachpb.RangeDescriptor, ) error
ChangeReplicas adds or removes a replica of a range. The change is performed in a distributed transaction and takes effect when that transaction is committed. When removing a replica, only the NodeID and StoreID fields of the Replica are used.
The supplied RangeDescriptor is used as a form of optimistic lock. See the comment of "AdminSplit" for more information on this pattern.
Changing the replicas for a range is complicated. A change is initiated by the "replicate" queue when it encounters a range which has too many replicas, too few replicas or requires rebalancing. Addition and removal of a replica is divided into four phases. The first phase, which occurs in Replica.ChangeReplicas, is performed via a distributed transaction which updates the range descriptor and the meta range addressing information. This transaction includes a special ChangeReplicasTrigger on the EndTransaction request. A ConditionalPut of the RangeDescriptor implements the optimistic lock on the RangeDescriptor mentioned previously. Like all transactions, the requests within the transaction are replicated via Raft, including the EndTransaction request.
The second phase of processing occurs when the batch containing the EndTransaction is proposed to raft. This proposing occurs on whatever replica received the batch, usually, but not always the range lease holder. defaultProposeRaftCommandLocked notices that the EndTransaction contains a ChangeReplicasTrigger and proposes a ConfChange to Raft (via raft.RawNode.ProposeConfChange).
The ConfChange is propagated to all of the replicas similar to a normal Raft command, though additional processing is done inside of Raft. A Replica encounters the ConfChange in Replica.handleRaftReady and executes it using raft.RawNode.ApplyConfChange. If a new replica was added the Raft leader will start sending it heartbeat messages and attempting to bring it up to date. If a replica was removed, it is at this point that the Raft leader will stop communicating with it.
The fourth phase of change replicas occurs when each replica for the range encounters the ChangeReplicasTrigger when applying the EndTransaction request. The replica will update its local range descriptor so as to contain the new set of replicas. If the replica is the one that is being removed, it will queue itself for removal with replicaGCQueue.
Note that a removed replica may not see the EndTransaction containing the ChangeReplicasTrigger. The ConfChange operation will be applied as soon as a quorum of nodes have committed it. If the removed replica is down or the message is dropped for some reason the removed replica will not be notified. The replica GC queue will eventually discover and cleanup this state.
When a new replica is added, it will have to catch up to the state of the other replicas. The Raft leader automatically handles this by either sending the new replica Raft log entries to apply, or by generating and sending a snapshot. See Replica.Snapshot and Replica.Entries.
Note that Replica.ChangeReplicas returns when the distributed transaction has been committed to a quorum of replicas in the range. The actual replication of data occurs asynchronously via a snapshot or application of Raft log entries. This is important for the replicate queue to be aware of. A node can process hundreds or thousands of ChangeReplicas operations per second even though the actual replication of data proceeds at a much slower base. In order to avoid having this background replication overwhelm the system, replication is throttled via a reservation system. When allocating a new replica for a range, the replicate queue reserves space for that replica on the target store via a ReservationRequest. (See StorePool.reserve). The reservation is fulfilled when the snapshot is applied.
TODO(peter): There is a rare scenario in which a replica can be brought up to date via Raft log replay. In this scenario, the reservation will be left dangling until it expires. See #7849.
TODO(peter): Describe preemptive snapshots. Preemptive snapshots are needed for the replicate queue to function properly. Currently the replicate queue will fire off as many replica additions as possible until it starts getting reservations denied at which point it will ignore the replica until the next scanner cycle.
func (*Replica) CheckConsistency ¶
func (r *Replica) CheckConsistency( ctx context.Context, args roachpb.CheckConsistencyRequest, desc *roachpb.RangeDescriptor, ) (roachpb.CheckConsistencyResponse, *roachpb.Error)
CheckConsistency runs a consistency check on the range. It first applies a ComputeChecksum command on the range. It then issues CollectChecksum commands to the other replicas.
TODO(tschottdorf): We should call this AdminCheckConsistency.
func (*Replica) CloseOutSnap ¶
func (r *Replica) CloseOutSnap()
CloseOutSnap closes the Replica's outgoing snapshot, freeing its resources and readying the Replica to send more snapshots. Must be called after any invocation of SnapshotWithContext.
func (*Replica) ComputeChecksum ¶
func (r *Replica) ComputeChecksum( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.ComputeChecksumRequest, ) (roachpb.ComputeChecksumResponse, ProposalData, error)
ComputeChecksum starts the process of computing a checksum on the replica at a particular snapshot. The checksum is later verified through a CollectChecksumRequest.
func (*Replica) ConditionalPut ¶
func (r *Replica) ConditionalPut( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.ConditionalPutRequest, ) (roachpb.ConditionalPutResponse, error)
ConditionalPut sets the value for a specified key only if the expected value matches. If not, the return value contains the actual value.
func (*Replica) ContainsKey ¶
ContainsKey returns whether this range contains the specified key.
func (*Replica) ContainsKeyRange ¶
ContainsKeyRange returns whether this range contains the specified key range from start to end.
func (*Replica) Delete ¶
func (r *Replica) Delete( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.DeleteRequest, ) (roachpb.DeleteResponse, error)
Delete deletes the key and value specified by key.
func (*Replica) DeleteRange ¶
func (r *Replica) DeleteRange( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, maxKeys int64, args roachpb.DeleteRangeRequest, ) (roachpb.DeleteRangeResponse, *roachpb.Span, int64, error)
DeleteRange deletes the range of key/value pairs specified by start and end keys.
func (*Replica) Desc ¶
func (r *Replica) Desc() *roachpb.RangeDescriptor
Desc returns the authoritative range descriptor, acquiring a replica lock in the process.
func (*Replica) EndTransaction ¶
func (r *Replica) EndTransaction( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.EndTransactionRequest, ) (roachpb.EndTransactionResponse, ProposalData, error)
EndTransaction either commits or aborts (rolls back) an extant transaction according to the args.Commit parameter. Rolling back an already rolled-back txn is ok.
func (*Replica) Entries ¶
Entries implements the raft.Storage interface. Note that maxBytes is advisory and this method will always return at least one entry even if it exceeds maxBytes. Passing maxBytes equal to zero disables size checking. Entries requires that the replica lock is held.
func (*Replica) FirstIndex ¶
FirstIndex implements the raft.Storage interface. FirstIndex requires that the replica lock is held.
func (*Replica) GC ¶
func (r *Replica) GC( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.GCRequest, ) (roachpb.GCResponse, ProposalData, error)
GC iterates through the list of keys to garbage collect specified in the arguments. MVCCGarbageCollect is invoked on each listed key along with the expiration timestamp. The GC metadata specified in the args is persisted after GC.
func (*Replica) Get ¶
func (r *Replica) Get( ctx context.Context, batch engine.ReadWriter, h roachpb.Header, args roachpb.GetRequest, ) (roachpb.GetResponse, ProposalData, error)
Get returns the value for a specified key.
func (*Replica) GetFirstIndex ¶
GetFirstIndex is the same function as FirstIndex but it does not require that the replica lock is held.
func (*Replica) GetMVCCStats ¶
GetMVCCStats returns a copy of the MVCC stats object for this range.
func (*Replica) GetMaxBytes ¶
GetMaxBytes atomically gets the range maximum byte limit.
func (*Replica) GetReplicaDescriptor ¶
func (r *Replica) GetReplicaDescriptor() (roachpb.ReplicaDescriptor, error)
GetReplicaDescriptor returns the replica for this range from the range descriptor. Returns a *RangeNotFoundError if the replica is not found. No other errors are returned.
func (*Replica) GetSnapshot ¶
func (r *Replica) GetSnapshot(ctx context.Context) (*OutgoingSnapshot, error)
GetSnapshot wraps Snapshot() but does not require the replica lock to be held and it will block instead of returning ErrSnapshotTemporaryUnavailable. The caller is directly responsible for calling r.CloseOutSnap.
func (*Replica) HeartbeatTxn ¶
func (r *Replica) HeartbeatTxn( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.HeartbeatTxnRequest, ) (roachpb.HeartbeatTxnResponse, error)
HeartbeatTxn updates the transaction status and heartbeat timestamp after receiving transaction heartbeat messages from coordinator. Returns the updated transaction.
func (*Replica) Increment ¶
func (r *Replica) Increment( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.IncrementRequest, ) (roachpb.IncrementResponse, error)
Increment increments the value (interpreted as varint64 encoded) and returns the newly incremented value (encoded as varint64). If no value exists for the key, zero is incremented.
func (*Replica) InitPut ¶
func (r *Replica) InitPut( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.InitPutRequest, ) (roachpb.InitPutResponse, error)
InitPut sets the value for a specified key only if it doesn't exist. It returns an error if the key exists with an existing value that is different from the value provided.
func (*Replica) InitialState ¶
InitialState implements the raft.Storage interface. InitialState requires that the replica lock be held.
func (*Replica) IsDestroyed ¶
IsDestroyed returns a non-nil error if the replica has been destroyed.
func (*Replica) IsFirstRange ¶
IsFirstRange returns true if this is the first range.
func (*Replica) IsInitialized ¶
IsInitialized is true if we know the metadata of this range, either because we created it or we have received an initial snapshot from another node. It is false when a range has been created in response to an incoming message but we are waiting for our initial snapshot.
func (*Replica) LastIndex ¶
LastIndex implements the raft.Storage interface. LastIndex requires that the replica lock is held.
func (*Replica) LeaseInfo ¶
func (r *Replica) LeaseInfo( ctx context.Context, args roachpb.LeaseInfoRequest, ) (roachpb.LeaseInfoResponse, error)
LeaseInfo returns information about the lease holder for the range.
func (*Replica) Merge ¶
func (r *Replica) Merge( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.MergeRequest, ) (roachpb.MergeResponse, error)
Merge is used to merge a value into an existing key. Merge is an efficient accumulation operation which is exposed by RocksDB, used by CockroachDB for the efficient accumulation of certain values. Due to the difficulty of making these operations transactional, merges are not currently exposed directly to clients. Merged values are explicitly not MVCC data.
func (*Replica) PushTxn ¶
func (r *Replica) PushTxn( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.PushTxnRequest, ) (roachpb.PushTxnResponse, error)
PushTxn resolves conflicts between concurrent txns (or between a non-transactional reader or writer and a txn) in several ways depending on the statuses and priorities of the conflicting transactions. The PushTxn operation is invoked by a "pusher" (the writer trying to abort a conflicting txn or the reader trying to push a conflicting txn's commit timestamp forward), who attempts to resolve a conflict with a "pushee" (args.PushTxn -- the pushee txn whose intent(s) caused the conflict). A pusher is either transactional, in which case PushTxn is completely initialized, or not, in which case the PushTxn has only the priority set.
Txn already committed/aborted: If pushee txn is committed or aborted return success.
Txn Timeout: If pushee txn entry isn't present or its LastHeartbeat timestamp isn't set, use its as LastHeartbeat. If current time - LastHeartbeat > 2 * DefaultHeartbeatInterval, then the pushee txn should be either pushed forward, aborted, or confirmed not pending, depending on value of Request.PushType.
Old Txn Epoch: If persisted pushee txn entry has a newer Epoch than PushTxn.Epoch, return success, as older epoch may be removed.
Lower Txn Priority: If pushee txn has a lower priority than pusher, adjust pushee's persisted txn depending on value of args.PushType. If args.PushType is PUSH_ABORT, set txn.Status to ABORTED, and priority to one less than the pusher's priority and return success. If args.PushType is PUSH_TIMESTAMP, set txn.Timestamp to just after PushTo.
Higher Txn Priority: If pushee txn has a higher priority than pusher, return TransactionPushError. Transaction will be retried with priority one less than the pushee's higher priority.
If the pusher is non-transactional, args.PusherTxn is an empty proto with only the priority set.
If the pushee is aborted, its timestamp will be forwarded to match its last client activity timestamp (i.e. last heartbeat), if available. This is done so that the updated timestamp populates the abort cache, allowing the GC queue to purge entries for which the transaction coordinator must have found out via its heartbeats that the transaction has failed.
func (*Replica) Put ¶
func (r *Replica) Put( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.PutRequest, ) (roachpb.PutResponse, error)
Put sets the value for a specified key.
func (*Replica) RaftStatus ¶
RaftStatus returns the current raft status of the replica. It returns nil if the Raft group has not been initialized yet.
func (*Replica) RangeLookup ¶
func (r *Replica) RangeLookup( ctx context.Context, batch engine.ReadWriter, h roachpb.Header, args roachpb.RangeLookupRequest, ) (roachpb.RangeLookupResponse, ProposalData, error)
RangeLookup is used to look up RangeDescriptors - a RangeDescriptor is a metadata structure which describes the key range and replica locations of a distinct range in the cluster.
RangeDescriptors are stored as values in the cockroach cluster's key-value store. However, they are always stored using special "Range Metadata keys", which are "ordinary" keys with a special prefix prepended. The Range Metadata Key for an ordinary key can be generated with the `keys.RangeMetaKey(key)` function. The RangeDescriptor for the range which contains a given key can be retrieved by generating its Range Metadata Key and dispatching it to RangeLookup.
Note that the Range Metadata Key sent to RangeLookup is NOT the key at which the desired RangeDescriptor is stored. Instead, this method returns the RangeDescriptor stored at the _lowest_ existing key which is _greater_ than the given key. The returned RangeDescriptor will thus contain the ordinary key which was originally used to generate the Range Metadata Key sent to RangeLookup.
The "Range Metadata Key" for a range is built by appending the end key of the range to the respective meta prefix.
Lookups for range metadata keys usually want to read inconsistently, but some callers need a consistent result; both are supported.
This method has an important optimization in the inconsistent case: instead of just returning the request RangeDescriptor, it also returns a slice of additional range descriptors immediately consecutive to the desired RangeDescriptor. This is intended to serve as a sort of caching pre-fetch, so that the requesting nodes can aggressively cache RangeDescriptors which are likely to be desired by their current workload. The Reverse flag specifies whether descriptors are prefetched in descending or ascending order.
func (*Replica) RequestLease ¶
func (r *Replica) RequestLease( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.RequestLeaseRequest, ) (roachpb.RequestLeaseResponse, ProposalData, error)
RequestLease sets the range lease for this range. The command fails only if the desired start timestamp collides with a previous lease. Otherwise, the start timestamp is wound back to right after the expiration of the previous lease (or zero). If this range replica is already the lease holder, the expiration will be extended or shortened as indicated. For a new lease, all duties required of the range lease holder are commenced, including clearing the command queue and timestamp cache.
func (*Replica) ResolveIntent ¶
func (r *Replica) ResolveIntent( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.ResolveIntentRequest, ) (roachpb.ResolveIntentResponse, error)
ResolveIntent resolves a write intent from the specified key according to the status of the transaction which created it.
func (*Replica) ResolveIntentRange ¶
func (r *Replica) ResolveIntentRange( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.ResolveIntentRangeRequest, ) (roachpb.ResolveIntentRangeResponse, error)
ResolveIntentRange resolves write intents in the specified key range according to the status of the transaction which created it.
func (*Replica) ReverseScan ¶
func (r *Replica) ReverseScan( ctx context.Context, batch engine.ReadWriter, h roachpb.Header, maxKeys int64, args roachpb.ReverseScanRequest, ) (roachpb.ReverseScanResponse, *roachpb.Span, int64, ProposalData, error)
ReverseScan scans the key range specified by start key through end key in descending order up to some maximum number of results. maxKeys stores the number of scan results remaining for this batch (MaxInt64 for no limit).
func (*Replica) Scan ¶
func (r *Replica) Scan( ctx context.Context, batch engine.ReadWriter, h roachpb.Header, maxKeys int64, args roachpb.ScanRequest, ) (roachpb.ScanResponse, *roachpb.Span, int64, ProposalData, error)
Scan scans the key range specified by start key through end key in ascending order up to some maximum number of results. maxKeys stores the number of scan results remaining for this batch (MaxInt64 for no limit).
func (*Replica) Send ¶
func (r *Replica) Send( ctx context.Context, ba roachpb.BatchRequest, ) (*roachpb.BatchResponse, *roachpb.Error)
Send adds a command for execution on this range. The command's affected keys are verified to be contained within the range and the range's lease is confirmed. The command is then dispatched either along the read-only execution path or the read-write Raft command queue. ctx should contain the log tags from the store (and up).
func (*Replica) SetMaxBytes ¶
SetMaxBytes atomically sets the maximum byte limit before split. This value is cached by the range for efficiency.
func (*Replica) Snapshot ¶
Snapshot implements the raft.Storage interface. Snapshot requires that the replica lock is held.
func (*Replica) SnapshotWithContext ¶
func (r *Replica) SnapshotWithContext(ctx context.Context) (*OutgoingSnapshot, error)
SnapshotWithContext is the main implementation for Snapshot() but it takes a context to allow tracing. If this method returns without error, callers must eventually call CloseOutSnap to ready this replica for more snapshots.
func (*Replica) State ¶
func (r *Replica) State() storagebase.RangeInfo
State returns a copy of the internal state of the Replica, along with some auxiliary information.
func (*Replica) String ¶
String returns the string representation of the replica using an inconsistent copy of the range descriptor. Therefore, String does not require a lock and its output may not be atomic with other ongoing work in the replica. This is done to prevent deadlocks in logging sites.
func (*Replica) Term ¶
Term implements the raft.Storage interface. Term requires that the replica lock is held.
func (*Replica) TransferLease ¶
func (r *Replica) TransferLease( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.TransferLeaseRequest, ) (roachpb.RequestLeaseResponse, ProposalData, error)
TransferLease sets the lease holder for the range. Unlike with RequestLease(), the new lease is allowed to overlap the old one, the contract being that the transfer must have been initiated by the (soon ex-) lease holder which must have dropped all of its lease holder powers before proposing.
func (*Replica) TruncateLog ¶
func (r *Replica) TruncateLog( ctx context.Context, batch engine.ReadWriter, ms *enginepb.MVCCStats, h roachpb.Header, args roachpb.TruncateLogRequest, ) (roachpb.TruncateLogResponse, ProposalData, error)
TruncateLog discards a prefix of the raft log. Truncating part of a log that has already been truncated has no effect. If this range is not the one specified within the request body, the request will also be ignored.
type ReplicaDataIterator ¶
type ReplicaDataIterator struct {
// contains filtered or unexported fields
}
ReplicaDataIterator provides a complete iteration over all key / value rows in a range, including all system-local metadata and user data. The ranges keyRange slice specifies the key ranges which comprise all of the range's data.
A ReplicaDataIterator provides a subset of the engine.Iterator interface.
func NewReplicaDataIterator ¶
func NewReplicaDataIterator( d *roachpb.RangeDescriptor, e engine.Reader, replicatedOnly bool, ) *ReplicaDataIterator
NewReplicaDataIterator creates a ReplicaDataIterator for the given replica.
func (*ReplicaDataIterator) Close ¶
func (ri *ReplicaDataIterator) Close()
Close the underlying iterator.
func (*ReplicaDataIterator) Error ¶
func (ri *ReplicaDataIterator) Error() error
Error returns the error, if any, which the iterator encountered.
func (*ReplicaDataIterator) Key ¶
func (ri *ReplicaDataIterator) Key() engine.MVCCKey
Key returns the current key.
func (*ReplicaDataIterator) Next ¶
func (ri *ReplicaDataIterator) Next()
Next advances to the next key in the iteration.
func (*ReplicaDataIterator) Valid ¶
func (ri *ReplicaDataIterator) Valid() bool
Valid returns true if the iterator currently points to a valid value.
func (*ReplicaDataIterator) Value ¶
func (ri *ReplicaDataIterator) Value() []byte
Value returns the current value.
type ReplicaPlaceholder ¶
type ReplicaPlaceholder struct {
// contains filtered or unexported fields
}
ReplicaPlaceholder is created by a Store in anticipation of replacing it at some point in the future with a Replica. It has a RangeDescriptor.
func (*ReplicaPlaceholder) Desc ¶
func (r *ReplicaPlaceholder) Desc() *roachpb.RangeDescriptor
Desc returns the range Placeholder's descriptor.
func (*ReplicaPlaceholder) Less ¶
func (r *ReplicaPlaceholder) Less(i btree.Item) bool
Less implements the btree.Item interface.
func (*ReplicaPlaceholder) String ¶
func (r *ReplicaPlaceholder) String() string
type ReplicaSnapshotDiff ¶
type ReplicaSnapshotDiff struct { // LeaseHolder is set to true of this k:v pair is only present on the lease // holder. LeaseHolder bool Key roachpb.Key Timestamp hlc.Timestamp Value []byte }
ReplicaSnapshotDiff is a part of a []ReplicaSnapshotDiff which represents a diff between two replica snapshots. For now it's only a diff between their KV pairs.
type ReplicaSnapshotDiffSlice ¶
type ReplicaSnapshotDiffSlice []ReplicaSnapshotDiff
ReplicaSnapshotDiffSlice groups multiple ReplicaSnapshotDiff records and exposes a formatting helper.
func (ReplicaSnapshotDiffSlice) String ¶
func (rsds ReplicaSnapshotDiffSlice) String() string
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements FreezeServer and ConsistencyServer.
func MakeServer ¶
func MakeServer(descriptor *roachpb.NodeDescriptor, stores *Stores) Server
MakeServer returns a new instance of Server.
func (Server) CollectChecksum ¶
func (is Server) CollectChecksum( ctx context.Context, req *CollectChecksumRequest, ) (*CollectChecksumResponse, error)
CollectChecksum implements ConsistencyServer.
func (Server) PollFrozen ¶
func (is Server) PollFrozen( ctx context.Context, args *PollFrozenRequest, ) (*PollFrozenResponse, error)
PollFrozen implements the FreezeServer interface.
type SnapshotRequest ¶
type SnapshotRequest struct { Header *SnapshotRequest_Header `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"` // A RocksDB BatchRepr. Multiple kv_batches may be sent across multiple request messages. KVBatch []byte `protobuf:"bytes,2,opt,name=kv_batch,json=kvBatch" json:"kv_batch,omitempty"` // These are really raftpb.Entry, but we model them as raw bytes to avoid // roundtripping through memory. They are separate from the kv_batch to // allow flexibility in log implementations. LogEntries [][]byte `protobuf:"bytes,3,rep,name=log_entries,json=logEntries" json:"log_entries,omitempty"` Final bool `protobuf:"varint,4,opt,name=final" json:"final"` }
SnapshotRequest is the request used to send streaming snapshot requests.
func (*SnapshotRequest) Descriptor ¶
func (*SnapshotRequest) Descriptor() ([]byte, []int)
func (*SnapshotRequest) Marshal ¶
func (m *SnapshotRequest) Marshal() (dAtA []byte, err error)
func (*SnapshotRequest) ProtoMessage ¶
func (*SnapshotRequest) ProtoMessage()
func (*SnapshotRequest) Reset ¶
func (m *SnapshotRequest) Reset()
func (*SnapshotRequest) Size ¶
func (m *SnapshotRequest) Size() (n int)
func (*SnapshotRequest) String ¶
func (m *SnapshotRequest) String() string
func (*SnapshotRequest) Unmarshal ¶
func (m *SnapshotRequest) Unmarshal(dAtA []byte) error
type SnapshotRequest_Header ¶
type SnapshotRequest_Header struct { RangeDescriptor cockroach_roachpb.RangeDescriptor `protobuf:"bytes,1,opt,name=range_descriptor,json=rangeDescriptor" json:"range_descriptor"` // The inner raft message is of type MsgSnap, and its snapshot data contains a UUID. RaftMessageRequest RaftMessageRequest `protobuf:"bytes,2,opt,name=raft_message_request,json=raftMessageRequest" json:"raft_message_request"` // The estimated size of the range, to be used in reservation decisions. RangeSize int64 `protobuf:"varint,3,opt,name=range_size,json=rangeSize" json:"range_size"` // can_decline is set on preemptive snapshots, but not those generated // by raft because at that point it is better to queue up the stream // than to cancel it. CanDecline bool `protobuf:"varint,4,opt,name=can_decline,json=canDecline" json:"can_decline"` }
func (*SnapshotRequest_Header) Descriptor ¶
func (*SnapshotRequest_Header) Descriptor() ([]byte, []int)
func (*SnapshotRequest_Header) Marshal ¶
func (m *SnapshotRequest_Header) Marshal() (dAtA []byte, err error)
func (*SnapshotRequest_Header) MarshalTo ¶
func (m *SnapshotRequest_Header) MarshalTo(dAtA []byte) (int, error)
func (*SnapshotRequest_Header) ProtoMessage ¶
func (*SnapshotRequest_Header) ProtoMessage()
func (*SnapshotRequest_Header) Reset ¶
func (m *SnapshotRequest_Header) Reset()
func (*SnapshotRequest_Header) Size ¶
func (m *SnapshotRequest_Header) Size() (n int)
func (*SnapshotRequest_Header) String ¶
func (m *SnapshotRequest_Header) String() string
func (*SnapshotRequest_Header) Unmarshal ¶
func (m *SnapshotRequest_Header) Unmarshal(dAtA []byte) error
type SnapshotResponse ¶
type SnapshotResponse struct { Status SnapshotResponse_Status `protobuf:"varint,1,opt,name=status,enum=cockroach.storage.SnapshotResponse_Status" json:"status"` Message string `protobuf:"bytes,2,opt,name=message" json:"message"` StoreCapacity *cockroach_roachpb.StoreCapacity `protobuf:"bytes,3,opt,name=store_capacity,json=storeCapacity" json:"store_capacity,omitempty"` }
func (*SnapshotResponse) Descriptor ¶
func (*SnapshotResponse) Descriptor() ([]byte, []int)
func (*SnapshotResponse) Marshal ¶
func (m *SnapshotResponse) Marshal() (dAtA []byte, err error)
func (*SnapshotResponse) ProtoMessage ¶
func (*SnapshotResponse) ProtoMessage()
func (*SnapshotResponse) Reset ¶
func (m *SnapshotResponse) Reset()
func (*SnapshotResponse) Size ¶
func (m *SnapshotResponse) Size() (n int)
func (*SnapshotResponse) String ¶
func (m *SnapshotResponse) String() string
func (*SnapshotResponse) Unmarshal ¶
func (m *SnapshotResponse) Unmarshal(dAtA []byte) error
type SnapshotResponseStream ¶
type SnapshotResponseStream interface { Context() context.Context Send(*SnapshotResponse) error Recv() (*SnapshotRequest, error) }
SnapshotResponseStream is the subset of the MultiRaft_RaftSnapshotServer interface that is needed for sending responses.
type SnapshotResponse_Status ¶
type SnapshotResponse_Status int32
const ( SnapshotResponse_UNKNOWN SnapshotResponse_Status = 0 SnapshotResponse_ACCEPTED SnapshotResponse_Status = 1 SnapshotResponse_APPLIED SnapshotResponse_Status = 2 SnapshotResponse_ERROR SnapshotResponse_Status = 3 SnapshotResponse_DECLINED SnapshotResponse_Status = 4 )
func (SnapshotResponse_Status) Enum ¶
func (x SnapshotResponse_Status) Enum() *SnapshotResponse_Status
func (SnapshotResponse_Status) EnumDescriptor ¶
func (SnapshotResponse_Status) EnumDescriptor() ([]byte, []int)
func (SnapshotResponse_Status) String ¶
func (x SnapshotResponse_Status) String() string
func (*SnapshotResponse_Status) UnmarshalJSON ¶
func (x *SnapshotResponse_Status) UnmarshalJSON(data []byte) error
type SnapshotStorePool ¶
type SnapshotStorePool interface {
// contains filtered or unexported methods
}
SnapshotStorePool narrows StorePool to make sendSnapshot easier to test.
type Store ¶
type Store struct { Ident roachpb.StoreIdent // contains filtered or unexported fields }
A Store maintains a map of ranges by start key. A Store corresponds to one physical device.
func NewStore ¶
func NewStore(cfg StoreConfig, eng engine.Engine, nodeDesc *roachpb.NodeDescriptor) *Store
NewStore returns a new instance of a store.
func (*Store) AcquireRaftSnapshot ¶
AcquireRaftSnapshot returns true if a new raft snapshot can start. If true is returned, the caller MUST call ReleaseRaftSnapshot.
func (*Store) AnnotateCtx ¶
AnnotateCtx is a convenience wrapper; see AmbientContext.
func (*Store) AnnotateCtxWithSpan ¶
func (s *Store) AnnotateCtxWithSpan( ctx context.Context, opName string, ) (context.Context, opentracing.Span)
AnnotateCtxWithSpan is a convenience wrapper; see AmbientContext.
func (*Store) Attrs ¶
func (s *Store) Attrs() roachpb.Attributes
Attrs returns the attributes of the underlying store.
func (*Store) Bootstrap ¶
func (s *Store) Bootstrap(ident roachpb.StoreIdent) error
Bootstrap writes a new store ident to the underlying engine. To ensure that no crufty data already exists in the engine, it scans the engine contents before writing the new store ident. The engine should be completely empty. It returns an error if called on a non-empty engine.
func (*Store) BootstrapRange ¶
BootstrapRange creates the first range in the cluster and manually writes it to the store. Default range addressing records are created for meta1 and meta2. Default configurations for zones are created. All configs are specified for the empty key prefix, meaning they apply to the entire database. The zone requires three replicas with no other specifications. It also adds the range tree and the root node, the first range, to it. The 'initialValues' are written as well after each value's checksum is initialized.
func (*Store) Capacity ¶
func (s *Store) Capacity() (roachpb.StoreCapacity, error)
Capacity returns the capacity of the underlying storage engine. Note that this does not include reservations.
func (*Store) ComputeMetrics ¶
ComputeMetrics immediately computes the current value of store metrics which cannot be computed incrementally. This method should be invoked periodically by a higher-level system which records store metrics.
func (*Store) ComputeStatsForKeySpan ¶
ComputeStatsForKeySpan computes the aggregated MVCCStats for all replicas on this store which contain any keys in the supplied range.
func (*Store) Descriptor ¶
func (s *Store) Descriptor() (*roachpb.StoreDescriptor, error)
Descriptor returns a StoreDescriptor including current store capacity information.
func (*Store) DrainLeases ¶
DrainLeases (when called with 'true') prevents all of the Store's Replicas from acquiring or extending range leases and waits until all of them have expired. If an error is returned, the draining state is still active, but there may be active leases held by some of the Store's Replicas. When called with 'false', returns to the normal mode of operation.
func (*Store) FrozenStatus ¶
func (s *Store) FrozenStatus(collectFrozen bool) (repDescs []roachpb.ReplicaDescriptor)
FrozenStatus returns all of the Store's Replicas which are frozen (if the parameter is true) or unfrozen (otherwise). It makes no attempt to prevent new data being rebalanced to the Store, and thus does not guarantee that the Store remains in the reported state.
func (*Store) GetReplica ¶
GetReplica fetches a replica by Range ID. Returns an error if no replica is found.
func (*Store) GossipDeadReplicas ¶
GossipDeadReplicas broadcasts the stores dead replicas on the gossip network.
func (*Store) GossipStore ¶
GossipStore broadcasts the store on the gossip network.
func (*Store) HandleRaftRequest ¶
func (s *Store) HandleRaftRequest( ctx context.Context, req *RaftMessageRequest, respStream RaftMessageResponseStream, ) *roachpb.Error
HandleRaftRequest dispatches a raft message to the appropriate Replica. It requires that s.mu is not held.
func (*Store) HandleRaftResponse ¶
func (s *Store) HandleRaftResponse(ctx context.Context, resp *RaftMessageResponse) error
HandleRaftResponse implements the RaftMessageHandler interface. It requires that s.mu is not held.
func (*Store) HandleRaftUncoalescedRequest ¶
func (s *Store) HandleRaftUncoalescedRequest( ctx context.Context, req *RaftMessageRequest, respStream RaftMessageResponseStream, ) *roachpb.Error
HandleRaftUncoalescedRequest dispatches a raft message to the appropriate Replica. It requires that s.mu is not held.
func (*Store) HandleSnapshot ¶
func (s *Store) HandleSnapshot(header *SnapshotRequest_Header, stream SnapshotResponseStream) error
HandleSnapshot reads an incoming streaming snapshot and applies it if possible.
func (*Store) LeaseCount ¶
LeaseCount returns the number of replicas this store holds leases for.
func (*Store) LookupReplica ¶
LookupReplica looks up a replica via binary search over the "replicasByKey" btree. Returns nil if no replica is found for specified key range. Note that the specified keys are transformed using Key.Address() to ensure we lookup replicas correctly for local keys. When end is nil, a replica that contains start is looked up.
func (*Store) MVCCStats ¶
MVCCStats returns the current MVCCStats accumulated for this store. TODO(mrtracy): This should be removed as part of #4465, this is only needed to support the current StatusSummary structures which will be changing.
func (*Store) MergeRange ¶
func (s *Store) MergeRange( ctx context.Context, subsumingRng *Replica, updatedEndKey roachpb.RKey, subsumedRangeID roachpb.RangeID, ) error
MergeRange expands the subsuming range to absorb the subsumed range. This merge operation will fail if the two ranges are not collocated on the same store. The subsumed range's raftMu is assumed held.
func (*Store) Metrics ¶
func (s *Store) Metrics() *StoreMetrics
Metrics returns the store's metric struct.
func (*Store) NewRangeDescriptor ¶
func (s *Store) NewRangeDescriptor( start, end roachpb.RKey, replicas []roachpb.ReplicaDescriptor, ) (*roachpb.RangeDescriptor, error)
NewRangeDescriptor creates a new descriptor based on start and end keys and the supplied roachpb.Replicas slice. It allocates a new range ID and returns a RangeDescriptor whose Replicas are a copy of the supplied replicas slice, with appropriate ReplicaIDs assigned.
func (*Store) NewSnapshot ¶
NewSnapshot creates a new snapshot engine.
func (*Store) NotifyBootstrapped ¶
func (s *Store) NotifyBootstrapped()
NotifyBootstrapped tells the store that it was bootstrapped and allows idle replicas to campaign immediately. This primarily affects tests.
func (*Store) RaftStatus ¶
RaftStatus returns the current raft status of the local replica of the given range.
func (*Store) ReleaseRaftSnapshot ¶
func (s *Store) ReleaseRaftSnapshot()
ReleaseRaftSnapshot decrements the count of active snapshots.
func (*Store) RemoveReplica ¶
RemoveReplica removes the replica from the store's replica map and from the sorted replicasByKey btree. The version of the replica descriptor that was used to make the removal decision is passed in, and the removal is aborted if the replica ID has changed since then. If `destroy` is true, all data belonging to the replica will be deleted. In either case a tombstone record will be written.
func (*Store) ReplicaCount ¶
ReplicaCount returns the number of replicas contained by this store.
func (*Store) Send ¶
func (s *Store) Send( ctx context.Context, ba roachpb.BatchRequest, ) (br *roachpb.BatchResponse, pErr *roachpb.Error)
Send fetches a range based on the header's replica, assembles method, args & reply into a Raft Cmd struct and executes the command using the fetched range. An incoming request may be transactional or not. If it is not transactional, the timestamp at which it executes may be higher than that optionally specified through the incoming BatchRequest, and it is not guaranteed that all operations are written at the same timestamp. If it is transactional, a timestamp must not be set - it is deduced automatically from the transaction. In particular, the read (original) timestamp will be used for all reads _and writes_ (see the TxnMeta.OrigTimestamp for details).
Should a transactional operation be forced to a higher timestamp (for instance due to the timestamp cache or finding a committed value in the path of one of its writes), the response will have a transaction set which should be used to update the client transaction.
func (*Store) SplitRange ¶
SplitRange shortens the original range to accommodate the new range. The new range is added to the ranges map and the replicasByKey btree. origRng.raftMu and newRng.raftMu must be held.
This is only called from the split trigger in the context of the execution of a Raft command.
func (*Store) TestingKnobs ¶
func (s *Store) TestingKnobs() *StoreTestingKnobs
TestingKnobs accessor.
func (*Store) WaitForInit ¶
func (s *Store) WaitForInit()
WaitForInit waits for any asynchronous processes begun in Start() to complete their initialization. In particular, this includes gossiping. In some cases this may block until the range GC queue has completed its scan. Only for testing.
type StoreConfig ¶
type StoreConfig struct { AmbientCtx log.AmbientContext Clock *hlc.Clock DB *client.DB Gossip *gossip.Gossip NodeLiveness *NodeLiveness StorePool *StorePool Transport *RaftTransport // SQLExecutor is used by the store to execute SQL statements in a way that // is more direct than using a sql.Executor. SQLExecutor sqlutil.InternalExecutor // TimeSeriesDataStore is an interface used by the store's time series // maintenance queue to dispatch individual maintenance tasks. TimeSeriesDataStore TimeSeriesDataStore // RangeRetryOptions are the retry options when retryable errors are // encountered sending commands to ranges. RangeRetryOptions retry.Options // RaftTickInterval is the resolution of the Raft timer; other raft timeouts // are defined in terms of multiples of this value. RaftTickInterval time.Duration // CoalescedHeartbeatsInterval is the interval for which heartbeat messages // are queued and then sent as a single coalesced heartbeat; it is a // fraction of the RaftTickInterval so that heartbeats don't get delayed by // an entire tick. Delaying coalescing heartbeat responses has a bad // interaction with quiescence because the coalesced (delayed) heartbeat // response can unquiesce the leader. Consider: // // T+0: leader queues MsgHeartbeat // T+1: leader sends MsgHeartbeat // follower receives MsgHeartbeat // follower queues MsgHeartbeatResp // T+2: leader queues quiesce message // follower sends MsgHeartbeatResp // leader receives MsgHeartbeatResp // T+3: leader sends quiesce message // // Thus we want to make sure that heartbeats are responded to faster than // the quiesce cadence. CoalescedHeartbeatsInterval time.Duration // RaftHeartbeatIntervalTicks is the number of ticks that pass between heartbeats. RaftHeartbeatIntervalTicks int // RaftElectionTimeoutTicks is the number of ticks that must pass before a follower // considers a leader to have failed and calls a new election. Should be significantly // higher than RaftHeartbeatIntervalTicks. The raft paper recommends a value of 150ms // for local networks. RaftElectionTimeoutTicks int // ScanInterval is the default value for the scan interval ScanInterval time.Duration // ScanMaxIdleTime is the maximum time the scanner will be idle between ranges. // If enabled (> 0), the scanner may complete in less than ScanInterval for small // stores. ScanMaxIdleTime time.Duration // ConsistencyCheckInterval is the default time period in between consecutive // consistency checks on a range. ConsistencyCheckInterval time.Duration // ConsistencyCheckPanicOnFailure causes the node to panic when it detects a // replication consistency check failure. ConsistencyCheckPanicOnFailure bool // AllocatorOptions configures how the store will attempt to rebalance its // replicas to other stores. AllocatorOptions AllocatorOptions // If LogRangeEvents is true, major changes to ranges will be logged into // the range event log. LogRangeEvents bool // AsyncSnapshotMaxAge is the maximum amount of time that an // asynchronous snapshot will be held while waiting for raft to pick // it up (counted from when the snapshot generation is completed). AsyncSnapshotMaxAge time.Duration // RaftEntryCacheSize is the size in bytes of the Raft log entry cache // shared by all Raft groups managed by the store. RaftEntryCacheSize uint64 TestingKnobs StoreTestingKnobs // RangeLeaseActiveDuration is the duration of the active period of leader // leases requested. RangeLeaseActiveDuration time.Duration // RangeLeaseRenewalDuration specifies a time interval at the end of the // active lease interval (i.e. bounded to the right by the start of the stasis // period) during which operations will trigger an asynchronous renewal of the // lease. RangeLeaseRenewalDuration time.Duration // MetricsSampleInterval is (server.Context).MetricsSampleInterval MetricsSampleInterval time.Duration // EnableCoalescedHeartbeats controls whether heartbeats are coalesced. EnableCoalescedHeartbeats bool }
A StoreConfig encompasses the auxiliary objects and configuration required to create a store. All fields holding a pointer or an interface are required to create a store; the rest will have sane defaults set if omitted.
func TestStoreConfig ¶
func TestStoreConfig(clock *hlc.Clock) StoreConfig
TestStoreConfig has some fields initialized with values relevant in tests.
func (*StoreConfig) SetDefaults ¶
func (sc *StoreConfig) SetDefaults()
SetDefaults initializes unset fields in StoreConfig to values suitable for use on a local network. TODO(tschottdorf) see if this ought to be configurable via flags.
func (*StoreConfig) Valid ¶
func (sc *StoreConfig) Valid() bool
Valid returns true if the StoreConfig is populated correctly. We don't check for Gossip and DB since some of our tests pass that as nil.
type StoreList ¶
type StoreList struct {
// contains filtered or unexported fields
}
StoreList holds a list of store descriptors and associated count and used stats for those stores.
type StoreMetrics ¶
type StoreMetrics struct { // Replica metrics. ReplicaCount *metric.Counter // Does not include reserved replicas. ReservedReplicaCount *metric.Counter RaftLeaderCount *metric.Gauge RaftLeaderNotLeaseHolderCount *metric.Gauge LeaseHolderCount *metric.Gauge QuiescentCount *metric.Gauge // Replica CommandQueue metrics. MaxCommandQueueSize *metric.Gauge MaxCommandQueueWriteCount *metric.Gauge MaxCommandQueueReadCount *metric.Gauge MaxCommandQueueTreeSize *metric.Gauge MaxCommandQueueOverlaps *metric.Gauge CombinedCommandQueueSize *metric.Gauge CombinedCommandWriteCount *metric.Gauge CombinedCommandReadCount *metric.Gauge // Range metrics. AvailableRangeCount *metric.Gauge // Replication metrics. ReplicaAllocatorNoopCount *metric.Gauge ReplicaAllocatorRemoveCount *metric.Gauge ReplicaAllocatorAddCount *metric.Gauge ReplicaAllocatorRemoveDeadCount *metric.Gauge // Lease request metrics for successful and failed lease requests. These // count proposals (i.e. it does not matter how many Replicas apply the // lease). LeaseRequestSuccessCount *metric.Counter LeaseRequestErrorCount *metric.Counter // Storage metrics. LiveBytes *metric.Gauge KeyBytes *metric.Gauge ValBytes *metric.Gauge IntentBytes *metric.Gauge LiveCount *metric.Gauge KeyCount *metric.Gauge ValCount *metric.Gauge IntentCount *metric.Gauge IntentAge *metric.Gauge GcBytesAge *metric.Gauge LastUpdateNanos *metric.Gauge Capacity *metric.Gauge Available *metric.Gauge Reserved *metric.Counter SysBytes *metric.Gauge SysCount *metric.Gauge // RocksDB metrics. RdbBlockCacheHits *metric.Gauge RdbBlockCacheMisses *metric.Gauge RdbBlockCacheUsage *metric.Gauge RdbBlockCachePinnedUsage *metric.Gauge RdbBloomFilterPrefixChecked *metric.Gauge RdbBloomFilterPrefixUseful *metric.Gauge RdbMemtableHits *metric.Gauge RdbMemtableMisses *metric.Gauge RdbMemtableTotalSize *metric.Gauge RdbFlushes *metric.Gauge RdbCompactions *metric.Gauge RdbTableReadersMemEstimate *metric.Gauge RdbReadAmplification *metric.Gauge RdbNumSSTables *metric.Gauge // Range event metrics. RangeSplits *metric.Counter RangeAdds *metric.Counter RangeRemoves *metric.Counter RangeSnapshotsGenerated *metric.Counter RangeSnapshotsNormalApplied *metric.Counter RangeSnapshotsPreemptiveApplied *metric.Counter // Raft processing metrics. RaftTicks *metric.Counter RaftWorkingDurationNanos *metric.Counter RaftTickingDurationNanos *metric.Counter // Raft message metrics. RaftRcvdMsgProp *metric.Counter RaftRcvdMsgApp *metric.Counter RaftRcvdMsgAppResp *metric.Counter RaftRcvdMsgVote *metric.Counter RaftRcvdMsgVoteResp *metric.Counter RaftRcvdMsgPreVote *metric.Counter RaftRcvdMsgPreVoteResp *metric.Counter RaftRcvdMsgSnap *metric.Counter RaftRcvdMsgHeartbeat *metric.Counter RaftRcvdMsgHeartbeatResp *metric.Counter RaftRcvdMsgTransferLeader *metric.Counter RaftRcvdMsgTimeoutNow *metric.Counter RaftRcvdMsgDropped *metric.Counter RaftEnqueuedPending *metric.Gauge RaftCoalescedHeartbeatsPending *metric.Gauge // Replica queue metrics. GCQueueSuccesses *metric.Counter GCQueueFailures *metric.Counter GCQueuePending *metric.Gauge GCQueueProcessingNanos *metric.Counter RaftLogQueueSuccesses *metric.Counter RaftLogQueueFailures *metric.Counter RaftLogQueuePending *metric.Gauge RaftLogQueueProcessingNanos *metric.Counter ConsistencyQueueSuccesses *metric.Counter ConsistencyQueueFailures *metric.Counter ConsistencyQueuePending *metric.Gauge ConsistencyQueueProcessingNanos *metric.Counter ReplicaGCQueueSuccesses *metric.Counter ReplicaGCQueueFailures *metric.Counter ReplicaGCQueuePending *metric.Gauge ReplicaGCQueueProcessingNanos *metric.Counter ReplicateQueueSuccesses *metric.Counter ReplicateQueueFailures *metric.Counter ReplicateQueuePending *metric.Gauge ReplicateQueueProcessingNanos *metric.Counter ReplicateQueuePurgatory *metric.Gauge SplitQueueSuccesses *metric.Counter SplitQueueFailures *metric.Counter SplitQueuePending *metric.Gauge SplitQueueProcessingNanos *metric.Counter TimeSeriesMaintenanceQueueSuccesses *metric.Counter TimeSeriesMaintenanceQueueFailures *metric.Counter TimeSeriesMaintenanceQueuePending *metric.Gauge TimeSeriesMaintenanceQueueProcessingNanos *metric.Counter // GCInfo cumulative totals. GCNumKeysAffected *metric.Counter GCIntentsConsidered *metric.Counter GCIntentTxns *metric.Counter GCTransactionSpanScanned *metric.Counter GCTransactionSpanGCAborted *metric.Counter GCTransactionSpanGCCommitted *metric.Counter GCTransactionSpanGCPending *metric.Counter GCAbortSpanScanned *metric.Counter GCAbortSpanConsidered *metric.Counter GCAbortSpanGCNum *metric.Counter GCPushTxn *metric.Counter GCResolveTotal *metric.Counter GCResolveSuccess *metric.Counter // Mutex timing information. MuStoreNanos *metric.Histogram MuSchedulerNanos *metric.Histogram MuRaftNanos *metric.Histogram MuReplicaNanos *metric.Histogram MuCommandQueueNanos *metric.Histogram // contains filtered or unexported fields }
StoreMetrics is the set of metrics for a given store.
type StorePool ¶
type StorePool struct { log.AmbientContext // contains filtered or unexported fields }
StorePool maintains a list of all known stores in the cluster and information on their health.
func NewStorePool ¶
func NewStorePool( ambient log.AmbientContext, g *gossip.Gossip, clock *hlc.Clock, rpcContext *rpc.Context, timeUntilStoreDead time.Duration, stopper *stop.Stopper, deterministic bool, ) *StorePool
NewStorePool creates a StorePool and registers the store updating callback with gossip.
type StoreRequestHeader ¶
type StoreRequestHeader struct { NodeID github_com_cockroachdb_cockroach_pkg_roachpb.NodeID `` /* 141-byte string literal not displayed */ StoreID github_com_cockroachdb_cockroach_pkg_roachpb.StoreID `` /* 145-byte string literal not displayed */ }
StoreRequestHeader locates a Store on a Node.
func (*StoreRequestHeader) Descriptor ¶
func (*StoreRequestHeader) Descriptor() ([]byte, []int)
func (*StoreRequestHeader) Marshal ¶
func (m *StoreRequestHeader) Marshal() (dAtA []byte, err error)
func (*StoreRequestHeader) MarshalTo ¶
func (m *StoreRequestHeader) MarshalTo(dAtA []byte) (int, error)
func (*StoreRequestHeader) ProtoMessage ¶
func (*StoreRequestHeader) ProtoMessage()
func (*StoreRequestHeader) Reset ¶
func (m *StoreRequestHeader) Reset()
func (*StoreRequestHeader) Size ¶
func (m *StoreRequestHeader) Size() (n int)
func (*StoreRequestHeader) String ¶
func (m *StoreRequestHeader) String() string
func (*StoreRequestHeader) Unmarshal ¶
func (m *StoreRequestHeader) Unmarshal(dAtA []byte) error
type StoreTestingKnobs ¶
type StoreTestingKnobs struct { // A callback to be called when executing every replica command. // If your filter is not idempotent, consider wrapping it in a // ReplayProtectionFilterWrapper. TestingCommandFilter storagebase.ReplicaCommandFilter TestingApplyFilter storagebase.ReplicaApplyFilter // TestingResponseFilter is called after the replica processes a // command in order for unittests to modify the batch response, // error returned to the client, or to simulate network failures. TestingResponseFilter storagebase.ReplicaResponseFilter // If non-nil, BadChecksumPanic is called by CheckConsistency() instead of // panicking on a checksum mismatch. BadChecksumPanic func(roachpb.StoreIdent) // If non-nil, BadChecksumReportDiff is called by CheckConsistency() on a // checksum mismatch to report the diff between snapshots. BadChecksumReportDiff func(roachpb.StoreIdent, []ReplicaSnapshotDiff) // Disables the use of one phase commits. DisableOnePhaseCommits bool // A hack to manipulate the clock before sending a batch request to a replica. // TODO(kaneda): This hook is not encouraged to use. Get rid of it once // we make TestServer take a ManualClock. ClockBeforeSend func(*hlc.Clock, roachpb.BatchRequest) // MaxOffset, if set, overrides the server clock's MaxOffset at server // creation time. // See also DisableMaxOffsetCheck. MaxOffset time.Duration // DisableMaxOffsetCheck disables the rejection (in Store.Send) of requests // with the timestamp too much in the future. Normally, this rejection is a // good sanity check, but certain tests unfortunately insert a "message from // the future" into the system to advance the clock of a TestServer. We // should get rid of such practices once we make TestServer take a // ManualClock. DisableMaxOffsetCheck bool // DontPreventUseOfOldLeaseOnStart disables the initialization of // replica.mu.minLeaseProposedTS on replica.Init(). This has the effect of // allowing the replica to use the lease that it had in a previous life (in // case the tests persisted the engine used in said previous life). DontPreventUseOfOldLeaseOnStart bool // LeaseRequestEvent, if set, is called when replica.requestLeaseLocked() is // called to acquire a new lease. This can be used to assert that a request // triggers a lease acquisition. LeaseRequestEvent func(ts hlc.Timestamp) // LeaseTransferBlockedOnExtensionEvent, if set, is called when // replica.TransferLease() encounters an in-progress lease extension. // nextLeader is the replica that we're trying to transfer the lease to. LeaseTransferBlockedOnExtensionEvent func(nextLeader roachpb.ReplicaDescriptor) // DisableReplicaGCQueue disables the replication queue. DisableReplicaGCQueue bool // DisableReplicateQueue disables the replication queue. DisableReplicateQueue bool // DisableSplitQueue disables the split queue. DisableSplitQueue bool // DisableScanner disables the replica scanner. DisableScanner bool // DisablePeriodicGossips disables periodic gossiping. DisablePeriodicGossips bool // DisableRefreshReasonTicks disables refreshing pending commands when a new // leader is discovered. DisableRefreshReasonNewLeader bool // DisableRefreshReasonTicks disables refreshing pending commands when a // snapshot is applied. DisableRefreshReasonSnapshotApplied bool // DisableRefreshReasonTicks disables refreshing pending commands // periodically. DisableRefreshReasonTicks bool // DisableProcessRaft disables the process raft loop. DisableProcessRaft bool // ReplicateQueueAcceptsUnsplit allows the replication queue to // process ranges that need to be split, for use in tests that use // the replication queue but disable the split queue. ReplicateQueueAcceptsUnsplit bool // NumKeysEvaluatedForRangeIntentResolution is set by the stores to the // number of keys evaluated for range intent resolution. NumKeysEvaluatedForRangeIntentResolution *int64 // SkipMinSizeCheck, if set, makes the store creation process skip the check // for a minimum size. SkipMinSizeCheck bool }
StoreTestingKnobs is a part of the context used to control parts of the system.
func (*StoreTestingKnobs) ModuleTestingKnobs ¶
func (*StoreTestingKnobs) ModuleTestingKnobs()
ModuleTestingKnobs is part of the base.ModuleTestingKnobs interface.
type Stores ¶
type Stores struct { log.AmbientContext // contains filtered or unexported fields }
A Stores provides methods to access a collection of stores. There's a visitor pattern and also an implementation of the client.Sender interface which directs a call to the appropriate store based on the call's key range. Stores also implements the gossip.Storage interface, which allows gossip bootstrap information to be persisted consistently to every store and the most recent bootstrap information to be read at node startup.
func NewStores ¶
func NewStores(ambient log.AmbientContext, clock *hlc.Clock) *Stores
NewStores returns a local-only sender which directly accesses a collection of stores.
func (*Stores) FirstRange ¶
func (ls *Stores) FirstRange() (*roachpb.RangeDescriptor, error)
FirstRange implements the RangeDescriptorDB interface. It returns the range descriptor which contains KeyMin.
func (*Stores) GetStoreCount ¶
GetStoreCount returns the number of stores this node is exporting.
func (*Stores) LookupReplica ¶
func (ls *Stores) LookupReplica( start, end roachpb.RKey, ) (roachpb.RangeID, roachpb.ReplicaDescriptor, error)
LookupReplica looks up replica by key [range]. Lookups are done by consulting each store in turn via Store.LookupReplica(key). Returns RangeID and replica on success; RangeKeyMismatch error if not found. If end is nil, a replica containing start is looked up. This is only for testing usage; performance doesn't matter.
func (*Stores) ReadBootstrapInfo ¶
func (ls *Stores) ReadBootstrapInfo(bi *gossip.BootstrapInfo) error
ReadBootstrapInfo implements the gossip.Storage interface. Read attempts to read gossip bootstrap info from every known store and finds the most recent from all stores to initialize the bootstrap info argument. Returns an error on any issues reading data for the stores (but excluding the case in which no data has been persisted yet).
func (*Stores) RemoveStore ¶
RemoveStore removes the specified store from the store map.
func (*Stores) Send ¶
func (ls *Stores) Send( ctx context.Context, ba roachpb.BatchRequest, ) (*roachpb.BatchResponse, *roachpb.Error)
Send implements the client.Sender interface. The store is looked up from the store map if specified by the request; otherwise, the command is being executed locally, and the replica is determined via lookup through each store's LookupRange method. The latter path is taken only by unit tests.
func (*Stores) VisitStores ¶
VisitStores implements a visitor pattern over stores in the storeMap. The specified function is invoked with each store in turn. Care is taken to invoke the visitor func without the lock held to avoid inconsistent lock orderings, as some visitor functions may call back into the Stores object. Stores are visited in random order.
func (*Stores) WriteBootstrapInfo ¶
func (ls *Stores) WriteBootstrapInfo(bi *gossip.BootstrapInfo) error
WriteBootstrapInfo implements the gossip.Storage interface. Write persists the supplied bootstrap info to every known store. Returns nil on success; otherwise returns first error encountered writing to the stores.
type TimeSeriesDataStore ¶
type TimeSeriesDataStore interface { ContainsTimeSeries(roachpb.RKey, roachpb.RKey) bool PruneTimeSeries( context.Context, engine.Reader, roachpb.RKey, roachpb.RKey, *client.DB, hlc.Timestamp, ) error }
TimeSeriesDataStore is an interface defined in the storage package that can be implemented by the higher-level time series system. This allows the storage queues to run periodic time series maintenance; importantly, this maintenance can then be informed by data from the local store.
Source Files ¶
- abort_cache.go
- addressing.go
- allocator.go
- api.pb.go
- balancer.go
- command_queue.go
- doc.go
- entry_cache.go
- gc_queue.go
- id_alloc.go
- intent_resolver.go
- liveness.pb.go
- log.go
- metrics.go
- migration.go
- node_liveness.go
- queue.go
- raft.go
- raft.pb.go
- raft_log_queue.go
- raft_transport.go
- refreshraftreason_string.go
- replica.go
- replica_command.go
- replica_consistency_queue.go
- replica_data_iter.go
- replica_gc_queue.go
- replica_placeholder.go
- replica_proposal.go
- replica_raftstorage.go
- replica_range_lease.go
- replica_state.go
- replicate_queue.go
- reservation.go
- rule_solver.go
- scanner.go
- scheduler.go
- split_queue.go
- stats.go
- store.go
- store_pool.go
- stores.go
- stores_server.go
- timestamp_cache.go
- track_raft_protos.go
- ts_maintenance_queue.go
Directories ¶
Path | Synopsis |
---|---|
Package engine provides low-level storage.
|
Package engine provides low-level storage. |
enginepb
Package enginepb is a generated protocol buffer package.
|
Package enginepb is a generated protocol buffer package. |
Package storagebase is a generated protocol buffer package.
|
Package storagebase is a generated protocol buffer package. |