apache / apache/pulsar-client-cpp

[Bug] Acknowledge might fail with ResultAlreadyClosed during unload

Open
#407 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
71
Forks
90
Avg merge
2h 33m
Merged PRs (30d)
3

Description

### Search before asking

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

### Version

main

### Minimal reproduce step

Enable `ackReceipt` for https://github.com/apache/pulsar-client-cpp/blob/main/tests/extensibleLM/ExtensibleLoadManagerTest.cc

```c++
ConsumerConfiguration consumerConf;
consumerConf.setAckReceiptEnabled(true);
Consumer consumer;
Result consumerResult = client.subscribe(topicName, "sub", consumerConf, consumer);
```

### What did you expect to see?

The test passed

### What did you see instead?

```
2024-02-27 21:51:30.938 WARN [0x16b36b000] AckGroupingTracker:93 | Connection is not ready, ACK failed for [(14,0,-1,-1)]
2024-02-27 21:51:30.938 INFO [0x16b96f000] ExtensibleLoadManagerTest:145 | acked i: 0 81 ms
/Users/xuyunze/github.com/bewaremypower/pulsar-client-cpp/tests/extensibleLM/ExtensibleLoadManagerTest.cc:147: Failure
Expected equality of these values:
ackResult
Which is: AlreadyClosed
ResultOk
Which is: Ok
```

Note: I changed the log level of `AckGroupingTracker:93` to warn locally.

### Anything else?

When `HandlerBase::getCnx()` returns a null `weak_ptr`, it's retryable if the state is not `Closing` or `Closed`. We should schedule the flush again.

### Are you willing to submit a PR?

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

Contributor guide

Open the contributing guide

Research direction

Start with tests/extensibleLM/ExtensibleLoadManagerTest.cc, especially the ackReceipt setup and the failing assertion around line 147. Trace AckGroupingTracker and HandlerBase::getCnx() to understand the unload path and retry condition. Done means the test passes with ackResult equal to ResultOk instead of AlreadyClosed when the client unloads.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.