Skip to content

Commit bd8df07

Browse files
committed
asim: pass node id to queues for logging
This commit passes in the node id to different queues for logging purposes. Epic: none Release note: none
1 parent 7b39ad9 commit bd8df07

File tree

6 files changed

+12
-2
lines changed

6 files changed

+12
-2
lines changed

pkg/kv/kvserver/asim/asim.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ func (s *Simulator) StoreAddNotify(storeID state.StoreID, _ state.State) {
133133
func (s *Simulator) addStore(storeID state.StoreID, tick time.Time) {
134134
allocator := s.state.Allocator(storeID)
135135
storePool := s.state.StorePool(storeID)
136+
store, _ := s.state.Store(storeID)
136137
s.rqs[storeID] = queue.NewReplicateQueue(
137138
storeID,
139+
store.NodeID(),
138140
s.changer,
139141
s.settings,
140142
allocator,
@@ -143,6 +145,7 @@ func (s *Simulator) addStore(storeID state.StoreID, tick time.Time) {
143145
)
144146
s.lqs[storeID] = queue.NewLeaseQueue(
145147
storeID,
148+
store.NodeID(),
146149
s.changer,
147150
s.settings,
148151
allocator,

pkg/kv/kvserver/asim/queue/lease_queue.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package queue
88
import (
99
"container/heap"
1010
"context"
11+
"fmt"
1112
"time"
1213

1314
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/allocatorimpl"
@@ -32,6 +33,7 @@ type leaseQueue struct {
3233
// NewLeaseQueue returns a new lease queue.
3334
func NewLeaseQueue(
3435
storeID state.StoreID,
36+
nodeID state.NodeID,
3537
stateChanger state.Changer,
3638
settings *config.SimulationSettings,
3739
allocator allocatorimpl.Allocator,
@@ -52,6 +54,7 @@ func NewLeaseQueue(
5254
clock: storePool.Clock(),
5355
}
5456
lq.AddLogTag("lease", nil)
57+
lq.AddLogTag(fmt.Sprintf("n%ds%d", nodeID, storeID), "")
5558
return &lq
5659
}
5760

pkg/kv/kvserver/asim/queue/lease_queue_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ func TestLeaseQueue(t *testing.T) {
140140
store, _ := s.Store(testingStore)
141141
lq := NewLeaseQueue(
142142
store.StoreID(),
143+
store.NodeID(),
143144
changer,
144145
testSettings,
145146
s.Allocator(store.StoreID()),

pkg/kv/kvserver/asim/queue/replicate_queue.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type replicateQueue struct {
3131
// NewReplicateQueue returns a new replicate queue.
3232
func NewReplicateQueue(
3333
storeID state.StoreID,
34+
nodeID state.NodeID,
3435
stateChanger state.Changer,
3536
settings *config.SimulationSettings,
3637
allocator allocatorimpl.Allocator,
@@ -51,6 +52,7 @@ func NewReplicateQueue(
5152
clock: storePool.Clock(),
5253
}
5354
rq.AddLogTag("replica", nil)
55+
rq.AddLogTag(fmt.Sprintf("n%ds%d", nodeID, storeID), "")
5456
return &rq
5557
}
5658

@@ -64,7 +66,7 @@ func (rq *replicateQueue) MaybeAdd(ctx context.Context, replica state.Replica, s
6466
}
6567

6668
repl := NewSimulatorReplica(replica, s)
67-
rq.AddLogTag("r", repl.repl.Descriptor())
69+
rq.AddLogTag("r", repl.Desc().RangeID)
6870
rq.AnnotateCtx(ctx)
6971

7072
desc := repl.Desc()

pkg/kv/kvserver/asim/queue/replicate_queue_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ func TestReplicateQueue(t *testing.T) {
289289
store, _ := s.Store(testingStore)
290290
rq := NewReplicateQueue(
291291
store.StoreID(),
292+
store.NodeID(),
292293
changer,
293294
testSettings,
294295
s.Allocator(store.StoreID()),

pkg/kv/kvserver/asim/storerebalancer/store_rebalancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (src *storeRebalancerControl) checkPendingTicket() (done bool, _ error) {
155155
}
156156

157157
func (src *storeRebalancerControl) Tick(ctx context.Context, tick time.Time, state state.State) {
158-
src.sr.AddLogTag("tick", tick)
158+
src.sr.AddLogTag("tick", tick.Sub(src.settings.StartTime))
159159
ctx = src.sr.ResetAndAnnotateCtx(ctx)
160160
switch src.rebalancerState.phase {
161161
case rebalancerSleeping:

0 commit comments

Comments
 (0)