-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[ServerCnx] Only reply to client when code completes producerFuture #13949
[ServerCnx] Only reply to client when code completes producerFuture #13949
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM +1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@Jason918 - thank you for calling this out, sorry about that misattribution. I noticed the code today when looking at recent changes, but I failed to dig deep enough to know that it predated your commit. I updated the PR description. I did inspect the rest of the class today, and I don't see the behavior anywhere else. |
We should apply this change carefully. If the client is like the followings:
In my opinion, we should handle such case in the following principles:
I think it's the more easy and clear way to handle both the client-side and server-side. And currently, the client-side also follow this way https://github.com/apache/pulsar/blob/master/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java#L534, https://github.com/apache/pulsar/blob/master/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java#L719 |
A related discussion before: #13245 |
This is a valid concern. However, the client is supposed to send a The consequence of my proposed PR: if a client does not follow the protocol spec, it will not receive a response (step 6), then the client will timeout waiting for a response and then it'll retry and succeed (or fail). I agree that we need to be careful implementing this. I wouldn't cherry pick these changes to previous branches. However, as I have mentioned elsewhere, I think this is the right design because we should only respond to a client once.
I don't think we need to design for this case because the client is not supposed to send two
In both of these examples, the client will log warning messages if it receives responses for requests that are already completed. Those warnings won't be actionable. I think we should respond to client requests just once. |
Yes, I'm also talking about this one, the only difference is the behavior of the client-side sending multiple requests with the same producer ID. Two options we are talking about:
I would tend to the second one. |
This is already the current behavior. See: pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java Lines 1175 to 1201 in f48b53d
I agree that sending a failure is the right design, since the client is not following the protocol spec (it shouldn't try to create the same producer twice). Although, technically, if the producer is already created, we just respond that it was created successfully. I am not sure that I like this design, but that is a different discussion. I described in detail why it is problematic if the client does not send the
This is another reason why the broker shouldn't respond if the producer future is already completed: it gets completed when the client sends a |
@michaeljmarshall Thanks for the explanation, LGTM.
Yes, it should be a different discussion, I think we should return such as a |
@codelipenghui - that's a great point, and I support exploring a change to the behavior. I just looked at the git history, and we've responded to this behavior with a |
…he#13949) ### Motivation We should only send the error response to the client when the code is able to complete the `producerFuture`. This logic is described here: https://github.com/apache/pulsar/blob/2285d02aa9957af7877b9d3d3c628a750d813ca7/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java#L1286-L1293 Edit: in a previous version of this motivation section, I attributed the current behavior to apache#12874. That PR did not introduce this behavior, though. ### Modifications * Move the response to the client into a conditional block that only runs when this section of the code is able to complete the future.
Motivation
We should only send the error response to the client when the code is able to complete the
producerFuture
. This logic is described here:pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
Lines 1286 to 1293 in 2285d02
Edit: in a previous version of this motivation section, I attributed the current behavior to #12874. That PR did not introduce this behavior, though.
Modifications
Verifying this change
This is a trivial change.
Does this pull request potentially affect one of the following parts:
It impacts how the broker interacts with the client. This change ensures that we have the correct behavior.
Documentation
no-need-doc
This change is completely internal.