Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raftstore: support consistency check #1344

Merged
merged 10 commits into from
Nov 29, 2016
Merged

Conversation

BusyJay
Copy link
Member

@BusyJay BusyJay commented Nov 23, 2016

@BusyJay BusyJay force-pushed the busyjay/consistency-check branch from f3105d7 to f9646e1 Compare November 25, 2016 08:26
@BusyJay
Copy link
Member Author

BusyJay commented Nov 25, 2016

PTAL

@BusyJay
Copy link
Member Author

BusyJay commented Nov 28, 2016

ping

pub static ref REGION_HASH_COUNTER_VEC: CounterVec =
register_counter_vec!(
"tikv_raftstore_hash_total",
"Total number of raftstore has computing.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has been computing

@@ -165,6 +171,13 @@ fn notify_region_removed(region_id: u64, peer_id: u64, mut cmd: PendingCmd) {
cmd.call(resp);
}

pub struct ConsistencyState {
pub last_check_time: Instant,
// (computed_result_or_to_be_revified, index, hash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's revified, typo?

return;
}

if state.index == expected_index {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can extract a function for both here and L1706.

state.index = index;
state.hash = hash;

let mut request = RaftCmdRequest::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not using a new_verify_hash_request like new_compute_hash_request below?

timer.observe_duration();

let mut checksum = Vec::with_capacity(4);
checksum.write_u32::<BigEndian>(sum).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seem that we use CRC32 for checksum, no need to use Sha1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, to reduce the overhead.

@siddontang
Copy link
Contributor

Rest LGTM

@siddontang
Copy link
Contributor

@disksing

We should add MVCC verify later.

@@ -99,6 +102,9 @@ pub struct Config {
pub max_leader_missing_duration: Duration,

pub snap_apply_batch_size: usize,

// Interval (s) to check region whether the data are consistent.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the data s/are/is/

pub static ref REGION_HASH_COUNTER_VEC: CounterVec =
register_counter_vec!(
"tikv_raftstore_hash_total",
"Total number of raftstore has computed.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total number of hash ...?

leader_lease_expired_time: Option<Timespec>,
leader_missing_time: Option<Instant>,
Copy link
Contributor

@hhkbp2 hhkbp2 Nov 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The related fields should be grouped together, such as leader_lease_expired_time and election_timeout.

Some(ExecResult::ComputeHash {
region: self.region().clone(),
index: ctx.index,
// This snapshot may be hold for a long time, which may cause too many
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/hold/held/

escape(&state.hash));
}
REGION_HASH_COUNTER_VEC.with_label_values(&["verify", "matched"]).inc();
state.hash = vec![];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be clearer to set and reset state.index and state.hash together every time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state.index does not need to be updated here.

@hhkbp2
Copy link
Contributor

hhkbp2 commented Nov 29, 2016

Rest LGTM

@siddontang
Copy link
Contributor

LGTM

@BusyJay BusyJay changed the title [DNM] raftstore: support consistency check raftstore: support consistency check Nov 29, 2016
@BusyJay BusyJay merged commit 567a636 into master Nov 29, 2016
@BusyJay BusyJay deleted the busyjay/consistency-check branch November 29, 2016 06:20
mittalrishabh pushed a commit to mittalrishabh/tikv that referenced this pull request Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants