File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -431,17 +431,18 @@ pub(crate) async fn execute_root_selection_set<R: Resolver>(
431
431
ctx. cache_status . store ( CacheStatus :: Shared ) ;
432
432
}
433
433
434
+ // Calculate the weight once outside the lock.
435
+ let weight = result. weight ( ) ;
436
+
434
437
// Check if this query should be cached.
435
438
// Share errors from the herd cache, but don't store them in generational cache.
436
439
// In particular, there is a problem where asking for a block pointer beyond the chain
437
440
// head can cause the legitimate cache to be thrown out.
438
441
// It would be redundant to insert herd cache hits.
439
- let no_cache = herd_hit || result. has_errors ( ) || result . weight ( ) > * MAX_ENTRY_WEIGHT ;
442
+ let no_cache = herd_hit || result. has_errors ( ) || weight > * MAX_ENTRY_WEIGHT ;
440
443
if let ( false , Some ( key) , Some ( block_ptr) , Some ( network) ) =
441
444
( no_cache, key, block_ptr, & ctx. query . network )
442
445
{
443
- // Calculate the weight outside the lock.
444
- let weight = result. weight ( ) ;
445
446
let shard = ( key[ 0 ] as usize ) % QUERY_BLOCK_CACHE . len ( ) ;
446
447
let inserted = QUERY_BLOCK_CACHE [ shard] . lock ( & ctx. logger ) . insert (
447
448
network,
You can’t perform that action at this time.
0 commit comments