Do not ack to AckNxt

This causes nil messages mid content stream and is confusing,
the test for this is amended to test the content received for
validity - where previously the test assumed any content is
good content but in fact it only received half the content.

Removing this behaviour until we can design this properly

Signed-off-by: R.I.Pienaar <rip@devco.net>
This commit is contained in:
R.I.Pienaar
2020-09-21 17:28:44 +02:00
parent f76d6e38bd
commit cd376aa753
2 changed files with 10 additions and 1 deletions

View File

@@ -698,12 +698,15 @@ func (o *Consumer) sendAckReply(subj string) {
func (o *Consumer) processAck(_ *subscription, _ *client, subject, reply string, msg []byte) {
sseq, dseq, dcount, _ := o.ReplyInfo(subject)
var skipAckReply bool
switch {
case len(msg) == 0, bytes.Equal(msg, AckAck), bytes.Equal(msg, AckOK):
o.ackMsg(sseq, dseq, dcount)
case bytes.Equal(msg, AckNext):
o.ackMsg(sseq, dseq, dcount)
o.processNextMsgReq(nil, nil, subject, reply, nil)
skipAckReply = true
case bytes.Equal(msg, AckNak):
o.processNak(sseq, dseq)
case bytes.Equal(msg, AckProgress):
@@ -713,7 +716,7 @@ func (o *Consumer) processAck(_ *subscription, _ *client, subject, reply string,
}
// Ack the ack if requested.
if len(reply) > 0 {
if len(reply) > 0 && !skipAckReply {
o.sendAckReply(reply)
}
}
@@ -956,6 +959,7 @@ func (o *Consumer) ackMsg(sseq, dseq, dcount uint64) {
func (o *Consumer) processAckMsg(sseq, dseq, dcount uint64, doSample bool) {
var sagap uint64
o.mu.Lock()
switch o.config.AckPolicy {
case AckExplicit:

View File

@@ -1665,6 +1665,11 @@ func TestJetStreamWorkQueueAckAndNext(t *testing.T) {
if err != nil {
t.Fatalf("Unexpected error waiting for messages: %v", err)
}
if !bytes.Equal(m.Data, []byte("Hello World!")) {
t.Fatalf("Got an invalid message from the stream: %q", m.Data)
}
nc.PublishRequest(m.Reply, sub.Subject, server.AckNext)
}
})