translate data: only redirect to UNKNOWN node if there is no STARTED

caveat: this will always redirect to the first UNKNOWN
node... possibly we would want to select randomly or have the ability
to retry different nodes.
This commit is contained in:
Matthew Jaffee 2022-04-28 13:08:08 -05:00 committed by Matthew Jaffee
parent f7651e3a26
commit cb4f23fc98

9
api.go
View file

@ -867,10 +867,15 @@ func (api *API) TranslateData(ctx context.Context, indexName string, partition i
var upNode *topology.Node
for _, node := range nodes {
// we all UNKNOWN state here because we often mistakenly think
// a node is not up under heavy load.
if node.State == disco.NodeStateStarted || node.State == disco.NodeStateUnknown {
// a node is not up under heavy load, but prefer STARTED if we
// find one.
if node.State == disco.NodeStateStarted {
upNode = node
break
} else if node.State == disco.NodeStateUnknown {
if upNode != nil {
upNode = node
}
}
}