Description
Observed behavior
Observed behavior
I'm sorry if this is not a bug, but I cannot find any documentation to why this should be the behavior.
TLDR
JetStream with multiple messages per subject and a consumer with Explicit ACK that only cares about last message per subject. Some ACKs are not registered causing the message to being redelivered.
Setup
I have the following JetStream:
Information for Stream CONTRACTS created 2024-12-05 09:38:36
Subjects: contracts.>
Replicas: 1
Storage: File
Options:
Retention: Limits
Acknowledgments: true
Discard Policy: Old
Duplicate Window: 2m0s
Allows Msg Delete: true
Allows Purge: true
Allows Rollups: false
Limits:
Maximum Messages: unlimited
Maximum Per Subject: 5 # This seems to be the cause of the issue
Maximum Bytes: unlimited
Maximum Age: 2d0h0m0s
Maximum Message Size: unlimited
Maximum Consumers: unlimited
...
And I subscribe using:
...
AckPolicy = ConsumerConfigAckPolicy.Explicit,
DeliverPolicy = ConsumerConfigDeliverPolicy.LastPerSubject,
...
After a few successfully ACKed messages the producer stalls as it no longer receives the ACK. After the wait time the messages are being redelivered, but ACK are still not registered. This is visible by the Acknowledgment Floor
not changing its sequence number and that Unprocessed messages
remain the same.
The Outstanding ACKs would be "1000 out of maximum 1000". I also tried with higher and lower values.
Changing WaitTime
to 30 seconds (default is 2) also did not resolve anything.
Work-around
Changing the AckPolicy to None or the DeliverPolicy to All resolves the issue
Expected behavior
With a stream with subjects/messages like:
foo.bar/1, foo.more/2, foo.bar/3, .., foo.more/89
And a consumer that must ACK explicit and only cares about the last message on each subject.
I would expect:
- the consumer to receive foo.bar/3 and foo.more/89 (and whatever else is available inbetween)
- That no messages are being redelivered
- Unprocessed messages goes gradually down to 0
Server and client version
2.11.1-binary
0.1.6
Host environment
No response
Steps to reproduce
Setting the Max ACK Pending
to 1 and a high Wait Time
ensures that the program pauses exactly when the issue arises.