Skip to content
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

PostData.MultiJson broken when direct streaming is disabled #150

Closed
dawust opened this issue Dec 11, 2024 · 2 comments
Closed

PostData.MultiJson broken when direct streaming is disabled #150

dawust opened this issue Dec 11, 2024 · 2 comments

Comments

@dawust
Copy link
Contributor

dawust commented Dec 11, 2024

Elastic.Clients.Elasticsearch version: 8.16.1 (works in 8.14.6)

When writing data using PostData.MultiJson, the FinishStream(Async) method is incorrectly duplicating data into the same buffer when disableDirectStreaming is set to true. This happens because BufferIfNeeded modifies writableStream by reference to use a newly created MemoryStream buffer, but FinishStream later uses the same writableStream (now the buffer) for copying, resulting in self-copying and data duplication.

Steps to Reproduce

Use PostData.MultiJson with disableDirectStreaming set to true.
Observe that the data in WrittenBytes is duplicated.

Solution
I think, the issue can be resolved by introducing a local variable stream to hold the current writing stream, ensuring that the original writableStream remains distinct from the buffer. The local stream is used for writing data, while the original writableStream is used correctly in FinishStream.

#149

@grokpot
Copy link

grokpot commented Dec 12, 2024

I'm also affected by this.

@kevin-mueller
Copy link

Same here

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

4 participants