Skip to content
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
7 changes: 6 additions & 1 deletion pkg/etcdcli/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ func GetMemberHealth(ctx context.Context, clipool *EtcdClientPool, etcdMembers [
}
defer clipool.Return(cli)

memberHealth[i] = checkSingleMemberHealth(ctx, cli, member)
// Create an independent timeout context for each member health check
// This prevents one slow member from affecting other members' health checks
memberCtx, cancel := context.WithTimeout(ctx, DefaultClientTimeout)
defer cancel()

memberHealth[i] = checkSingleMemberHealth(memberCtx, cli, member)
Copy link
Contributor

@lance5890 lance5890 Aug 28, 2025

Choose a reason for hiding this comment

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

Maybe there's potential data race issue in the goroutine - it's capturing the loop variable member by reference. This can cause a data race where all goroutines end up checking the last member. we should pass member as an argument: go func(i int, m *etcdserverpb.Member) {...}(i, member)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the quick review @lance5890 - I think this should be fixed in later go versions?
https://go.dev/blog/loopvar-preview

}(i)
}

Expand Down