Skip to content

Commit a774206

Browse files
committed
Always include one non-local target during discovery
Signed-off-by: Henry Robinson <hrobinson@slack-corp.com>
1 parent 0b70c76 commit a774206

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

go/vt/vtgateproxy/discovery.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ func (b *JSONGateResolverBuilder) parse() (bool, error) {
323323
for poolType := range targets {
324324
b.sorter.shuffleSort(targets[poolType], b.affinityField, b.affinityValue)
325325
if len(targets[poolType]) > *numConnections {
326-
targets[poolType] = targets[poolType][:b.numConnections]
326+
// Always grab one non-local target to protect against a complete local failure.
327+
nonLocal := targets[poolType][len(targets[poolType])-1]
328+
targets[poolType] = append(targets[poolType][:b.numConnections], nonLocal)
327329
}
328330
targetCount.Set(poolType, int64(len(targets[poolType])))
329331
}

0 commit comments

Comments
 (0)