-
Notifications
You must be signed in to change notification settings - Fork 473
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
Use checkpoint to implement data snapshot when full replication #205
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good implementation! LGTM except Fail
=> Failed
in error message.
Another potential optimization was in GetFullReplDataInfo
when multi-slaves were in full sync at the same time.
For example:
A slave comes at first and creating the checkpoint, then B slave follows closely, it would get an error if the new checkpoint was creating. The way to fix was by waiting for the new checkpoint to finish.
lock();
if (!sync_dir.IsExists() || checkpoint.Expired()) {
CreateCheckpoint();
}
unlock();
if (checkpoint.Expired()) {
return error;
}
Get Replication Data Info
But the current implementation was fine to me that B slave would restart full sync again.
Co-authored-by: hulk <hulk.website@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, cheers!!!
Motivation
Currently, master creates a new snapshot by
backup
function of rocksdb when replicas ask for full replication. Although, rocksdbbackup
function can support incremental backup, it still cost much time, disk bandwidth, and disk space if there is no based backup or current backup exists for long time, andbackup
function really needs copy real files. If kvrocks holds a huge amount of data, copying data files would influence the writing or reading of rocksdb that results in latency of user request.As we know, the function
checkpoint
of rocksdb would hard link data files instead of copying files, that has minor resource consumption, so we wish using checkpoint to implement data snapshot when full replication to avoid influencing user requests.Solution
Master
Replica
Compatibility
As #200, kvrocks still support to replicate data from old version master if you set
master-use-repl-port
to yes. For detail, we still use old implementation to coping from old version master.