Skip to content

Commit

Permalink
feat: Add warning on duplicate clients for round-robin and `shuffle…
Browse files Browse the repository at this point in the history
…` 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

---
  • Loading branch information
kabachook authored Aug 27, 2024
1 parent bb1be84 commit d148b94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scheduler/scheduler_round_robin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ func (s *syncClient) syncRoundRobin(ctx context.Context, resolvedResources chan<
if table.Multiplex != nil {
clients = table.Multiplex(s.client)
}
// Detect duplicate clients while multiplexing
seenClients := make(map[string]bool)
for _, c := range clients {
if _, ok := seenClients[c.ID()]; !ok {
seenClients[c.ID()] = true
} else {
s.logger.Warn().Str("client", c.ID()).Str("table", table.Name).Msg("multiplex returned duplicate client")
}
}
preInitialisedClients[i] = clients
// we do this here to avoid locks so we initial the metrics structure once in the main goroutines
// and then we can just read from it in the other goroutines concurrently given we are not writing to it.
Expand Down
9 changes: 9 additions & 0 deletions scheduler/scheduler_shuffle.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ func (s *syncClient) syncShuffle(ctx context.Context, resolvedResources chan<- *
if table.Multiplex != nil {
clients = table.Multiplex(s.client)
}
// Detect duplicate clients while multiplexing
seenClients := make(map[string]bool)
for _, c := range clients {
if _, ok := seenClients[c.ID()]; !ok {
seenClients[c.ID()] = true
} else {
s.logger.Warn().Str("client", c.ID()).Str("table", table.Name).Msg("multiplex returned duplicate client")
}
}
preInitialisedClients[i] = clients
// we do this here to avoid locks so we initial the metrics structure once in the main goroutines
// and then we can just read from it in the other goroutines concurrently given we are not writing to it.
Expand Down

1 comment on commit d148b94

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Benchmark results

  • Glob-8 ns/op: 94.63

Please sign in to comment.