-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Remove as many Thread.sleep calls from REST endpoint #1355
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
Conversation
|
@mgodave This change doesn't solve the problem that the ugly The problem is not the sync vs async ZK call (though sure, the async with response continuation is more efficient). The real problem is that in ZK there is no read-your-write consistency by default. That is also aggravated by the fact the we have a cache for configuration/metadata that is updated with ZK watches. The particular instance of the problem typically manifest itself only in a test environment where there are multiple brokers and multiple ZK servers in the ensemble. It goes like this:
The "good" solution would be to always do a ZK The problem with that is that we have to do a ZK write (implied by
|
|
The point is, sleeping a thread in the REST endpoint is a resource hog and generally not a great idea. |
|
I think I see what you are saying. Either way, scheduling a return after the sync timeout would be a better option. |
I'm not debating that :)
Definitely. It's still hacky but at least we don't keep the thread hanging. |
|
Feel free to close it.
…On Mar 7, 2018 11:43, "Matteo Merli" ***@***.***> wrote:
The point is, sleeping a thread in the REST endpoint is a resource hog and
generally not a great idea.
I'm not debating that :)
I think I see what you are saying. Either way, scheduling a return after
the sync timeout would be a better option.
Definitely. It's still hacky but at least we don't keep the thread hanging.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1355 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAh9FgmREEPx8-ZsIDyQWCaI3jUr8aEnks5tcCpAgaJpZM4Sg5AV>
.
|
There is read-your-writes within a session. However, which zookeeper client cache thing seems to be able to handle some errors by creating a new client. And it's caching data, only updating with watchers. There's no guarantee that when your create succeeds the watchers will have run. Quite the opposite in fact, as the server will respond with success for the write first and then trigger the watchers. I think the sleep is trying to solve a different problem though. It's not to ensure that the local client has seen update, but to try to ensure that all brokers have seen it, which is perfectly natural in distsys. |
*Motivation* We should use the original role to verify if it is allowed for a given topic operation (cherry picked from commit 6734ab6)
*Modifications* - We should use the original role to verify if it is allowed for a given topic operation - use the original authentication data - Authz provider doesn't have to be aware of proxyRole - Fix authorization test
…#1355) (#7788) * Fix allowTopicOperationAsync logic (#1355) *Modifications* - We should use the original role to verify if it is allowed for a given topic operation - use the original authentication data - Authz provider doesn't have to be aware of proxyRole - Fix authorization test * Refactor authorize logic to provide a uniform authorization behavior
…#1355) (#7788) * Fix allowTopicOperationAsync logic (#1355) *Modifications* - We should use the original role to verify if it is allowed for a given topic operation - use the original authentication data - Authz provider doesn't have to be aware of proxyRole - Fix authorization test * Refactor authorize logic to provide a uniform authorization behavior (cherry picked from commit 48f5a2f)
…apache#1355) (apache#7788) * Fix allowTopicOperationAsync logic (apache#1355) *Modifications* - We should use the original role to verify if it is allowed for a given topic operation - use the original authentication data - Authz provider doesn't have to be aware of proxyRole - Fix authorization test * Refactor authorize logic to provide a uniform authorization behavior
…apache#1355) (apache#7788) * Fix allowTopicOperationAsync logic (apache#1355) *Modifications* - We should use the original role to verify if it is allowed for a given topic operation - use the original authentication data - Authz provider doesn't have to be aware of proxyRole - Fix authorization test * Refactor authorize logic to provide a uniform authorization behavior
…apache#1355) (apache#7788) * Fix allowTopicOperationAsync logic (apache#1355) *Modifications* - We should use the original role to verify if it is allowed for a given topic operation - use the original authentication data - Authz provider doesn't have to be aware of proxyRole - Fix authorization test * Refactor authorize logic to provide a uniform authorization behavior
…apache#1355) (apache#7788) * Fix allowTopicOperationAsync logic (apache#1355) *Modifications* - We should use the original role to verify if it is allowed for a given topic operation - use the original authentication data - Authz provider doesn't have to be aware of proxyRole - Fix authorization test * Refactor authorize logic to provide a uniform authorization behavior
…apache#1355) (apache#7788) * Fix allowTopicOperationAsync logic (apache#1355) *Modifications* - We should use the original role to verify if it is allowed for a given topic operation - use the original authentication data - Authz provider doesn't have to be aware of proxyRole - Fix authorization test * Refactor authorize logic to provide a uniform authorization behavior
…apache#1355) (apache#7788) * Fix allowTopicOperationAsync logic (apache#1355) *Modifications* - We should use the original role to verify if it is allowed for a given topic operation - use the original authentication data - Authz provider doesn't have to be aware of proxyRole - Fix authorization test * Refactor authorize logic to provide a uniform authorization behavior (cherry picked from commit 48f5a2f)
Thread.sleep is rarely the correct answer as it can lead to race conditions and incorrect results. In this case sleeping the tread will tie up an entire thread in the REST endpoint. The operations that are being slept are themselves async and can easily be represented as Futures (CompletableFutures). Furthermore the REST framework we are using supports async results. This has the benefit of still allowing timeouts on the endpoint, allowing an operation to fail or complete, and not tie up an entire serving thread while an already async operation completes. There is still one remaining Thread.sleep that I would like to squash but I wanted to put this work up for consideration.