RobertIndie opened a new pull request, #1252:
URL: https://github.com/apache/pulsar-client-go/pull/1252
<!--
### Contribution Checklist
- Name the pull request in the form "[Issue XYZ][component] Title of the
pull request", where *XYZ* should be replaced by the actual issue number.
Skip *Issue XYZ* if there is no associated github issue for this pull
request.
Skip *component* if you are unsure about which is the best component.
E.g. `[docs] Fix typo in produce method`.
- Fill out the template below to describe the changes contributed by the
pull request. That will give reviewers the context they need to do the review.
- Each pull request should address only one issue, not mix up code from
multiple issues.
- Each commit in the pull request has a meaningful commit message
- Once all items of the checklist are addressed, remove the above text and
this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
### Motivation
When using key-based production, the key-based batcher cannot ensure the
sequence ID order when flushing messages. This leads to frequent disconnections
between the client and the broker, resulting in poor performance.
Here is the related log:
```
time="2024-07-19T03:38:07Z" level=warning msg="Received send error from
server: [PersistenceError] : [Cannot determine whether the message is a
duplicate at this time]"
time="2024-07-19T03:38:07Z" level=warning msg="Connection was closed"
cnx="xxx" producerID=1 producer_name=xxx topic="xxx"
time="2024-07-19T03:38:07Z" level=warning msg="Failed to write on
connection" error="use of closed network connection" local_addr="xxx"
remote_addr="xxx"
```
The broker receives unordered messages and sends an error to the client.
This causes the client to reconnect to the broker.
### Modifications
- Refactor the BatchBuilder interface.
- Sort batches before flushing in the key-based batcher builder.
### Verifying this change
This change added tests
### Does this pull request potentially affect one of the following parts:
*If `yes` was chosen, please highlight the changes*
- Dependencies (does it add or upgrade a dependency): (yes / no)
- The public API: (yes / no)
- The schema: (yes / no / don't know)
- The default values of configurations: (yes / no)
- The wire protocol: (yes / no)
### Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / GoDocs /
not documented)
- If a feature is not applicable for documentation, explain why?
- If a feature is not documented yet in this PR, please create a followup
issue for adding the documentation
--
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]