-
Notifications
You must be signed in to change notification settings - Fork 345
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
Add send error logic for connection #566
Add send error logic for connection #566
Conversation
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
ping @zymap PTAL |
pulsar/internal/connection.go
Outdated
if ok { | ||
producer.ConnectionClosed() | ||
} else { | ||
c.log. |
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.
wrong indentation?
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.
No, this is automatically formatted by golanglint, probably for aesthetic reasons
pulsar/internal/connection.go
Outdated
c.listenersLock.RUnlock() | ||
|
||
if ok { | ||
producer.ConnectionClosed() |
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.
In the Java implementation, we change the state to terminate and send the error to all pending messages, does the producer connection closed will do the same thing with that?
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.
Why is this called and the connection is not closed? What should the behavior be when this error happens? What do the other clients do? Calling producer.ConnectionClosed() when we don't close connection make the code confusing in my opinion.
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.
Nothing here is to send a connection closed signal to runEventsLoop, try to trigger the logic of reconnection
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.
The java client closes the connection in the default case.
Should we do the same. What should the expected client behavior be here?
pulsar/internal/connection.go
Outdated
producerID := sendError.GetProducerId() | ||
|
||
SendError: | ||
switch *sendError.Error { |
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.
We also handle the ChecksumError
in the java implementation, do we need to implement that?
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.
How do the other clients handle this and is the correct behavior (send signal to producer, close producer, close connection, etc..)?
pulsar/internal/connection.go
Outdated
c.listenersLock.RUnlock() | ||
|
||
if ok { | ||
producer.ConnectionClosed() |
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.
Why is this called and the connection is not closed? What should the behavior be when this error happens? What do the other clients do? Calling producer.ConnectionClosed() when we don't close connection make the code confusing in my opinion.
pulsar/internal/connection.go
Outdated
|
||
errMsg := fmt.Sprintf("server error: %s: %s", cmdError.GetError(), cmdError.GetMessage()) | ||
request.callback(nil, errors.New(errMsg)) | ||
break SendError |
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.
I'm not following why there needs to be a break to SendError?
Warn("[HandleSendError] connection closed") | ||
} | ||
break SendError | ||
default: |
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.
Is the pending request callback not needed in the default case?
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
There is currently no good idea to deal with TopicTerminatedError, so it is temporarily not supported. |
@@ -33,7 +33,9 @@ func (t *ProducerInterceptor) BeforeSend(producer pulsar.Producer, message *puls | |||
buildAndInjectSpan(message, producer).Finish() | |||
} | |||
|
|||
func (t *ProducerInterceptor) OnSendAcknowledgement(producer pulsar.Producer, message *pulsar.ProducerMessage, msgID pulsar.MessageID) { | |||
func (t *ProducerInterceptor) OnSendAcknowledgement(producer pulsar.Producer, |
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.
Can we revert these formatting changes since they have nothing to do with this change?
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.
This will cause Action CI to fail:
Error: pulsar/internal/pulsartracing/producer_interceptor.go:36: line is 136 characters (lll)
func (t *ProducerInterceptor) OnSendAcknowledgement(producer pulsar.Producer, message *pulsar.ProducerMessage, msgID pulsar.MessageID) {
Error: pulsar/internal/pulsartracing/producer_interceptor_test.go:58: line is 132 characters (lll)
func (p *mockProducer) SendAsync(context.Context, *pulsar.ProducerMessage, func(pulsar.MessageID, *pulsar.ProducerMessage, error)) {
Error: Process completed with exit code 1.
pulsar/internal/connection.go
Outdated
c.listenersLock.RUnlock() | ||
|
||
if ok { | ||
producer.ConnectionClosed() |
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.
The java client closes the connection in the default case.
Should we do the same. What should the expected client behavior be here?
pulsar/internal/connection.go
Outdated
|
||
switch *sendError.Error { | ||
case pb.ServerError_NotAllowedError: | ||
c.pendingLock.Lock() |
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.
This block of code is used in a couple of places now maybe we should add a function? Something like this?
func deletePendingRequest(requestID) (request, bool) {
c.pendingLock.Lock()
defer c.pendingLock.Unlock()
request, ok := c.pendingReqs[requestID]
if ok {
delete(c.pendingReqs, requestID)
}
return request, ok
}
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.
Good ideas for this.
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.
The java client closes the connection in the default case.
Should we do the same. What should the expected client behavior be here?
About this, Look at the comments like reconnect, look at the code like close the current connection:
// By default, for transient error, let the **reconnection** logic
// to take place and re-establish the produce again
ctx.close();
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
Signed-off-by: xiaolongran xiaolongran@tencent.com
Fixes #564
Motivation
Add command of SendError logic for connection