wolfstudy commented on a change in pull request #622:
URL: https://github.com/apache/pulsar-client-go/pull/622#discussion_r718151165
##########
File path: pulsar/internal/connection.go
##########
@@ -752,38 +752,51 @@ func (c *connection) handleAuthChallenge(authChallenge
*pb.CommandAuthChallenge)
c.writeCommand(baseCommand(pb.BaseCommand_AUTH_RESPONSE,
cmdAuthResponse))
}
-func (c *connection) handleSendError(cmdError *pb.CommandError) {
- c.log.Warnf("Received send error from server: [%v] : [%s]",
cmdError.GetError(), cmdError.GetMessage())
+func (c *connection) handleSendError(sendError *pb.CommandSendError) {
+ c.log.Warnf("Received send error from server: [%v] : [%s]",
sendError.GetError(), sendError.GetMessage())
- requestID := cmdError.GetRequestId()
+ producerID := sendError.GetProducerId()
- switch cmdError.GetError() {
+ c.listenersLock.RLock()
+ producerListener := c.listeners[producerID]
+ c.listenersLock.RUnlock()
+
+ switch sendError.GetError() {
case pb.ServerError_NotAllowedError:
- request, ok := c.deletePendingRequest(requestID)
+ _, ok := c.deletePendingProducers(producerID)
if !ok {
c.log.Warnf("Received unexpected error response for
request %d of type %s",
- requestID, cmdError.GetError())
+ producerID, sendError.GetError())
return
}
- errMsg := fmt.Sprintf("server error: %s: %s",
cmdError.GetError(), cmdError.GetMessage())
- request.callback(nil, errors.New(errMsg))
+ c.log.Warnf("server error: %s: %s", sendError.GetError(),
sendError.GetMessage())
case pb.ServerError_TopicTerminatedError:
- request, ok := c.deletePendingRequest(requestID)
+ _, ok := c.deletePendingProducers(producerID)
Review comment:
Yes, Agree with your ideas.
The first point: Here we really should deal with SendError Command, not
ErrorCommand. This should be determined. But the requestID is not included in
SendError.
The second point: This requestID should be obtained from the Protobuf
protocol. Processing PendingRequest needs to rely on requestID, so now I am
also a bit confused. After receiving SendError, what should we do here?
##########
File path: pulsar/internal/connection.go
##########
@@ -752,38 +752,51 @@ func (c *connection) handleAuthChallenge(authChallenge
*pb.CommandAuthChallenge)
c.writeCommand(baseCommand(pb.BaseCommand_AUTH_RESPONSE,
cmdAuthResponse))
}
-func (c *connection) handleSendError(cmdError *pb.CommandError) {
- c.log.Warnf("Received send error from server: [%v] : [%s]",
cmdError.GetError(), cmdError.GetMessage())
+func (c *connection) handleSendError(sendError *pb.CommandSendError) {
+ c.log.Warnf("Received send error from server: [%v] : [%s]",
sendError.GetError(), sendError.GetMessage())
- requestID := cmdError.GetRequestId()
+ producerID := sendError.GetProducerId()
- switch cmdError.GetError() {
+ c.listenersLock.RLock()
+ producerListener := c.listeners[producerID]
+ c.listenersLock.RUnlock()
+
+ switch sendError.GetError() {
case pb.ServerError_NotAllowedError:
- request, ok := c.deletePendingRequest(requestID)
+ _, ok := c.deletePendingProducers(producerID)
if !ok {
c.log.Warnf("Received unexpected error response for
request %d of type %s",
- requestID, cmdError.GetError())
+ producerID, sendError.GetError())
return
}
- errMsg := fmt.Sprintf("server error: %s: %s",
cmdError.GetError(), cmdError.GetMessage())
- request.callback(nil, errors.New(errMsg))
+ c.log.Warnf("server error: %s: %s", sendError.GetError(),
sendError.GetMessage())
case pb.ServerError_TopicTerminatedError:
- request, ok := c.deletePendingRequest(requestID)
+ _, ok := c.deletePendingProducers(producerID)
Review comment:
Yes, Agree with your ideas.
The first point: Here we really should deal with SendError Command, not
ErrorCommand. This should be determined. But the requestID is not included in
SendError.
The second point: This requestID should be obtained from the Protobuf
protocol. Processing PendingRequest needs to rely on requestID, so now I am
also a bit confused. After receiving SendError, what should we do here?
##########
File path: pulsar/internal/connection.go
##########
@@ -752,38 +752,51 @@ func (c *connection) handleAuthChallenge(authChallenge
*pb.CommandAuthChallenge)
c.writeCommand(baseCommand(pb.BaseCommand_AUTH_RESPONSE,
cmdAuthResponse))
}
-func (c *connection) handleSendError(cmdError *pb.CommandError) {
- c.log.Warnf("Received send error from server: [%v] : [%s]",
cmdError.GetError(), cmdError.GetMessage())
+func (c *connection) handleSendError(sendError *pb.CommandSendError) {
+ c.log.Warnf("Received send error from server: [%v] : [%s]",
sendError.GetError(), sendError.GetMessage())
- requestID := cmdError.GetRequestId()
+ producerID := sendError.GetProducerId()
- switch cmdError.GetError() {
+ c.listenersLock.RLock()
+ producerListener := c.listeners[producerID]
+ c.listenersLock.RUnlock()
+
+ switch sendError.GetError() {
case pb.ServerError_NotAllowedError:
- request, ok := c.deletePendingRequest(requestID)
+ _, ok := c.deletePendingProducers(producerID)
if !ok {
c.log.Warnf("Received unexpected error response for
request %d of type %s",
- requestID, cmdError.GetError())
+ producerID, sendError.GetError())
return
}
- errMsg := fmt.Sprintf("server error: %s: %s",
cmdError.GetError(), cmdError.GetMessage())
- request.callback(nil, errors.New(errMsg))
+ c.log.Warnf("server error: %s: %s", sendError.GetError(),
sendError.GetMessage())
case pb.ServerError_TopicTerminatedError:
- request, ok := c.deletePendingRequest(requestID)
+ _, ok := c.deletePendingProducers(producerID)
if !ok {
- c.log.Warnf("Received unexpected error response for
request %d of type %s",
- requestID, cmdError.GetError())
+ c.log.Warnf("Received unexpected error response for
producer %d of type %s",
+ producerID, sendError.GetError())
return
}
- errMsg := fmt.Sprintf("server error: %s: %s",
cmdError.GetError(), cmdError.GetMessage())
- request.callback(nil, errors.New(errMsg))
+ c.log.Warnf("server error: %s: %s", sendError.GetError(),
sendError.GetMessage())
default:
// By default, for transient error, let the reconnection logic
// to take place and re-establish the produce again
- c.Close()
Review comment:
Refer to the above ideas, if we need to clean the pendingRequest cache,
then we'd better close the connection here. If we only need to clean up the map
of the producer of listeners, then here we only trigger the logic of
reconnection should be enough. Because of this connection, there may be other
producers in use.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]