-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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: use future pool for snap-generator pool #15079
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d3f4aeb
raftstore: use future pool for snap-generator pool
nolouch ebbb3ac
Merge remote-tracking branch 'origin/master' into use-yatp-builder
nolouch 4c65c79
revert
nolouch 728ca9b
Merge branch 'master' into use-yatp-builder
nolouch 7af300e
Merge branch 'master' into use-yatp-builder
ti-chi-bot[bot] 6923414
Merge branch 'master' into use-yatp-builder
ti-chi-bot[bot] c70d2fb
Merge branch 'master' into use-yatp-builder
ti-chi-bot[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,14 +28,11 @@ use raft::eraftpb::Snapshot as RaftSnapshot; | |
use tikv_util::{ | ||
box_err, box_try, | ||
config::VersionTrack, | ||
defer, error, info, thd_name, | ||
defer, error, info, | ||
time::{Instant, UnixSecs}, | ||
warn, | ||
worker::{Runnable, RunnableWithTimer}, | ||
}; | ||
use yatp::{ | ||
pool::{Builder, ThreadPool}, | ||
task::future::TaskCell, | ||
yatp_pool::{DefaultTicker, FuturePool, YatpPoolBuilder}, | ||
}; | ||
|
||
use super::metrics::*; | ||
|
@@ -373,7 +370,7 @@ where | |
coprocessor_host: CoprocessorHost<EK>, | ||
router: R, | ||
pd_client: Option<Arc<T>>, | ||
pool: ThreadPool<TaskCell>, | ||
pool: FuturePool, | ||
} | ||
|
||
impl<EK, R, T> Runner<EK, R, T> | ||
|
@@ -407,8 +404,13 @@ where | |
coprocessor_host, | ||
router, | ||
pd_client, | ||
pool: Builder::new(thd_name!("snap-generator")) | ||
.max_thread_count(cfg.value().snap_generator_pool_size) | ||
pool: YatpPoolBuilder::new(DefaultTicker::default()) | ||
.name_prefix("snap-generator") | ||
.thread_count( | ||
1, | ||
cfg.value().snap_generator_pool_size, | ||
cfg.value().snap_generator_pool_size, | ||
) | ||
.build_future_pool(), | ||
} | ||
} | ||
|
@@ -858,7 +860,12 @@ where | |
for_balance, | ||
allow_multi_files_snapshot, | ||
); | ||
}); | ||
}).unwrap_or_else( | ||
|e| { | ||
error!("failed to generate snapshot"; "region_id" => region_id, "err" => ?e); | ||
SNAP_COUNTER.generate.fail.inc(); | ||
}, | ||
); | ||
} | ||
task @ Task::Apply { .. } => { | ||
fail_point!("on_region_worker_apply", true, |_| {}); | ||
|
@@ -887,10 +894,6 @@ where | |
} | ||
} | ||
} | ||
|
||
fn shutdown(&mut self) { | ||
self.pool.shutdown(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you needs to impl it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think no place to use the shutdown current. |
||
} | ||
} | ||
|
||
impl<EK, R, T> RunnableWithTimer for Runner<EK, R, T> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe we need notify raftstore that snapshot will not be generated. Otherwise, leader will not retry generate snapshot.
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.
I think once the
notifier
is dropped(after failing), the generator can be retried.tikv/components/raftstore/src/store/peer_storage.rs
Lines 513 to 524 in 189e4c4