Skip to content
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

[fix] callback of send batch message is error when flush #303

Merged
merged 3 commits into from
Jul 24, 2023

Conversation

TakaHiR07
Copy link
Contributor

Motivation

When sendAsync batch messages and then flush() and close(), found that the callback of message is ResultAlreadyClosed but not Ok.

The root is if there is no batch messages remain in BatchMessageContainer when do flush, the flush callback directly return Ok. Instead, it should return Ok until the lastSendOpFuture complete.

Modifications

  1. fix the error code.
  2. test two cases of flush batch messages.

Verifying this change

  • Make sure that the change passes the CI checks.

Documentation

  • doc-not-needed
    (Please explain why)

@BewareMyPower BewareMyPower added the bug Something isn't working label Jul 21, 2023
Copy link
Contributor

@BewareMyPower BewareMyPower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the code format

tests/ProducerTest.cc Show resolved Hide resolved
tests/ProducerTest.cc Outdated Show resolved Hide resolved
@BewareMyPower BewareMyPower merged commit ffee4a0 into apache:main Jul 24, 2023
@BewareMyPower BewareMyPower added this to the 3.3.0 milestone Aug 7, 2023
BewareMyPower added a commit to BewareMyPower/pulsar-client-cpp that referenced this pull request Nov 20, 2023
Fixes apache#352

### Motivation

apache#303 adds the flush
callback to the last `OpSendMsg` instead of adding to the batch message
container. However, `batchMessageAndSend` will create an `OpSendMsg` and
add it to the `pendingMessagesQueue_`.

https://github.com/apache/pulsar-client-cpp/blob/7bb94f45b917ed30b5302ac93ffa1f1942fc6313/lib/ProducerImpl.cc#L384-L389

In the code above, `pendingMessagesQueue_` could never be empty and the
callback will be added again by `opSendMsg->addTrackerCallback`. The 1st
time it's added in `createOpSendMsg` or `createOpSendMsgs` called by
`batchMessageAndSend`.

### Motivation

Add the callback to the last `OpSendMsg only when the batch message
container is empty.

In `testFlushBatch`, replace the `flush` call with the `flushAsync` call
and verify the callback is only called once after it's completed.
BewareMyPower added a commit that referenced this pull request Nov 21, 2023
Fixes #352

### Motivation

#303 adds the flush
callback to the last `OpSendMsg` instead of adding to the batch message
container. However, `batchMessageAndSend` will create an `OpSendMsg` and
add it to the `pendingMessagesQueue_`.

https://github.com/apache/pulsar-client-cpp/blob/7bb94f45b917ed30b5302ac93ffa1f1942fc6313/lib/ProducerImpl.cc#L384-L389

In the code above, `pendingMessagesQueue_` could never be empty and the
callback will be added again by `opSendMsg->addTrackerCallback`. The 1st
time it's added in `createOpSendMsg` or `createOpSendMsgs` called by
`batchMessageAndSend`.

### Motivation

Add the callback to the last `OpSendMsg only when the batch message
container is empty.

In `testFlushBatch`, replace the `flush` call with the `flushAsync` call
and verify the callback is only called once after it's completed.
BewareMyPower added a commit that referenced this pull request Nov 21, 2023
Fixes #352

### Motivation

#303 adds the flush
callback to the last `OpSendMsg` instead of adding to the batch message
container. However, `batchMessageAndSend` will create an `OpSendMsg` and
add it to the `pendingMessagesQueue_`.

https://github.com/apache/pulsar-client-cpp/blob/7bb94f45b917ed30b5302ac93ffa1f1942fc6313/lib/ProducerImpl.cc#L384-L389

In the code above, `pendingMessagesQueue_` could never be empty and the
callback will be added again by `opSendMsg->addTrackerCallback`. The 1st
time it's added in `createOpSendMsg` or `createOpSendMsgs` called by
`batchMessageAndSend`.

### Motivation

Add the callback to the last `OpSendMsg only when the batch message
container is empty.

In `testFlushBatch`, replace the `flush` call with the `flushAsync` call
and verify the callback is only called once after it's completed.

(cherry picked from commit 37ea769)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants