Skip to content

Commit 464fb46

Browse files
committed
log cache errors and fallback to store instead of returning error to prevent consensus failure
1 parent 22f48a8 commit 464fb46

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

x/staking/keeper/delegation.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,7 @@ func (k Keeper) GetUBDQueueTimeSlice(ctx context.Context, timestamp time.Time) (
452452
if err == nil {
453453
return cachedPairs, nil
454454
}
455-
if !errors.Is(err, types.ErrCacheMaxSizeReached) {
456-
return nil, err
457-
}
455+
k.Logger(ctx).Error("GetUBDQueueTimeSlice from cache failed. Error: %s", err)
458456
}
459457

460458
store := k.storeService.OpenKVStore(ctx)
@@ -574,9 +572,7 @@ func (k Keeper) GetUBDs(ctx context.Context, endTime time.Time) (map[string][]ty
574572
if err == nil {
575573
return pairs, nil
576574
}
577-
if !errors.Is(err, types.ErrCacheMaxSizeReached) {
578-
return nil, err
579-
}
575+
k.Logger(ctx).Error("GetUBDs from cache failed. Error: %s", err)
580576
}
581577
return k.GetUnbondingDelegationsQueueFromStore(ctx, endTime)
582578
}
@@ -845,9 +841,7 @@ func (k Keeper) GetRedelegationQueueTimeSlice(ctx context.Context, timestamp tim
845841
if err == nil {
846842
return cachedTriplets, nil
847843
}
848-
if !errors.Is(err, types.ErrCacheMaxSizeReached) {
849-
return nil, err
850-
}
844+
k.Logger(ctx).Error("GetRedelegationQueueTimeSlice from cache failed. Error: %s", err)
851845
}
852846

853847
store := k.storeService.OpenKVStore(ctx)
@@ -1497,9 +1491,7 @@ func (k Keeper) GetPendingRedelegations(ctx context.Context, currTime time.Time)
14971491
if err == nil {
14981492
return redelegations, nil
14991493
}
1500-
if !errors.Is(err, types.ErrCacheMaxSizeReached) {
1501-
return nil, err
1502-
}
1494+
k.Logger(ctx).Error("GetPendingRedelegations from cache failed. Error: %s", err)
15031495
}
15041496
return k.GetRedelegationsQueueFromStore(ctx, currTime)
15051497
}

x/staking/keeper/validator.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,7 @@ func (k Keeper) GetUnbondingValidators(ctx context.Context, endTime time.Time, e
452452
if err == nil {
453453
return cachedAddrs, nil
454454
}
455-
if !errors.Is(err, types.ErrCacheMaxSizeReached) {
456-
return nil, err
457-
}
455+
k.Logger(ctx).Error("GetUnbondingValidators from cache failed. Error: %s", err)
458456
}
459457

460458
store := k.storeService.OpenKVStore(ctx)
@@ -674,9 +672,7 @@ func (k Keeper) GetPendingUnbondingValidators(ctx context.Context, endTime time.
674672
if err == nil {
675673
return addrs, nil
676674
}
677-
if !errors.Is(err, types.ErrCacheMaxSizeReached) {
678-
return nil, err
679-
}
675+
k.Logger(ctx).Error("GetPendingUnbondingValidators from cache failed. Error: %s", err)
680676
}
681677
return k.GetUnbondingValidatorsFromStore(ctx, endTime, endHeight)
682678
}

0 commit comments

Comments
 (0)