Skip to content

Question about TestRegionAddBackPeers3C and TestRegionRemovePeers3C #472

@iwantsomememories

Description

@iwantsomememories

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:

  1. Are these two tests constructed in a reasonable way?
  2. In the TiKV/PD design, is it valid to modify a Region’s membership information without updating its RegionEpoch?
  3. More generally, is it an intended assumption that changes to peers, startKey, or endKey must always be reflected in RegionEpoch?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions