Skip to content

Commit 84f34b9

Browse files
committed
asim: improve logging with asim/MMAStoreRebalancer
Previously, some commits printed the entire struct type, making the output unreadable. This commit improves the logging to print the info.
1 parent 9b72230 commit 84f34b9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/kv/kvserver/asim/mmaintegration/mma_store_rebalancer.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ func (msr *MMAStoreRebalancer) Tick(ctx context.Context, tick time.Time, s state
132132
msr.pendingTicket = -1
133133
success := true
134134
if err := op.Errors(); err != nil {
135-
log.KvDistribution.Infof(ctx, "operation for pendingChange=%v failed: %v", curChange, err)
135+
log.KvDistribution.Infof(ctx, "operation for pendingChange=%v failed: %v", curChange.change, err)
136136
success = false
137137
} else {
138-
log.KvDistribution.VInfof(ctx, 1, "operation for pendingChange=%v completed successfully", curChange)
138+
log.KvDistribution.VInfof(ctx, 1, "operation for pendingChange=%v completed successfully", curChange.change)
139139
}
140140
msr.as.PostApply(curChange.syncChangeID, success)
141141
msr.pendingChangeIdx++
142142
} else {
143-
log.KvDistribution.VInfof(ctx, 1, "operation for pendingChange=%v is still in progress", curChange)
143+
log.KvDistribution.VInfof(ctx, 1, "operation for pendingChange=%v is still in progress", curChange.change)
144144
// Operation is still in progress, nothing to do this tick.
145145
return
146146
}
@@ -156,14 +156,15 @@ func (msr *MMAStoreRebalancer) Tick(ctx context.Context, tick time.Time, s state
156156
pendingChanges := msr.allocator.ComputeChanges(ctx, &storeLeaseholderMsg, mmaprototype.ChangeOptions{
157157
LocalStoreID: roachpb.StoreID(msr.localStoreID),
158158
})
159-
for _, change := range pendingChanges {
159+
log.KvDistribution.Infof(ctx, "store %d: computed %d changes", msr.localStoreID, len(pendingChanges))
160+
for i, change := range pendingChanges {
160161
usageInfo := s.RangeUsageInfo(state.RangeID(change.RangeID), msr.localStoreID)
161162
msr.pendingChanges = append(msr.pendingChanges, pendingChangeAndRangeUsageInfo{
162163
change: change,
163164
usage: usageInfo,
164165
})
166+
log.KvDistribution.Infof(ctx, "%v-th change: %v", i+1, change)
165167
}
166-
log.KvDistribution.Infof(ctx, "store %d: computed %d changes %v", msr.localStoreID, len(msr.pendingChanges), msr.pendingChanges)
167168
if len(msr.pendingChanges) == 0 {
168169
// Nothing to do, there were no changes returned.
169170
msr.currentlyRebalancing = false
@@ -202,7 +203,7 @@ func (msr *MMAStoreRebalancer) Tick(ctx context.Context, tick time.Time, s state
202203
} else {
203204
panic(fmt.Sprintf("unexpected pending change type: %v", curChange))
204205
}
205-
log.KvDistribution.VInfof(ctx, 1, "dispatching operation for pendingChange=%v", curChange)
206+
log.KvDistribution.VInfof(ctx, 1, "dispatching operation for pendingChange=%v", curChange.change)
206207
msr.pendingChanges[msr.pendingChangeIdx].syncChangeID =
207208
msr.as.MMAPreApply(ctx, curChange.usage, curChange.change)
208209
msr.pendingTicket = msr.controller.Dispatch(ctx, tick, s, curOp)

0 commit comments

Comments
 (0)