mononoke: make bg session class tunable per-repo

Reviewed By: ahornby

Differential Revision: D26164309

fbshipit-source-id: bf489bbc75fdd9bcaeb07eb9d9f27249577a64df
This commit is contained in:
Stanislau Hlebik 2021-02-01 04:32:16 -08:00 committed by Facebook GitHub Bot
parent 43d406a808
commit da87622777
3 changed files with 8 additions and 6 deletions

View File

@ -131,7 +131,7 @@ pub trait BonsaiDerivable: Sized + 'static + Send + Sync + Clone {
parents: Vec<Self>,
options: &Self::Options,
) -> Result<Self, Error> {
let ctx = override_ctx(ctx);
let ctx = override_ctx(ctx, &repo);
Self::derive_from_parents_impl(ctx, repo, bonsai, parents, options).await
}
@ -161,7 +161,7 @@ pub trait BonsaiDerivable: Sized + 'static + Send + Sync + Clone {
where
Mapping: BonsaiDerivedMapping<Value = Self> + Send + Sync + Clone + 'static,
{
let ctx = &override_ctx(ctx.clone());
let ctx = &override_ctx(ctx.clone(), repo);
Self::batch_derive_impl(ctx, repo, csids, mapping, gap_size).await
}
@ -284,8 +284,10 @@ pub trait BonsaiDerived: Sized + 'static + Send + Sync + Clone + BonsaiDerivable
}
}
pub fn override_ctx(mut ctx: CoreContext) -> CoreContext {
if tunables::tunables().get_derived_data_use_background_session_class() {
pub fn override_ctx(mut ctx: CoreContext, repo: &BlobRepo) -> CoreContext {
let use_bg_class =
tunables::tunables().get_by_repo_derived_data_use_background_session_class(repo.name());
if let Some(true) = use_bg_class {
ctx.session_mut()
.override_session_class(SessionClass::Background);
ctx

View File

@ -273,7 +273,7 @@ where
}
{
let ctx = derived_data::override_ctx(ctx.clone());
let ctx = derived_data::override_ctx(ctx.clone(), &repo);
// flush blobstore
memblobstore.persist(&ctx).await?;
}

View File

@ -127,7 +127,7 @@ pub struct MononokeTunables {
// Use Background session class while deriving data. This makes derived data not write
// data to blobstore sync queue if a write was successful to the main blobstore.
derived_data_use_background_session_class: AtomicBool,
derived_data_use_background_session_class: TunableBoolByRepo,
commit_cloud_use_background_session_class: AtomicBool,
allow_change_xrepo_mapping_extra: AtomicBool,