Skip to content

Commit e9348e8

Browse files
committed
mmaprototype: improve logs with IsInConflictWithMMA
This commit enhances `IsInConflictWithMMA` logs so they appear in traces and under vmodule, improving visibility into MMA rejections.
1 parent f6110ae commit e9348e8

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

pkg/kv/kvserver/allocator/mmaprototype/allocator_state.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,17 +1348,36 @@ func (a *allocatorState) IsInConflictWithMMA(
13481348
if advisor.disabled {
13491349
return false
13501350
}
1351+
// Lazily compute and cache the load summary for the existing store.
13511352
if advisor.existingStoreSLS == nil {
1352-
summary := a.cs.computeLoadSummary(ctx, advisor.existingStoreID,
1353-
&advisor.means.storeLoad, &advisor.means.nodeLoad)
1353+
summary := a.cs.computeLoadSummary(ctx, advisor.existingStoreID, &advisor.means.storeLoad, &advisor.means.nodeLoad)
13541354
advisor.existingStoreSLS = &summary
13551355
}
13561356
existingSLS := advisor.existingStoreSLS
1357+
// Always compute the candidate's load summary.
13571358
candSLS := a.cs.computeLoadSummary(ctx, cand, &advisor.means.storeLoad, &advisor.means.nodeLoad)
1359+
1360+
var conflict bool
13581361
if cpuOnly {
1359-
return candSLS.dimSummary[CPURate] > existingSLS.dimSummary[CPURate]
1362+
conflict = candSLS.dimSummary[CPURate] > existingSLS.dimSummary[CPURate]
1363+
if conflict {
1364+
log.KvDistribution.VEventf(
1365+
ctx, 2,
1366+
"mma rejected candidate s%d (cpu-only) as a replacement for s%d: candidate=%v > existing=%v",
1367+
cand, advisor.existingStoreID, candSLS.dimSummary[CPURate], existingSLS.dimSummary[CPURate],
1368+
)
1369+
}
1370+
} else {
1371+
conflict = candSLS.sls > existingSLS.sls
1372+
if conflict {
1373+
log.KvDistribution.VEventf(
1374+
ctx, 2,
1375+
"mma rejected candidate s%d as a replacement for s%d: candidate=%v > existing=%v",
1376+
cand, advisor.existingStoreID, candSLS.sls, existingSLS.sls,
1377+
)
1378+
}
13601379
}
1361-
return candSLS.sls > existingSLS.sls
1380+
return conflict
13621381
}
13631382

13641383
// Consider the core logic for a change, rebalancing or recovery.

0 commit comments

Comments
 (0)