Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
133199: kv: return the actual epoch in replicaRLockedStoreLiveness.SupportFrom r=nvanbenschoten a=nvanbenschoten

This is needed to complete the intention of cockroachdb#131614.

May explain recent `epochs in store liveness shouldn't regress` assertion failures.

Epic: None
Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
craig[bot] and nvanbenschoten committed Oct 22, 2024
2 parents 9e49a0b + 95da904 commit 68407b8
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pkg/kv/kvserver/replica_store_liveness.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/util/envutil"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/log"
)

var raftLeaderFortificationFractionEnabled = settings.RegisterFloatSetting(
Expand Down Expand Up @@ -59,18 +60,12 @@ func (r *replicaRLockedStoreLiveness) getStoreIdent(
func (r *replicaRLockedStoreLiveness) SupportFor(replicaID raftpb.PeerID) (raftpb.Epoch, bool) {
storeID, ok := r.getStoreIdent(replicaID)
if !ok {
return 0, false
}
// TODO(arul): we can remove this once we start to assign storeLiveness in the
// Store constructor.
if r.store.storeLiveness == nil {
ctx := r.AnnotateCtx(context.TODO())
log.Warningf(ctx, "store not found for replica %d in SupportFor", replicaID)
return 0, false
}
epoch, ok := r.store.storeLiveness.SupportFor(storeID)
if !ok {
return 0, false
}
return raftpb.Epoch(epoch), true
return raftpb.Epoch(epoch), ok
}

// SupportFrom implements the raftstoreliveness.StoreLiveness interface.
Expand All @@ -79,6 +74,8 @@ func (r *replicaRLockedStoreLiveness) SupportFrom(
) (raftpb.Epoch, hlc.Timestamp) {
storeID, ok := r.getStoreIdent(replicaID)
if !ok {
ctx := r.AnnotateCtx(context.TODO())
log.Warningf(ctx, "store not found for replica %d in SupportFrom", replicaID)
return 0, hlc.Timestamp{}
}
epoch, exp := r.store.storeLiveness.SupportFrom(storeID)
Expand Down

0 comments on commit 68407b8

Please sign in to comment.