Skip to content

Commit

Permalink
Always include one non-local target during discovery
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Robinson <[email protected]>
henryr committed Jan 16, 2025
1 parent 0b70c76 commit a774206
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/vt/vtgateproxy/discovery.go
Original file line number Diff line number Diff line change
@@ -323,7 +323,9 @@ func (b *JSONGateResolverBuilder) parse() (bool, error) {
for poolType := range targets {
b.sorter.shuffleSort(targets[poolType], b.affinityField, b.affinityValue)
if len(targets[poolType]) > *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)
}
targetCount.Set(poolType, int64(len(targets[poolType])))
}

0 comments on commit a774206

Please sign in to comment.