wolfstudy opened a new pull request, #775:
URL: https://github.com/apache/pulsar-client-go/pull/775
### Motivation
There are mainly two problems fixed in this pr.
1. The first one is to return some error information when the Go SDK handles
Ack by itself to the user. Note: This is not the error information returned by
the Broker side, but some errors that may occur in the Go SDK itself when
processing the Ack command link. If we ignore these possible Errors here, then
when the user calls Ack, because there is no return value, the user will think
that the current Ack request has been successful, but in fact the Ack command
may have failed when the Go SDK requested, resulting in this The Ack status of
a message is lost and it becomes a hollow message. This will cause the backlog
size on the broker side to continuously increase until the threshold of the
backlog is triggered and the message sending fails.
For example a place where an error might occur:
```
func (pc *partitionConsumer) internalAck(req *ackRequest) {
.....
err := pc.client.rpcClient.RequestOnCnxNoWait(pc._getConn(),
pb.BaseCommand_ACK, cmdAck)
if err != nil {
pc.log.Error("Connection was closed when request ack cmd")
req.err = err
}
}
```
In this case, the ack fails because the current connection is closed, but
the user cannot capture this error message and think that the ack has
succeeded, so an ack hole will occur.
2. The second change is the introduction of the `reconnectFlag` field to
indicate that the current connection state has gone wrong and a new connection
needs to be created for reconnection. Use `reconnectFlag` instead of
`changeState(state connectionState)` to prevent the currently used connection
from being prematurely judged to be closed, causing command processing such as
ack to fail.
### Modifications
- Add error response for Ack func.
- When the current connection is in a **closed** state, use the logic of
reconnection instead of throwing `errConnectionClosed` directly.
--
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]