GetMany returns empty list after connection failure
See original GitHub issueNEST/Elasticsearch.Net version: 5.5.0 Elasticsearch version: 5.5.1
If I start with either elasticsearch down or simulated connection failures (using Fiddler to auto respond with 502) I’ll get a PipelineException on the first GetMany. If I start with a working cluster, which succeeds on the first call, and then close the connection or kill elastic before the second call, it will not throw an exception but return empty list instead.
The low level client returns an unsuccessful response in the second case which is good but the inconsistency in throwing was causing us to miss exceptions if the access to the cluster becomes unstable.
I know exceptions are off in the connection string but returning an empty list is very misleading?
Thanks.
Steps to reproduce:
var serverLocation = "localhost:9200";
var uri = new Uri("http://" + serverLocation);
var sniffingConnectionPool = new SniffingConnectionPool(new List<Uri>() { uri });
var connectionSettings = new ConnectionSettings(sniffingConnectionPool);
connectionSettings
.DisableDirectStreaming()
.SniffOnConnectionFault()
.SniffLifeSpan(TimeSpan.FromSeconds(300));
var client = new ElasticClient(connectionSettings);
var ids = new List<string> { "123" };
var postData = new Dictionary<string, IEnumerable<string>> { { "ids", ids } };
var index = "index";
var type = "type";
IEnumerable<IMultiGetHit<object>> response1 = client.GetMany<object>(ids, index, type);
// stop elastic
Thread.Sleep(5000);
IEnumerable<IMultiGetHit<object>> response2 = client.GetMany<object>(ids, index, type);
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Cool, thanks for the suggestion @russcam. We’ve sorted it out eventually but were caught off guard by the inconsistency.
This will be fixed in
6.x
onwards as per #2987Thanks for raising this @srgclr 👍