apache / apache/pulsar-client-cpp

[Bug] `std::bad_function_call` was thrown on `Reader::ReadNext` on a non-persistent topic

未關閉
#455 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
C++
星號
71
分支
90
平均合併
2 小時 33 分鐘
30 天內合併 PR
3

描述

### Search before asking

- [X] I searched in the [issues](https://github.com/apache/pulsar-client-cpp/issues) and found nothing similar.

### Version

Pulsar 3.3.2 running in docker, same issue also happen when I tried to connect to StreamNative cloud serivce. But I think this issue has notthing to do with the pulser server side. And I am using pulsar-client-cpp 3.5.1.

### Minimal reproduce step

1. Create a `Reader` on a non-persistent topic.
2. Call `ReadNext` on the Reader instance to read messages.

### What did you expect to see?

Messages are successfully read by the client.

### What did you see instead?

A portion of the exception backtrace:
```
0. std::exception::capture() @ 0x00000000245a0b24
1. std::exception::exception[abi:v15000]() @ 0x00000000245a0aec
2. std::__1::bad_function_call::bad_function_call() @ 0x00000000245a0a9c
3. std::__1::__throw_bad_function_call[abi:v15000]() @ 0x00000000245a0a50
4. ? @ 0x000000003e7c3b18
5. ./build_docker/../contrib/llvm-project/libcxx/include/__functional/function.h:848: std::__1::__function::__policy_func::operator()[abi:v15000](pulsar::Result&&) const @ 0x000000003e83edc8
6. ./build_docker/../contrib/llvm-project/libcxx/include/__functional/function.h:1187: std::__1::function::operator()(pulsar::Result) const @ 0x000000003e7db9e4
7. ./build_docker/../contrib/pulsar-cmake/pulsar-client-cpp/lib/AckGroupingTracker.h:93: pulsar::AckGroupingTracker::addAcknowledgeCumulative(pulsar::MessageId const&, std::__1::function) @ 0x000000003e95a38c
8. ./build_docker/../contrib/pulsar-cmake/pulsar-client-cpp/lib/ConsumerImpl.cc:1187: pulsar::ConsumerImpl::acknowledgeCumulativeAsync(pulsar::MessageId const&, std::__1::function) @ 0x000000003e93ce34
9. ./build_docker/../contrib/pulsar-cmake/pulsar-client-cpp/lib/ReaderImpl.cc:155: pulsar::ReaderImpl::acknowledgeIfNecessary(pulsar::Result, pulsar::Message const&) @ 0x000000003ea6a8b0
10. ./build_docker/../contrib/pulsar-cmake/pulsar-client-cpp/lib/ReaderImpl.cc:130: pulsar::ReaderImpl::readNext(pulsar::Message&, int) @ 0x000000003ea6a954
11. ./build_docker/../contrib/pulsar-cmake/pulsar-client-cpp/lib/Reader.cc:49: pulsar::Reader::readNext(pulsar::Message&, int) @ 0x000000003ea66ccc
```

### Anything else?

I think the issue is that, `AckGroupingTracker::addAcknowledgeList` does check `callback` before calling it: https://github.com/apache/pulsar-client-cpp/blob/main/lib/AckGroupingTracker.h#L81-L83. And in `ReaderImpl::acknowledgeIfNecessary` it passes the `emptyCallback` caused the issue: https://github.com/apache/pulsar-client-cpp/blob/main/lib/ReaderImpl.cc#L155

### Are you willing to submit a PR?

- [X] I'm willing to submit a PR!

貢獻指南

開啟貢獻指南

研究方向

先閱讀 lib/ReaderImpl.cc 中的 acknowledgeIfNecessary 和 lib/AckGroupingTracker.h 中的 addAcknowledgeList,然後在非持久化 topic 上重現一個 Reader 並呼叫 ReadNext。完成的標準是用戶端不再拋出 std::bad_function_call,且訊息能夠成功讀取。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
cpp
領域
distributed-systems
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。