dag: update overlay_map_next_id on flush

Summary:
During flush, there could be newly added vertexes in the master group,
overlay_map_next_id needs to be updated accordingly so lazy lookup
can still work. This is especially needed when the non-master group
needs to be re-assigned.

Reviewed By: andll

Differential Revision: D30314051

fbshipit-source-id: cce7080f62aec2617b8f3d7194864df41dfff7e0
This commit is contained in:
Jun Wu 2021-08-16 14:23:40 -07:00 committed by Facebook GitHub Bot
parent 6bf7d34f3a
commit b2534c7d68
2 changed files with 11 additions and 9 deletions

View File

@ -813,13 +813,18 @@ where
}
fn invalidate_overlay_map(&mut self) -> Result<()> {
let next_id = self.dag.next_free_id(0, Group::MASTER)?;
self.overlay_map = Default::default();
self.overlay_map_next_id = next_id;
self.update_overlay_map_next_id()?;
tracing::debug!(target: "dag::cache", "cleared overlay map cache");
Ok(())
}
fn update_overlay_map_next_id(&mut self) -> Result<()> {
let next_id = self.dag.next_free_id(0, Group::MASTER)?;
self.overlay_map_next_id = next_id;
Ok(())
}
/// Attempt to get a snapshot of this graph.
pub(crate) fn try_snapshot(&self) -> Result<Arc<Self>> {
if let Some(s) = self.snapshot.read().deref() {
@ -2035,6 +2040,10 @@ where
self.dag
.build_segments_volatile_from_prepared_flat_segments(&outcome)?;
// The master group might have new vertexes inserted, which will
// affect the `overlay_map_next_id`.
self.update_overlay_map_next_id()?;
// Rebuild non-master ids and segments.
if self.need_rebuild_non_master() {
self.rebuild_non_master().await?;

View File

@ -64,14 +64,7 @@ Create commits in the client repo. Make them overlap with the server-side master
INFO dag::cache: skip flushing 112478962961147124edd43549aedd1a335e44bf-1 to IdMap set by DAG_SKIP_FLUSH_VERTEXES
Pull:
(On Windows the error message is a bit different)
#if no-windows
$ hg pull -B master
pulling from test:e1
searching for changes
transaction abort!
rollback completed
error.RustError: ProgrammingError: Server returned x~n (x = a31451c3c1debad52cf22ef2aebfc88c75dc899a 7, n = 6). But x exceeds the head in the local master group 5. This is not expected and indicates some logic error on the server side.
[255]
#endif