apache / apache/pulsar-client-cpp

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

Offen
#455 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
71
Forks
90
Ø Merge
2 Std. 33 Min.
Gemergte PRs (30 T.)
3

Beschreibung

### 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!

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by reading lib/ReaderImpl.cc at acknowledgeIfNecessary and lib/AckGroupingTracker.h at addAcknowledgeList, then reproduce a Reader on a non-persistent topic and call ReadNext. Done means the client no longer throws std::bad_function_call and messages are read successfully.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
distributed-systems
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.