-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Question about TestRegionAddBackPeers3C and TestRegionRemovePeers3C #472
Description
In both of the mentioned tests, the peers field in the Region metadata is modified through the following code, but the RegionEpoch is not updated accordingly:
region = region.Clone(core.SetPeers(region.GetPeers()[:1]))
regions[i] = region
c.Assert(cluster.processRegionHeartbeat(region), IsNil)
checkRegions(c, cluster.core.Regions, regions)The tests then check whether the Region heartbeat handling logic correctly updates the Region information.
However, based on my understanding of the project, any update to Region metadata should be accompanied by a corresponding update to RegionEpoch. In other words, there seems to be an invariant like this:
For two Regions with the same
RegionEpoch, their membership information (peers) and key range boundaries (startKey,endKey) should also be identical.
In this test scenario, the peers have changed while the RegionEpoch remains unchanged. As a result, when processing the Region heartbeat, the Region is not recognized as having been updated, which eventually causes the test to fail.
So I would like to clarify the following:
- Are these two tests constructed in a reasonable way?
- In the TiKV/PD design, is it valid to modify a Region’s membership information without updating its
RegionEpoch? - More generally, is it an intended assumption that changes to
peers,startKey, orendKeymust always be reflected inRegionEpoch?