Skip to content

Commit 9d2b9d4

Browse files
author
Zoran Cvetkov
committed
backport debug comparison
1 parent 7988c8a commit 9d2b9d4

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

graph/src/components/store/entity_cache.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,26 @@ impl EntityCache {
205205
}
206206
GetScope::InBlock => None,
207207
};
208-
209208
// Always test the cache consistency in debug mode. The test only
210-
// makes sense when we were actually asked to read from the store
209+
// makes sense when we were actually asked to read from the store.
210+
// We need to remove the VID as the one from the DB might come from
211+
// a legacy subgraph that has VID autoincremented while this trait
212+
// always creates it in a new style.
211213
debug_assert!(match scope {
212-
GetScope::Store => entity == self.store.get(key).unwrap().map(Arc::new),
214+
GetScope::Store => {
215+
// Release build will never call this function and hence it's OK
216+
// when that implementation is not correct.
217+
fn remove_vid(entity: Option<Arc<Entity>>) -> Option<Entity> {
218+
entity.map(|e| {
219+
#[allow(unused_mut)]
220+
let mut entity = (*e).clone();
221+
#[cfg(debug_assertions)]
222+
entity.remove("vid");
223+
entity
224+
})
225+
}
226+
remove_vid(entity.clone()) == remove_vid(self.store.get(key).unwrap().map(Arc::new))
227+
}
213228
GetScope::InBlock => true,
214229
});
215230

0 commit comments

Comments
 (0)