[fix] Fix PartitionedProducerImpl::closeAsync to close sub-producers properly#125
[fix] Fix PartitionedProducerImpl::closeAsync to close sub-producers properly#125RobertIndie merged 10 commits intoapache:mainfrom
Conversation
|
@erobot Hi, Can you add unit test based on the steps |
BewareMyPower
left a comment
There was a problem hiding this comment.
Could you also add the unit test to avoid the regression?
|
ok, I will fix the code style and add a unit test latter. |
The difference is not clear from the output. Maybe a unit test would be better to tell the difference. |
|
Just digged deeper into this issue. I think there is no problem with the current master. If one internal producer failed to create, the partitioned producer would not be added into the Then the
|
|
@BewareMyPower add a test to reproduce the problem |
|
I got it. It's caused when some sub-producers can be created successfully while other could fail. |
279d6cb to
2e4fb57
Compare
Co-authored-by: Yunze Xu <xyzinfernity@163.com>
Co-authored-by: Yunze Xu <xyzinfernity@163.com>
…properly (apache#125) ### Motivation PartitionedProducerImpl do not close sub-producers properly when any sub-producer creation fails. Continuing to retry creating producer will eventually reach the maximum producer limit. It seems a regression caused by apache#54. When sub-producer creation fails, state_ is set to Failed. PartitionedProducerImpl::closeAsync only do cleanup when state_==Ready and sub-producers do not close when state_==Failed. https://github.com/apache/pulsar-client-cpp/blob/f0268ecd29a6d0030b7d07379ec609884b4c14ff/lib/PartitionedProducerImpl.cc#L273-L276 ### Modifications Close sub-producers when state != Closed.
Motivation
PartitionedProducerImpl do not close sub-producers properly when any sub-producer creation fails. Continuing to retry creating producer will eventually reach the maximum producer limit. It seems a regression caused by #54.
When sub-producer creation fails, state_ is set to Failed. PartitionedProducerImpl::closeAsync only do cleanup when state_==Ready and sub-producers do not close when state_==Failed.
pulsar-client-cpp/lib/PartitionedProducerImpl.cc
Lines 273 to 276 in f0268ec
Modifications
Close sub-producers when state != Closed.
Verifying this change
test code:
test cmd:
test procedure:
Documentation
doc-required(Your PR needs to update docs and you will update later)
doc-not-neededbug-fix only
doc(Your PR contains doc changes)
doc-complete(Docs have been already added)