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

close socket after a complete write in TcpClient output #1247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ganxiyun
Copy link

I have many java processes running in output=tcpclient mode, the process keeps running a bit long.

When I check the log in the server side (on which tcpclient connects to), I see several EOFException.

image

After some investigation, the socket might be closed in client side while the RemoteControlWriter is still writing data to server side, therefore the server receives partial data and throws EOFException.

I can see such EOFException happening almost every time in my case (Many connections with long running period), although not big problem, I create this PR trying to fix it. Please kindly have a review.

@ganxiyun
Copy link
Author

Seems now it has build error which is irrelevant to the PR?

@Godin
Copy link
Member

Godin commented Nov 16, 2021

Seems now it has build error which is irrelevant to the PR?

yes it was unrelated - see #1249

@ganxiyun
Copy link
Author

Anyone who can kindly review this?

@marchof
Copy link
Member

marchof commented Dec 19, 2021

Did you already test this fix? Does it solve the problem you observe?

@ganxiyun
Copy link
Author

Hi @marchof I have manually tested local (not by unit test, I deliberately added some code to simulate multi-threading execution) and didn't observe the problem currently.

@marchof
Copy link
Member

marchof commented Dec 20, 2021

@ganxiyun I mean does this patch resolve the problem in your setup that you describe at the beginning?

@ganxiyun
Copy link
Author

@marchof YES. After applying this patch, I didn't observe the problem currently.

@marchof
Copy link
Member

marchof commented Dec 20, 2021

@ganxiyun Ok, thanks for the info!

I'm a bit reluctant to merge this without fully understanding the impact. My questions are:

  • TcpConnectionis also use in tcpserver mode. Do we have any sieffects here (deadlock)?
  • The close() method is called during VM shutdown. Is it a good idea to potentially block the shutdown sequence?

@ganxiyun
Copy link
Author

ganxiyun commented Dec 22, 2021

@marchof I could understand you concern.

TcpConnection is also use in tcpserver mode. Do we have any sieffects here (deadlock)?

I checked the code and class diagram (generated by Intellij) in TcpConnection, RemoteControlWriter, RuntimeData, ExecutionDataStore, and ExecutionData, there is no circular dependency, which breaks the Circular wait condition in deadlock. I think no deadlock here. For other sieffects, as you mentioned below, I will answer with my understanding.

The close() method is called during VM shutdown. Is it a good idea to potentially block the shutdown sequence?

If all data has been written to the socket before calling close(), there is no difference from the current implementation.
If it's in writing data sync block, I think waiting for writing is better, like flush the cache before closing. Usually it won't take long time. In case of write failure, exception will occur so the developers have the chance to know the problem.

multi-threading is not easy to test etc., your review opinion values a lot.

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

Successfully merging this pull request may close these issues.

None yet

3 participants