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

Always include one non-local target during discovery #583

Open
wants to merge 1 commit into
base: vtgateproxy-15
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion go/vt/vtgateproxy/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@
for poolType := range targets {
b.sorter.shuffleSort(targets[poolType], b.affinityField, b.affinityValue)
if len(targets[poolType]) > *numConnections {

Choose a reason for hiding this comment

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

nit: preexisting code and no change in behavior, but this should be if len(targets[poolType]) > b.numConnections {

targets[poolType] = targets[poolType][:b.numConnections]
// Always grab one non-local target to protect against a complete local failure.
nonLocal := targets[poolType][len(targets[poolType])-1]
targets[poolType] = append(targets[poolType][:b.numConnections], nonLocal)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pedantically you should probably only slice to [:b.numConnections-1] so that the total conns are still the number that we set, it's just only N-1 of them are AZ-affine?

}
targetCount.Set(poolType, int64(len(targets[poolType])))
}
Expand Down Expand Up @@ -414,7 +416,7 @@
if r.currentAddrs != nil && warmupTime.Seconds() > 0 {
combined := append(r.currentAddrs, addrs...)
log.V(100).Infof("updating targets for %s to warmup %v", r.target.URL.String(), targets)
r.clientConn.UpdateState(resolver.State{Addresses: combined})

Check failure on line 419 in go/vt/vtgateproxy/discovery.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

Error return value of `r.clientConn.UpdateState` is not checked (errcheck)

Check failure on line 419 in go/vt/vtgateproxy/discovery.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

Error return value of `r.clientConn.UpdateState` is not checked (errcheck)
time.Sleep(*warmupTime)
}

Expand Down
Loading