From dcc83cc250fbbbbe092911a36ced47a8e3fd3147 Mon Sep 17 00:00:00 2001 From: Muir Manders Date: Wed, 13 Mar 2024 20:01:47 -0700 Subject: [PATCH] eagerepo: refresh store for every EdenAPI method 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 --- eden/scm/lib/eagerepo/src/api.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/eden/scm/lib/eagerepo/src/api.rs b/eden/scm/lib/eagerepo/src/api.rs index 563400b833179..9eef133cc3493 100644 --- a/eden/scm/lib/eagerepo/src/api.rs +++ b/eden/scm/lib/eagerepo/src/api.rs @@ -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 @@ -318,6 +319,7 @@ impl EdenApi for EagerRepo { &self, requests: Vec, ) -> edenapi::Result> { + self.refresh_for_api(); let path_names: Vec<(AncestorPath, Vec)> = { let paths: Vec = requests .into_iter() @@ -364,6 +366,7 @@ impl EdenApi for EagerRepo { master_heads: Vec, hgids: Vec, ) -> edenapi::Result> { + self.refresh_for_api(); let path_names: Vec<(AncestorPath, Vec)> = { let heads: Vec = to_vec_vertex(&master_heads); let names: Vec = to_vec_vertex(&hgids); @@ -404,6 +407,7 @@ impl EdenApi for EagerRepo { async fn commit_known(&self, hgids: Vec) -> edenapi::Result> { 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(); @@ -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 @@ -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 @@ -493,6 +499,7 @@ impl EdenApi for EagerRepo { async fn bookmarks(&self, bookmarks: Vec) -> edenapi::Result> { 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 { @@ -510,6 +517,7 @@ impl EdenApi for EagerRepo { &self, prefixes: Vec, ) -> Result, EdenApiError> { + self.refresh_for_api(); let dag = self.dag().await; prefixes .into_iter() @@ -542,6 +550,7 @@ impl EdenApi for EagerRepo { ) -> Result, 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(); @@ -720,6 +729,7 @@ impl EdenApi for EagerRepo { mutations: Vec, ) -> Result, EdenApiError> { debug!(?changesets, ?mutations, "upload_changesets"); + self.refresh_for_api(); let mut res = Vec::with_capacity(changesets.len()); for UploadHgChangeset {