Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

feat(split): replica add validate_partition_hash #747

Merged
merged 4 commits into from
Feb 7, 2021

Conversation

hycdong
Copy link
Contributor

@hycdong hycdong commented Feb 2, 2021

As pr #745 shows, we adds an app_env called SPLIT_VALIDATE_PARTITION_HASH, when partition split started, it will be set as true, this pr adds how replica handle it, including:

  1. In function update_app_envs_internal, update replica's _validate_partition_hash value
  2. In function on_client_read and on_client_write, check if reject all requests
    As previous pr feat(split): register child partition #391 shows, when parent partition is registering child partition, requests should be rejected during this stage (partition_version = -1)
  3. In function on_client_read and on_client_write, check if read from correct partition, write into correct partition
    As previous pr feat(split): add partition_version #394 shows, we adds partition_version to do this check, partition_version valid value is partition_count - 1. Let me take an example to explain the check:

Before split:
partition_count = 8, partition_version = 7, parent_partition = 1
case1. write request partition_hash = 1, target_partition_index = (1 & 7) = 1
case2. write request partition_hash = 9, target_partition_index = (9 & 7) = 1

When partition split finishs, the request whose partition_hash is 9 should not sent to parent partition, its should be sent to write to the child partition.

After split:
partition_count = 16, partition_version = 15, parent_partition = 1
case1. write request partition_hash = 1, target_partition_index = (1 & 15) = 1
case2. write request partition_hash = 9, target_partition_index = (9 & 15) = 9 -> should sent to child

When client receives error ERR_PARENT_PARTITION_MISUSED, it should trigger query_meta to let client learned the newest partition_count, this will be added in client.

src/replica/replica.cpp Outdated Show resolved Hide resolved
acelyc111
acelyc111 previously approved these changes Feb 4, 2021
src/replica/replica.cpp Outdated Show resolved Hide resolved
@acelyc111 acelyc111 merged commit 447155a into XiaoMi:master Feb 7, 2021
@hycdong hycdong deleted the replica_validate_partition_hash branch February 7, 2021 08:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants