|
|
@ -535,11 +535,16 @@ func queryFailover(q queryServer, query *structs.PreparedQuery,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now try the selected DCs in priority order. Note that we pass along
|
|
|
|
// Now try the selected DCs in priority order.
|
|
|
|
// the limit since it can be applied remotely to save bandwidth. We also
|
|
|
|
failovers := 0
|
|
|
|
// pass along the consistency mode information we were given, so that
|
|
|
|
for _, dc := range dcs {
|
|
|
|
// applies to the remote query as well.
|
|
|
|
// This keeps track of how many iterations we actually run.
|
|
|
|
for i, dc := range dcs {
|
|
|
|
failovers++
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Note that we pass along the limit since it can be applied
|
|
|
|
|
|
|
|
// remotely to save bandwidth. We also pass along the consistency
|
|
|
|
|
|
|
|
// mode information we were given, so that applies to the remote
|
|
|
|
|
|
|
|
// query as well.
|
|
|
|
remote := &structs.PreparedQueryExecuteRemoteRequest{
|
|
|
|
remote := &structs.PreparedQueryExecuteRemoteRequest{
|
|
|
|
Datacenter: dc,
|
|
|
|
Datacenter: dc,
|
|
|
|
Query: *query,
|
|
|
|
Query: *query,
|
|
|
@ -551,14 +556,15 @@ func queryFailover(q queryServer, query *structs.PreparedQuery,
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Keep track of the number of failovers.
|
|
|
|
|
|
|
|
reply.Failovers = i + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We can stop if we found some nodes.
|
|
|
|
// We can stop if we found some nodes.
|
|
|
|
if len(reply.Nodes) > 0 {
|
|
|
|
if len(reply.Nodes) > 0 {
|
|
|
|
break
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set this at the end because the response from the remote doesn't have
|
|
|
|
|
|
|
|
// this information.
|
|
|
|
|
|
|
|
reply.Failovers = failovers
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|