Configure maximum concurrent leader probes #303
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently,
go-dqlite
was updated in #292 to concurrently open up to 10 requests to other cluster members when probing for leadership. The goal of this was to prevent go-dqlite from getting hung up on some unresponsive nodes.One issue with this is that it is a bit too aggressive, each attempt to fetch the leader will execute effectively
2n - 1
network requests wheren
is the number of cluster members. #302 will make this return early if the leader is found, but it would also be great if a project could configure this value to grow and shrink based on the current health of the cluster.Effectively, if the cluster is healthy, the
2n -1
requests are redundant because we generally only need a maximum of 2. (One to some node and another to who that node reports is the leader).So this PR adds the
WithConcurrentLeaderConns
option to each ofclient
,driver
, andapp
. The default value will remain 10 as before.In particular for
app
anddriver
, the value is actually recorded as a pointer so that a project can dynamically grow and shrink the maximum concurrent connections that will be maintained when probing for the leader during the role adjustment interval.The idea here is that the hook from #301 can be used to check the deviation in node response times after each role adjustment, and then increment or decrement the maximum connections that the cluster can tolerate.