From a774206406b47a8d9451f2373ddcb5452424c5cd Mon Sep 17 00:00:00 2001 From: Henry Robinson Date: Thu, 16 Jan 2025 12:02:16 +0000 Subject: [PATCH] Always include one non-local target during discovery Signed-off-by: Henry Robinson --- go/vt/vtgateproxy/discovery.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go/vt/vtgateproxy/discovery.go b/go/vt/vtgateproxy/discovery.go index 8bef891b485..b0ecd5c1281 100644 --- a/go/vt/vtgateproxy/discovery.go +++ b/go/vt/vtgateproxy/discovery.go @@ -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]))) }