Skip to content

Commit

Permalink
Revert "fix: clear trie view caches before state sync (#3593)" (#3743)
Browse files Browse the repository at this point in the history
Revert invalidating view client cache on gc/data reset to avoid
lock contention.
Fixes #3712.
This reverts commit 9428c7d.
  • Loading branch information
mikhailOK authored and bowenwang1996 committed Jan 5, 2021
1 parent 46b0296 commit 4632371
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion chain/client/tests/process_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,8 @@ fn test_data_reset_before_state_sync() {
head_block.header().epoch_id(),
&QueryRequest::ViewAccount { account_id: "test_account".to_string() },
);
assert!(response.is_err());
// TODO(#3742): ViewClient still has data in cache by current design.
assert!(response.is_ok());
}

#[test]
Expand Down
3 changes: 1 addition & 2 deletions core/store/src/trie/shard_tries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ impl ShardTries {
}
}
for (shard_id, ops) in shards.into_iter().enumerate() {
self.caches[shard_id].update_cache(&ops);
self.view_caches[shard_id].update_cache(&ops);
self.caches[shard_id].update_cache(ops);
}
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions core/store/src/trie/trie_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ impl TrieCache {
Self(Arc::new(Mutex::new(SizedCache::with_size(TRIE_MAX_CACHE_SIZE))))
}

pub fn update_cache(&self, ops: &[(CryptoHash, Option<Vec<u8>>)]) {
pub fn update_cache(&self, ops: Vec<(CryptoHash, Option<Vec<u8>>)>) {
let mut guard = self.0.lock().expect(POISONED_LOCK_ERR);
for (hash, opt_value_rc) in ops {
if let Some(value_rc) = opt_value_rc {
if let (Some(value), _rc) = decode_value_with_rc(value_rc) {
if let (Some(value), _rc) = decode_value_with_rc(&value_rc) {
if value.len() < TRIE_LIMIT_CACHED_VALUE_SIZE {
guard.cache_set(*hash, value.to_vec());
guard.cache_set(hash, value.to_vec());
}
} else {
guard.cache_remove(&hash);
Expand Down

0 comments on commit 4632371

Please sign in to comment.