-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Disallow calling blockUntilReady from main thread #3778
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
Disallow calling blockUntilReady from main thread #3778
Conversation
Also fix a data race that apparently hasn't been ported to 6.2 yet
|
The C API documentation should also be updated to reflect this change. |
|
I would be in favor of a new error code if you want to add one. Either that, or I guess we could try to make it consistent how we report the failure for these generic errors. I've found it's sometimes been difficult trying to help someone else diagnose errors like |
|
I'll update the documentation and add a new error code |
I'm not sure how exactly to change it. It's accurate as is, and I don't want to encourage anyone to rely on the new "throws a particular error" behavior |
|
From the C API documentation:
This is no longer accurate, you can also throw an error if you call this from the main thread.
The advice still holds, but this won't cause deadlock anymore. |
|
I'm going to change this so that it only throws if the future is not ready, since it's possible that there are users who rely on the current behavior of fdb_future_block_until_ready not blowing up if you call it from the network thread and it's ready (even though the documentation advises against that) |
As described in https://apple.github.io/foundationdb/api-c.html?highlight=fdb_future_block_until_ready#c.fdb_future_block_until_ready, it's an error to call fdb_future_block_until_ready from the main thread (the one running fdb_run_network). This PR changes the current behavior of deadlocking (difficult to debug and to know what to do to recover from it) to throwing an error and tracing a diagnostic.
I'm also wondering if it would be even better to have a new error code for this, in case the client doesn't have tracing enabled.