github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/docs/RFCS/20150729_bounds_generation.md (about) 1 - Feature Name: bounds_generation 2 - Status: rejected 3 - Start Date: 2015-07-29 4 - RFC PR: [#1867](https://github.com/cockroachdb/cockroach/pull/1867) 5 - Cockroach Issue: [#1644](https://github.com/cockroachdb/cockroach/issues/1644) 6 7 # Rejection notes 8 9 This RFC supplements #1866, which was rejected. 10 11 # Summary 12 13 Add a **bounds generation number** to all range descriptors, and use 14 it to maintain consistency of the store's `replicasByKey` map. 15 16 # Motivation 17 18 One of the issues in 19 [#1644](https://github.com/cockroachdb/cockroach/issues/1644) is that 20 a replica may be created in response to a raft message before the 21 split that created the range has been processed, leading to conflicts 22 in the `Store.replicasByKey` map. 23 24 # Detailed design 25 26 Add a field `bounds_generation` to `RangeDescriptor`. This value is 27 incremented whenever the bounds of the range change. On a split, the 28 `bounds_generation` of each post-split range is one plus the pre-split 29 `bounds_generation`. On a merge, the `bounds_generation` of the 30 post-merge range is one plus the maximum of the two pre-merge ranges' 31 values. 32 33 In `Store.addRangeInternal`, when we add the range to `replicasByKey`, 34 we first test for an overlapping range. If we find one, we compare 35 bounds generations: the range with the lower bounds generation has its 36 effective bounds reduced to eliminate the conflict. 37 38 When this happens, the range whose bounds have been reduced will stop 39 receiving KV requests for the affected portion of the keyspace. It 40 will, however, continue to receive raft messages, which are routed by 41 ID instead of by key. This will allow the replica to catch up and 42 process the split transaction that allowed the new range with a higher bounds generation to come into existence (or the replica has been removed and will eventually be garbage-collected). 43 44 # Drawbacks 45 46 # Alternatives 47 48 # Unresolved questions