Skip to content

Commit

Permalink
per-replica EveryN
Browse files Browse the repository at this point in the history
  • Loading branch information
tbg committed Mar 14, 2023
1 parent 02f8eaf commit e005c0f
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions pkg/kv/kvserver/replica.go
Expand Up @@ -167,6 +167,7 @@ type raftSparseStatus struct {
// integrity by replacing failed replicas, splitting and merging
// as appropriate.
type Replica struct {
logUnstableN log.EveryN
// A replica's AmbientCtx includes the log tags from the parent node and
// store.
log.AmbientContext
Expand Down
1 change: 1 addition & 0 deletions pkg/kv/kvserver/replica_init.go
Expand Up @@ -82,6 +82,7 @@ func newUninitializedReplica(
) *Replica {
uninitState := stateloader.UninitializedReplicaState(rangeID)
r := &Replica{
logUnstableN: log.Every(time.Second),
AmbientContext: store.cfg.AmbientCtx,
RangeID: rangeID,
replicaID: replicaID,
Expand Down
3 changes: 0 additions & 3 deletions pkg/kv/kvserver/replica_proposal_buf.go
Expand Up @@ -14,7 +14,6 @@ import (
"context"
"sync"
"sync/atomic"
"time"

"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/closedts/tracker"
Expand Down Expand Up @@ -901,8 +900,6 @@ func (b *propBuf) forwardClosedTimestampLocked(closedTS hlc.Timestamp) bool {
return b.assignedClosedTimestamp.Forward(closedTS)
}

var logUnstableN = log.Every(time.Second)

func proposeBatch(raftGroup proposerRaft, replID roachpb.ReplicaID, ents []raftpb.Entry) error {
if len(ents) == 0 {
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/replica_raft.go
Expand Up @@ -775,7 +775,7 @@ func (r *Replica) handleRaftReadyRaftMuLocked(
{
count, bytes := raftGroup.UnstableLogStats()
const mb = 1 << 20
if bytes > 50*mb && logUnstableN.ShouldLog() {
if bytes > 50*mb && r.logUnstableN.ShouldLog() {
log.Infof(ctx, "r%d: unstable log #%d/%s", r.RangeID, count, humanizeutil.IBytes(bytes))
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/store.go
Expand Up @@ -2881,7 +2881,7 @@ func (s *Store) updateReplicationGauges(ctx context.Context) error {
fmt.Fprintf(&buf, ", ")
}
}
log.Infof(ctx, "recv-queues: %s", buf)
log.Infof(ctx, "recv-queues: %s", &buf)
}

newStoreReplicaVisitor(s).Visit(func(rep *Replica) bool {
Expand Down

0 comments on commit e005c0f

Please sign in to comment.