Termination of a deleted pending message acks all messages below it under AckPolicy All
Observed behavior
Setup:
- stream N (subjects
n.>, file storage, no limits) - durable pull consumer C (AckPolicy All, FilterSubject
n.>, MaxAckPending 4, AckWait 5m)
- Publish one message to the stream, read it and accept it to move ack_floor >0 (otherwise when ack_floor is 0: consumer.purge() cleans pendings by itself)
- Publish 4 messages to the stream: 2 3 4 5. messages 2 and 3 should have one distinct subject
- Fetch the messages but do not ack. Received messages: 2 3 4 5
- Purge messages 3 and 4 (by their common subject)
- NAK whole batch
- Fetch the messages again. Received: 2 5. And two advisories appeared
$JS.EVENT.ADVISORY.CONSUMER.MSG_TERMINATED.MSG_TERMINATED.<stream>.<consumer>for messages 3 and 4, reason "Unacknowledged message was deleted" appeared. ack_floor.stream_seq moved from 1 to 4 - NAK whole batch again Problem --> 8. Fetch the messages again. Received messages: 5
The message 2 was never acked before and is lost. If any error or NAK happens on step 6-7 client loses the message.
Expected behavior
The same flow as in Observed behavior, but: 7. NAK whole batch again 8. Fetch the messages again. Received messages: 1 4
The termination of a deleted message must not affect other unacknowledged messages when the consumer's AckPolicy is All.
Server and client version
Server: nats-server v2.12.8 and v2.15.0 (latest release, checked today), standalone, default JetStream settings, file storage
Client: NATS.Net 2.6.7 (.NET 10)
Host environment
Windows 11 x64, single server process
Steps to reproduce
Attached a single-file .NET program with all steps. Requires .NET 10 SDK: dotnet run AckAllFloorJump.cs [nats://host:4222]. The program prints REPRODUCED or NOT REPRODUCED at the end.
sample-output-2.12.8.txt sample-output-2.15.0.txt AckAllFloorJump.cs
Submission acknowledgment
- I am a human being writing in my own words and not an AI agent. I will not use an AI agent to communicate on my behalf in this issue, either directly or via copy-paste.
Source: nats-io/nats-server