Skip to content

Commit

Permalink
eagerepo: refresh store for every EdenAPI method
Browse files Browse the repository at this point in the history
Summary: For safety every EdenAPI method should refresh the eager store. I didn't hit any particular problem, but it seems you can get stale reads if writes have been happening on another store instance. The writes could be from another process or another codepath in the same process that aren't sharing an eager store instance for whatever reason.

Reviewed By: zzl0

Differential Revision: D54839561

fbshipit-source-id: 4a34d0865176a057a04a429a85ee387418d851e6
  • Loading branch information
muirdm authored and facebook-github-bot committed Mar 14, 2024
1 parent b7f1b32 commit dcc83cc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions eden/scm/lib/eagerepo/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ impl EdenApi for EagerRepo {
});

debug!("pull_lazy");
self.refresh_for_api();
let common = to_vec_vertex(&common);
let missing = to_vec_vertex(&missing);
let set = self
Expand All @@ -318,6 +319,7 @@ impl EdenApi for EagerRepo {
&self,
requests: Vec<CommitLocationToHashRequest>,
) -> edenapi::Result<Vec<CommitLocationToHashResponse>> {
self.refresh_for_api();
let path_names: Vec<(AncestorPath, Vec<Vertex>)> = {
let paths: Vec<AncestorPath> = requests
.into_iter()
Expand Down Expand Up @@ -364,6 +366,7 @@ impl EdenApi for EagerRepo {
master_heads: Vec<HgId>,
hgids: Vec<HgId>,
) -> edenapi::Result<Vec<CommitHashToLocationResponse>> {
self.refresh_for_api();
let path_names: Vec<(AncestorPath, Vec<Vertex>)> = {
let heads: Vec<Vertex> = to_vec_vertex(&master_heads);
let names: Vec<Vertex> = to_vec_vertex(&hgids);
Expand Down Expand Up @@ -404,6 +407,7 @@ impl EdenApi for EagerRepo {

async fn commit_known(&self, hgids: Vec<HgId>) -> edenapi::Result<Vec<CommitKnownResponse>> {
debug!("commit_known {}", debug_hgid_list(&hgids));
self.refresh_for_api();
let mut values = Vec::new();
for id in hgids {
let known = self.get_sha1_blob(id).map_err(map_crate_err)?.is_some();
Expand All @@ -426,6 +430,7 @@ impl EdenApi for EagerRepo {
debug_hgid_list(&heads),
debug_hgid_list(&common),
);
self.refresh_for_api();
let heads = Set::from_static_names(heads.iter().map(|v| Vertex::copy_from(v.as_ref())));
let common = Set::from_static_names(common.iter().map(|v| Vertex::copy_from(v.as_ref())));
let graph = self
Expand Down Expand Up @@ -471,6 +476,7 @@ impl EdenApi for EagerRepo {
debug_hgid_list(&heads),
debug_hgid_list(&common),
);
self.refresh_for_api();
let heads = Set::from_static_names(heads.iter().map(|v| Vertex::copy_from(v.as_ref())));
let common = Set::from_static_names(common.iter().map(|v| Vertex::copy_from(v.as_ref())));
let graph = self
Expand All @@ -493,6 +499,7 @@ impl EdenApi for EagerRepo {

async fn bookmarks(&self, bookmarks: Vec<String>) -> edenapi::Result<Vec<BookmarkEntry>> {
debug!("bookmarks {}", debug_string_list(&bookmarks));
self.refresh_for_api();
let mut values = Vec::new();
let map = self.get_bookmarks_map().map_err(map_crate_err)?;
for name in bookmarks {
Expand All @@ -510,6 +517,7 @@ impl EdenApi for EagerRepo {
&self,
prefixes: Vec<String>,
) -> Result<Vec<CommitHashLookupResponse>, EdenApiError> {
self.refresh_for_api();
let dag = self.dag().await;
prefixes
.into_iter()
Expand Down Expand Up @@ -542,6 +550,7 @@ impl EdenApi for EagerRepo {
) -> Result<Vec<CommitMutationsResponse>, EdenApiError> {
commits.sort();
debug!("commit_mutations {}", debug_hgid_list(&commits));
self.refresh_for_api();

let mut seen_commits = HashSet::new();
let mut mutations = Vec::new();
Expand Down Expand Up @@ -720,6 +729,7 @@ impl EdenApi for EagerRepo {
mutations: Vec<HgMutationEntryContent>,
) -> Result<Response<UploadTokensResponse>, EdenApiError> {
debug!(?changesets, ?mutations, "upload_changesets");
self.refresh_for_api();

let mut res = Vec::with_capacity(changesets.len());
for UploadHgChangeset {
Expand Down

0 comments on commit dcc83cc

Please sign in to comment.