apache / apache/pulsar

[Bug] When using a NonDurable subscription in Pulsar, subscription failure occurs in the presence of message backlog accumulation.

Open
#21,594 0 comments 0 reactions 1 assignee Claimed by @xiannvyou View on GitHub
type/bug
Dominant language
Java
Stars
15.3k
Forks
3.8k
Avg merge
1d 14h
Merged PRs (30d)
160

Description

### Search before asking

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

### Version

broker version:2.7.4
client version : github.com/apache/pulsar-client-go@v0.11.0

### Minimal reproduce step

Go code

> When the message backlog exceeds 3000 after the initial subscription, attempting to re-subscribe will result in a failure. The consumer group still retains the previous consumers.

```go
package main

import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"time"

"github.com/apache/pulsar-client-go/pulsar"
)

func main() {
client, err := pulsar.NewClient(pulsar.ClientOptions{URL: ""})
if err != nil {
panic(err)
}
subscribe, err := client.Subscribe(pulsar.ConsumerOptions{
Topic: "persistent://~/~/~",
SubscriptionName: "go-test",
Type: pulsar.Shared,
SubscriptionMode: pulsar.NonDurable,
KeySharedPolicy: nil,
})
if err != nil {
// panic: server error: PersistenceError: java.util.concurrent.CompletionException: java.lang.NullPointerException
panic(err)
}
go func() {

for {
msg, err := subscribe.Receive(context.Background())
if err != nil {
fmt.Printf("%v/n", err)
}
// simulated consumption power
time.Sleep(5 * time.Second)
_ = subscribe.Ack(msg)
}
}()
signals := make(chan os.Signal, 1)
signal.Notify(make(chan os.Signal, 1), syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
<-signals
subscribe.Close()
}
```

### What did you expect to see?

After the code execution is terminated, the subscription group should disappear. Upon re-subscription, only the new consumers will be present in the subscription group.

### What did you see instead?

The subscription group does not disappear after closing the code. Upon re-subscription, it fails to subscribe successfully. The consumer information can still be seen in the subscription group, but it is unable to consume messages and remains permanently displayed in the subscription information.
![image](https://github.com/apache/pulsar/assets/95083676/312e3514-6ae4-4dd1-8eb6-375a4a341379)
The mentioned IP addresses refer to the consumers that have already been destroyed due to code termination, but still exist in the subscription group.

### Anything else?

_No response_

### Are you willing to submit a PR?

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.