question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deserialization in parallel causes invalid objects

See original GitHub issue

NEST/Elasticsearch.Net version: 5.6.6

Elasticsearch version: 5.6.3

Description of the problem including expected versus actual behavior: Actual: When deserializing a GeoJson object using NTS the properties data is duplicated from one entity to the other. Expected: Data should not “leak”.

Steps to reproduce:

  1. Query the database using search in parallel
  2. Test the results It doesn’t happen all the time, it happens from time to time which I believe is related to timing and multithread stuff… Code can be seen here: https://github.com/IsraelHikingMap/Site/blob/master/IsraelHiking.DataAccess/ElasticSearchGateway.cs#L381L401

Expected behavior There shouldn’t be a “memory override”

Provide ConnectionSettings (if relevant): https://github.com/IsraelHikingMap/Site/blob/master/IsraelHiking.DataAccess/ElasticSearchGateway.cs#L66L75 Most of the info can be found in the following thread, I don’t know if the problem is here or in the deserialization code in the NTS library… 😦 The comment below and afterwards is the relevant discussion. There are also elastic dump there. https://github.com/NetTopologySuite/NetTopologySuite.IO.GeoJSON/issues/46#issuecomment-636530155

Provide DebugInformation (if relevant): Can be found in the above issue.

Any help would be greatly appreciated. Running on .net core 3.1 windows server 2012 R2.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:25 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
russcamcommented, Jun 23, 2020

@HarelM Stating that no one wants to take care of it is a mischaracterisation. At the moment, there is not a clear reproducible example to demonstrate the issue, requiring an investment in time and effort to come up with one and investigate. In addition, the issue is for a version no longer supported and it’s not clear that the issue is with the client. This is why I think a minimal reproducible example is so important; it removes all extraneous variables, reducing the problem space to one that can expedite investigation 😃

The fact that ES is not creating a new serializer every time is what I believe is causing this issue.

Json.NET’s JsonSerializer is thread safe as far as I know. The use of StreamingContext makes assumptions about how JsonSerializer is consumed, which may not hold for a JsonSerializer outside of the control of where such assumptions are made. For example, in the case of MultiSearch where a given search response is tied to a document type T, a new serializer may be created to handle that

https://github.com/elastic/elasticsearch-net/blob/641df53f5fa646648bc9cfb8d14d5ef11041f30a/src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsBase.cs#L100-L101

which may break the assumptions that the usage of StreamingContext is relying on. A simple reproducible example on a supported version would help to better understand what is at play.

1reaction
russcamcommented, Oct 29, 2020

Great to hear that the issue is now resolved, @HarelM. Closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deserialization InvalidClassException (No valid constructor ...
I'm trying to serialize an object and then deserialize it after sending its data to a client program. Here's an example of how...
Read more >
Deserialized JSON with Invalid Ids are ignored silently
Below String has invalid Id for Lookup(Contact). But it's deserialized without an error, which I hope is okay. My concern is Update DML...
Read more >
Xml Deserialization in C# - Code Maze
The InvalidOperationException is a common exception that may occur during XML deserialization. It typically indicates that the XML data does not ...
Read more >
Marshmallow: Serialization and Deserialization Like a Pro
Easy serialization and deserialization: Marshmallow makes it easy to convert complex Python objects to and from JSON, YAML, or other formats.
Read more >
serde is one of the best things about Rust in practice. It is ...
These concerns are valid. Data serialization/deserialization is an extremely standard thing to need to be able to do. It's not the user's fault ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found