Skip to content

Commit

Permalink
megarepo_api: don't derive filenodes while building megarepo commits
Browse files Browse the repository at this point in the history
Summary:
The filenodes derived data type only applies to public commits.  Ordinarily it is a no-op when attempted on a draft commit, however derivation batching can fail if it discovers that the parent of a batch root is not derived.

Don't even try to derive filenodes for these commits.  The derivation will happen for real when the bookmark is moved to the head commit and the ancestors all become public.

Reviewed By: gustavoavena

Differential Revision: D66507350

fbshipit-source-id: 6c4717469949aee709e7ec0e939596b2596699c1
  • Loading branch information
markbt authored and facebook-github-bot committed Nov 27, 2024
1 parent f19c2ab commit 903281b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
26 changes: 5 additions & 21 deletions eden/mononoke/megarepo_api/src/add_sync_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::sync::Arc;

use bookmarks::BookmarkKey;
use bookmarks::BookmarksRef;
use bulk_derivation::BulkDerivation;
use context::CoreContext;
use futures::TryFutureExt;
use megarepo_config::verify_config;
Expand All @@ -24,8 +23,8 @@ use mononoke_api::MononokeRepo;
use mononoke_api::RepoContext;
use mononoke_types::ChangesetId;
use mutable_renames::MutableRenames;
use repo_derived_data::RepoDerivedDataRef;

use crate::common::derive_all_types;
use crate::common::MegarepoOp;

// Create a new sync target given a config.
Expand Down Expand Up @@ -136,30 +135,15 @@ impl<'a, R: MononokeRepo> AddSyncTarget<'a, R> {

// For now let's just retry a few times so that we don't have to start over
// because of flakiness
let mut i = 0;
loop {
i += 1;
let derived_data_types = repo
.repo()
.repo_derived_data()
.active_config()
.types
.iter()
.copied()
.collect::<Vec<_>>();
let res = repo
.repo()
.repo_derived_data()
.manager()
.derive_bulk(ctx, &[top_merge_cs_id], None, &derived_data_types, None)
.await;
match res {
for attempt in 1.. {
let result = derive_all_types(ctx, repo.repo(), top_merge_cs_id).await;
match result {
Ok(()) => {
break;
}
Err(err) => {
scuba.log_with_msg("Derived data failed, retrying", Some(format!("{:#}", err)));
if i >= 5 {
if attempt >= 5 {
return Err(err.into());
}
}
Expand Down
5 changes: 5 additions & 0 deletions eden/mononoke/megarepo_api/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ use mononoke_types::BonsaiChangeset;
use mononoke_types::BonsaiChangesetMut;
use mononoke_types::ChangesetId;
use mononoke_types::DateTime;
use mononoke_types::DerivableType;
use mononoke_types::FileChange;
use mononoke_types::FileType;
use mononoke_types::GitLfs;
Expand Down Expand Up @@ -1426,6 +1427,10 @@ pub(crate) async fn derive_all_types(
.types
.iter()
.copied()
.filter(|t| {
// Filenodes cannot be derived for draft commits
*t != DerivableType::FileNodes
})
.collect::<Vec<_>>();
repo.repo_derived_data()
.manager()
Expand Down

0 comments on commit 903281b

Please sign in to comment.