-
Notifications
You must be signed in to change notification settings - Fork 245
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
Race condition when sending messages from another thread #354
Comments
Fun fact: on further testing, you ideally send an async |
The scenario you described sounds related to https://github.com/tomerfiliba/rpyc/blob/master/rpyc/core/protocol.py#L415-L419 |
Sounds related indeed, though the serve_threaded function isn't involved in the race identified here (except for calling serve()). I haven't tested the new version yet, but the relevant code is unchanged:
Basically, the AsyncResult needs to check |
As an update, I added some debugging documentation. A PDF of the TCP stream that the race condition occurs would help me create a unit test to prevent the issue in the future. If there is any concern about confidentiality, you could always encrypt it with my PGP and email under my profile. |
@comrumino : Do you have a CLA for us to sign, to assign rights? We've got a PR we could send up that might better illuminate what's going on (which depends on another PR to be viable). |
Nothing to sign, but I use TLDRLegal. I think CLAs mostly apply to restrictive IP rights. Even so, the license agreement covers your rights. I always welcome PRs or any other effort that makes my life easier 😄 |
The exact same issue also happens when a BgServingThread steals the async response data, and flags the object while the originator starts polling(). |
DemonOne, are you using the At the moment, serving connections could be made harder to use wrong: improve resource acquisition of connections such that only one thread is serving a given connection until released or thread is closed. My initial impression is that implementing a solution to reroute or better propagate would have a measurable performance impact; allowing RPyC streams/channels/connections to handle response data would be more efficient and consistent typical socket usage. |
@comrumino (it's me, DemonOne) The problem as I see it:
I managed to recreate this in a ratio of around 3-5 per 100 calls (in an internal tool I'm writing) |
@wumb0 @comrumino |
I solved something like this by using serve_threaded instead of serve_all.
Try that out and see if it makes a difference. Like I said in my PR there's
still a larger issue at play here (obviously).
…On Sun, Sep 19, 2021, 5:59 PM TI-AviBerko ***@***.***> wrote:
@wumb0 <https://github.com/wumb0> @comrumino
<https://github.com/comrumino>
Regarding the fix in #455
<#455> - in my use case the
async timeout is infinite, one of the threads can reach server() before the
_is_ready is signaled, and block forever.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#354 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHV3WY5EJMRZHX4RVS65ADUCZMK5ANCNFSM4JCJH67Q>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Thanks, but I don't think that's related. I do agree about the larger issue, maybe it'll be easier to concentrate the networking in one context. |
@TI-AviBerko @wumb0 @benoithudson is everyone here using either serve_threaded or BgServingThread? After another crack at this issue, here are my thoughts. From serve_threaded, I found this to be a refresher on the topic.
If I were to rephrase/correct this, after my most recent commits, I would make the argument that the I still need to check if Comments? |
Relates/impacts #482 since multiprocess is a more complex scenario. Minimally documentation could be better. |
Even with added support around threading for RPyC there will still be limitations due to fork https://www.evanjones.ca/fork-is-dangerous.html |
We're seeing a race that occasionally causes a 30-second lag. The precise scenario:
So there's no data loss, no unexpected exceptions, just 30 seconds wasted, once in a while.
Workaround: have the client ping every second, so that the waste is at most 1 second (because in step 9, thread B's poll doesn't time out it just handles the ping).
We haven't minimized the example yet.
Environment
This issue is presumably platform-independent.
The text was updated successfully, but these errors were encountered: