Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ring member refresh log improvements #6361

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions common/membership/hashring.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,7 @@ func (r *ring) notifySubscribers(msg ChangedEvent) {
}

// Unsubscribe removes subscriber
func (r *ring) Unsubscribe(
name string,
) error {
func (r *ring) Unsubscribe(name string) error {
r.subscribers.Lock()
defer r.subscribers.Unlock()
delete(r.subscribers.keys, name)
Expand Down Expand Up @@ -254,6 +252,7 @@ func (r *ring) Members() []HostInfo {
func (r *ring) refresh() error {
if r.members.refreshed.After(r.timeSource.Now().Add(-minRefreshInternal)) {
// refreshed too frequently
r.logger.Debug("refresh skipped, refreshed too frequently")
return nil
}

Expand All @@ -272,7 +271,9 @@ func (r *ring) refresh() error {
ring := emptyHashring()
ring.AddMembers(castToMembers(members)...)
r.value.Store(ring)
r.logger.Info("refreshed ring members", tag.Value(members))
// sort members for deterministic order in the logs
sort.Slice(members, func(i, j int) bool { return members[i].addr < members[j].addr })
r.logger.Info("refreshed ring members", tag.Value(members), tag.Counter(len(members)), tag.Service(r.service))

r.updateMembersMap(newMembersMap)

Expand Down
Loading