Skip to content

Commit d148b94

Browse files
authored
feat: Add warning on duplicate clients for round-robin and shuffle schedulers (#1878)
#### Summary `multiplex returned duplicate client` warning for incorrect multiplexers occurs only when `dfs` scheduler is used. This PR adds the same warning for `round-robin` and `shuffle` schedulers. More context here: https://discord.com/channels/872925471417962546/1271466277189324831 ---
1 parent bb1be84 commit d148b94

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

scheduler/scheduler_round_robin.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ func (s *syncClient) syncRoundRobin(ctx context.Context, resolvedResources chan<
2121
if table.Multiplex != nil {
2222
clients = table.Multiplex(s.client)
2323
}
24+
// Detect duplicate clients while multiplexing
25+
seenClients := make(map[string]bool)
26+
for _, c := range clients {
27+
if _, ok := seenClients[c.ID()]; !ok {
28+
seenClients[c.ID()] = true
29+
} else {
30+
s.logger.Warn().Str("client", c.ID()).Str("table", table.Name).Msg("multiplex returned duplicate client")
31+
}
32+
}
2433
preInitialisedClients[i] = clients
2534
// we do this here to avoid locks so we initial the metrics structure once in the main goroutines
2635
// and then we can just read from it in the other goroutines concurrently given we are not writing to it.

scheduler/scheduler_shuffle.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ func (s *syncClient) syncShuffle(ctx context.Context, resolvedResources chan<- *
2121
if table.Multiplex != nil {
2222
clients = table.Multiplex(s.client)
2323
}
24+
// Detect duplicate clients while multiplexing
25+
seenClients := make(map[string]bool)
26+
for _, c := range clients {
27+
if _, ok := seenClients[c.ID()]; !ok {
28+
seenClients[c.ID()] = true
29+
} else {
30+
s.logger.Warn().Str("client", c.ID()).Str("table", table.Name).Msg("multiplex returned duplicate client")
31+
}
32+
}
2433
preInitialisedClients[i] = clients
2534
// we do this here to avoid locks so we initial the metrics structure once in the main goroutines
2635
// and then we can just read from it in the other goroutines concurrently given we are not writing to it.

0 commit comments

Comments
 (0)