Skip to content

[C++] Release the unused spots of pending message queue#6926

Merged
codelipenghui merged 6 commits intoapache:masterfrom
BewareMyPower:reserve-unused-spot-dev
May 19, 2020
Merged

[C++] Release the unused spots of pending message queue#6926
codelipenghui merged 6 commits intoapache:masterfrom
BewareMyPower:reserve-unused-spot-dev

Conversation

@BewareMyPower
Copy link
Contributor

@BewareMyPower BewareMyPower commented May 9, 2020

Motivation

If messages were sent in batch, every single message would reserve one spot of producer's pending message queue, but only one batched message would be pushed to the queue. Therefore there may exist many unused spots when ProducerQueueIsFull happened.

Besides, if a message was too big or failed to be encrypted, sendAsync failed immediately but the reserved spot won't be released.

Modifications

  • Add a bool return value to BatchMessageContainer::sendMessages to indicate whether the batched message was pushed to producer's queue.
  • Add a bool return value to BatchMessageContainer::add to indicate whether the reserved spot should be released. The spot would be retained only if the first message was batched and not sent immediately. The spot would be released when the batched message was pushed to the queue.
  • Test sending a batch with a 2-spots pending message queue, one spot for storing the batched message, another spot for preventing ProducerQueueIsFull error.
  • Test after all batched messages being sent, whether the reserved spots of producer's queue were 0.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as BatchMessageTest.testSendCallback, BatchMessageTest.testPartitionedTopics and BasicEndToEndTest.testMessageTooBig.

@BewareMyPower BewareMyPower force-pushed the reserve-unused-spot-dev branch from 2e891f8 to d9403ae Compare May 10, 2020 10:37
@BewareMyPower
Copy link
Contributor Author

/pulsarbot run-failure-checks

@sijie sijie added component/c++ area/client type/bug The PR fixed a bug or issue reported a bug labels May 18, 2020
@sijie sijie added this to the 2.6.0 milestone May 18, 2020
@codelipenghui codelipenghui merged commit 5bb8809 into apache:master May 19, 2020
nicolo-paganin pushed a commit to oncodeit/pulsar that referenced this pull request May 22, 2020
### Motivation

If messages were sent in batch, every single message would reserve one spot of producer's pending message queue, but only one batched message would be pushed to the queue. Therefore there may exist many unused spots when `ProducerQueueIsFull` happened.

Besides, if a message was too big or failed to be encrypted, `sendAsync` failed immediately but the reserved spot won't be released.

### Modifications

- Add a `bool` return value to `BatchMessageContainer::sendMessages` to indicate whether the batched message was pushed to producer's queue.
- Add a `bool` return value to `BatchMessageContainer::add` to indicate whether the reserved spot should be released. The spot would be retained only if the first message was batched and not sent immediately. The spot would be released when the batched message was pushed to the queue.
- Test sending a batch with a 2-spots pending message queue, one spot for storing the batched message, another spot for preventing `ProducerQueueIsFull` error.
- Test after all batched messages being sent, whether the reserved spots of producer's queue were  0.

### Verifying this change

- [ ] Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as `BatchMessageTest.testSendCallback`, `BatchMessageTest.testPartitionedTopics` and `BasicEndToEndTest.testMessageTooBig`.
nicolo-paganin pushed a commit to oncodeit/pulsar that referenced this pull request May 22, 2020
### Motivation

If messages were sent in batch, every single message would reserve one spot of producer's pending message queue, but only one batched message would be pushed to the queue. Therefore there may exist many unused spots when `ProducerQueueIsFull` happened.

Besides, if a message was too big or failed to be encrypted, `sendAsync` failed immediately but the reserved spot won't be released.

### Modifications

- Add a `bool` return value to `BatchMessageContainer::sendMessages` to indicate whether the batched message was pushed to producer's queue.
- Add a `bool` return value to `BatchMessageContainer::add` to indicate whether the reserved spot should be released. The spot would be retained only if the first message was batched and not sent immediately. The spot would be released when the batched message was pushed to the queue.
- Test sending a batch with a 2-spots pending message queue, one spot for storing the batched message, another spot for preventing `ProducerQueueIsFull` error.
- Test after all batched messages being sent, whether the reserved spots of producer's queue were  0.

### Verifying this change

- [ ] Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as `BatchMessageTest.testSendCallback`, `BatchMessageTest.testPartitionedTopics` and `BasicEndToEndTest.testMessageTooBig`.
Huanli-Meng pushed a commit to Huanli-Meng/pulsar that referenced this pull request May 27, 2020
### Motivation

If messages were sent in batch, every single message would reserve one spot of producer's pending message queue, but only one batched message would be pushed to the queue. Therefore there may exist many unused spots when `ProducerQueueIsFull` happened.

Besides, if a message was too big or failed to be encrypted, `sendAsync` failed immediately but the reserved spot won't be released.

### Modifications

- Add a `bool` return value to `BatchMessageContainer::sendMessages` to indicate whether the batched message was pushed to producer's queue.
- Add a `bool` return value to `BatchMessageContainer::add` to indicate whether the reserved spot should be released. The spot would be retained only if the first message was batched and not sent immediately. The spot would be released when the batched message was pushed to the queue.
- Test sending a batch with a 2-spots pending message queue, one spot for storing the batched message, another spot for preventing `ProducerQueueIsFull` error.
- Test after all batched messages being sent, whether the reserved spots of producer's queue were  0.

### Verifying this change

- [ ] Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as `BatchMessageTest.testSendCallback`, `BatchMessageTest.testPartitionedTopics` and `BasicEndToEndTest.testMessageTooBig`.
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
### Motivation

If messages were sent in batch, every single message would reserve one spot of producer's pending message queue, but only one batched message would be pushed to the queue. Therefore there may exist many unused spots when `ProducerQueueIsFull` happened.

Besides, if a message was too big or failed to be encrypted, `sendAsync` failed immediately but the reserved spot won't be released.

### Modifications

- Add a `bool` return value to `BatchMessageContainer::sendMessages` to indicate whether the batched message was pushed to producer's queue.
- Add a `bool` return value to `BatchMessageContainer::add` to indicate whether the reserved spot should be released. The spot would be retained only if the first message was batched and not sent immediately. The spot would be released when the batched message was pushed to the queue.
- Test sending a batch with a 2-spots pending message queue, one spot for storing the batched message, another spot for preventing `ProducerQueueIsFull` error.
- Test after all batched messages being sent, whether the reserved spots of producer's queue were  0.

### Verifying this change

- [ ] Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as `BatchMessageTest.testSendCallback`, `BatchMessageTest.testPartitionedTopics` and `BasicEndToEndTest.testMessageTooBig`.
@BewareMyPower BewareMyPower deleted the reserve-unused-spot-dev branch September 16, 2022 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/client type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants