Skip to content

ElasticLowLevelClient with SniffingConnectionPool fails to make any request due to SniffResponse deserialization failure #3582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AndrewKostousov opened this issue Mar 3, 2019 · 4 comments

Comments

@AndrewKostousov
Copy link

NEST/Elasticsearch.Net version: 6.5.0 and master

Elasticsearch version: 6.2.3 (I believe server version is irrelevant for this issue)

Description of the problem including expected versus actual behavior:
When using SniffingConnectionPool in ElasticLowLevelClient basically every its method fails with Elasticsearch.Net.PipelineException : Failed sniffing cluster state.

Steps to reproduce:

  1. Add nunit test project to Elasticsearch.sln:
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="nunit" Version="3.11.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.11.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Elasticsearch.Net\Elasticsearch.Net.csproj" />
  </ItemGroup>
</Project>
  1. Add test case:
[Test]
public void SniffResponseParsingFailure()
{
  var sniffingConnectionPool = new SniffingConnectionPool(new []{new Uri("http://localhost:9200")});
  var elasticClient = new ElasticLowLevelClient(new ConnectionConfiguration(sniffingConnectionPool));
  var response = elasticClient.ClusterHealth<DynamicResponse>();
  Console.Out.WriteLine(response);
}

Stacktrace obtained on master (SHA-1: 682a8f7):

Elasticsearch.Net.PipelineException : Failed sniffing cluster state.
  ----> System.ArgumentException : Incorrect number of arguments supplied for call to method 'Void set_Item(System.String, Elasticsearch.Net.NodeInfo)'
   at Elasticsearch.Net.RequestPipeline.Sniff() in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Transport\Pipeline\RequestPipeline.cs:line 451
   at Elasticsearch.Net.RequestPipeline.FirstPoolUsage(SemaphoreSlim semaphore) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Transport\Pipeline\RequestPipeline.cs:line 279
   at Elasticsearch.Net.Transport`1.Request[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Transport\Transport.cs:line 58
   at Elasticsearch.Net.ElasticLowLevelClient.DoRequest[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\ElasticLowLevelClient.cs:line 45
   at Elasticsearch.Net.ElasticLowLevelClient.ClusterHealth[TResponse](ClusterHealthRequestParameters requestParameters) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\ElasticLowLevelClient.Generated.cs:line 402
   at Tests.Tests.SniffResponseParsingFailure() in C:\projects\open-source\elasticsearch-net\src\NUnitTestProject1\UnitTest1.cs:line 14
--ArgumentException
   at System.Linq.Expressions.Expression.ValidateArgumentCount(MethodBase method, ExpressionType nodeKind, Int32 count, ParameterInfo[] pis)
   at System.Linq.Expressions.Expression.ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ReadOnlyCollection`1& arguments)
   at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)
   at Elasticsearch.Net.ReflectionUtils.GetSetMethodByExpression(PropertyInfo propertyInfo) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\SimpleJson.cs:line 1924
   at Elasticsearch.Net.ReflectionUtils.GetSetMethod(PropertyInfo propertyInfo) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\SimpleJson.cs:line 1891
   at Elasticsearch.Net.PocoJsonSerializerStrategy.SetterValueFactory(Type type) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\SimpleJson.cs:line 1273
   at Elasticsearch.Net.ReflectionUtils.ThreadSafeDictionary`2.AddValue(TKey key) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\SimpleJson.cs:line 1983
   at Elasticsearch.Net.ReflectionUtils.ThreadSafeDictionary`2.Get(TKey key) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\SimpleJson.cs:line 1977
   at Elasticsearch.Net.ReflectionUtils.ThreadSafeDictionary`2.get_Item(TKey key) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\SimpleJson.cs:line 2037
   at Elasticsearch.Net.PocoJsonSerializerStrategy.DeserializeObject(Object value, Type type) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\SimpleJson.cs:line 1380
   at Elasticsearch.Net.ElasticsearchNetJsonStrategy.DeserializeObject(Object value, Type type) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\ElasticsearchNetJsonStrategy.cs:line 123
   at Elasticsearch.Net.PocoJsonSerializerStrategy.DeserializeObject(Object value, Type type) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\SimpleJson.cs:line 1386
   at Elasticsearch.Net.ElasticsearchNetJsonStrategy.DeserializeObject(Object value, Type type) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\ElasticsearchNetJsonStrategy.cs:line 123
   at Elasticsearch.Net.SimpleJson.DeserializeObject(String json, Type type, IJsonSerializerStrategy jsonSerializerStrategy) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\SimpleJson.cs:line 562
   at Elasticsearch.Net.LowLevelRequestResponseSerializer.Deserialize(Type type, Stream stream) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\LowLevelRequestResponseSerializer.cs:line 26
   at Elasticsearch.Net.LowLevelRequestResponseSerializer.Deserialize[T](Stream stream) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Serialization\LowLevelRequestResponseSerializer.cs:line 30
   at Elasticsearch.Net.ResponseBuilder.SetBody[TResponse](ApiCallDetails details, RequestData requestData, Stream responseStream, String mimeType) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Transport\Pipeline\ResponseBuilder.cs:line 103
   at Elasticsearch.Net.ResponseBuilder.ToResponse[TResponse](RequestData requestData, Exception ex, Nullable`1 statusCode, IEnumerable`1 warnings, Stream responseStream, String mimeType) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Transport\Pipeline\ResponseBuilder.cs:line 31
   at Elasticsearch.Net.HttpConnection.Request[TResponse](RequestData requestData) in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Connection\HttpConnection.cs:line 76
   at Elasticsearch.Net.RequestPipeline.Sniff() in C:\projects\open-source\elasticsearch-net\src\Elasticsearch.Net\Transport\Pipeline\RequestPipeline.cs:line 429

Some analysis:

  1. The problem does not appear in Elasticsearch.Net v6.4.0.
  2. I believe it was introduced with PR #3071 where #if NETFX_CORE || DOTNETCORE directive was removed for #define SIMPLE_JSON_TYPEINFO in SimpleJson.cs. At least when I commented out this #define SIMPLE_JSON_TYPEINFO directive my test has passed.
@AndrewKostousov AndrewKostousov changed the title ElasticLowLevelClient with SniffingConnectionPool fails to make any requests due to SniffResponse deserialization failure ElasticLowLevelClient with SniffingConnectionPool fails to make any request due to SniffResponse deserialization failure Mar 3, 2019
@Mpdreamz
Copy link
Member

Mpdreamz commented Mar 4, 2019

Thank you so much for reporting this this was introduced in:

4c08a6e

As part of #3483

This brought SIMPLE_JSON_TYPEINFO back in to play which is not needed as our baseline is netstandard2.0

This affects the low level client starting from 6.4.1 and 5.6.5 on the 5.x releases. The highlevel client or using the high level client through client.LowLevel is not affected.

We will rectify this as soon as possible

Mpdreamz added a commit that referenced this issue Mar 4, 2019
…used netstandard and netfx exceptions when deserializing sniff responses, but would light up in different places as well
Mpdreamz added a commit that referenced this issue Mar 4, 2019
…used netstandard and netfx exceptions when deserializing sniff responses, but would light up in different places as well

(cherry picked from commit c49736a)
@AndrewKostousov
Copy link
Author

Cool! Waiting for updated package on nuget :-)

russcam pushed a commit that referenced this issue Mar 6, 2019
…used netstandard and netfx exceptions when deserializing sniff responses, but would light up in different places as well (#3586)
@russcam russcam closed this as completed in 31934c9 Mar 6, 2019
russcam pushed a commit that referenced this issue Mar 6, 2019
* fix #3582 #3483 introduced SIMPLE_JSON_TYPEDEF to be defined which caused netstandard and netfx exceptions when deserializing sniff responses, but would light up in different places as well

(cherry picked from commit c49736a)

* update assertion to be 5.x specific
@russcam
Copy link
Contributor

russcam commented Mar 7, 2019

@AndrewKostousov the fix for this is now in 6.5.1 on nuget

@AndrewKostousov
Copy link
Author

Thanks!

SukharevAndrey pushed a commit to SukharevAndrey/elasticsearch-net that referenced this issue Mar 13, 2019
…fined which caused netstandard and netfx exceptions when deserializing sniff responses, but would light up in different places as well (elastic#3586)

(cherry picked from commit 0c5c092)
fakefeik pushed a commit to skbkontur/cassandra-distributed-task-queue that referenced this issue Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants