Describe the bug
events/natsjs.Stream.Consume defaults to manual acknowledgement even though
events.ConsumeOptions.AutoAck documents automatic acknowledgement as the
default.
The NATS Streaming and in-memory event implementations initialize
AutoAck: true. The NATS JetStream implementation initializes only Group, so
Go's zero value selects AutoAck: false. As a result, a default durable
JetStream consumer is created with AckExplicit, and messages are redelivered
unless every caller manually acknowledges them.
This is especially damaging to downstream consumers that rely on the documented
default. Under a bulk workload, unacknowledged messages accumulate and are
redelivered, increasing load until consumers can no longer drain the stream.
Steps to reproduce
- Start a NATS server with JetStream enabled.
- Create an
events/natsjs stream.
- Call
Consume(topic, events.WithGroup(group)) without WithAutoAck.
- Inspect the durable consumer with
JetStream.ConsumerInfo(topic, group).
The consumer reports AckExplicitPolicy.
Expected behavior
The default should follow the events API contract and the other event stream
implementations by enabling automatic acknowledgement. Explicitly calling
events.WithAutoAck(false, ackWait) must continue to select manual
acknowledgement.
Actual behavior
The default selects manual acknowledgement because AutoAck is left at its
false zero value.
Downstream impact
This was observed with ownCloud Infinite Scale 8.1.0 during a bulk WebDAV import
of roughly 100,000 files. Durable consumers used AckExplicit, pending messages
were repeatedly redelivered, files remained in processing, and NATS became
overloaded. Setting the NATSJS default to AutoAck: true created AckNone
consumers and allowed the queue to drain.
Related downstream reports:
Proposed fix
Initialize events.ConsumeOptions with AutoAck: true in
v4/events/natsjs/nats.go and add an integration test that verifies:
- default consumption uses
AckNonePolicy;
WithAutoAck(false, ...) still uses AckExplicitPolicy.
Describe the bug
events/natsjs.Stream.Consumedefaults to manual acknowledgement even thoughevents.ConsumeOptions.AutoAckdocuments automatic acknowledgement as thedefault.
The NATS Streaming and in-memory event implementations initialize
AutoAck: true. The NATS JetStream implementation initializes onlyGroup, soGo's zero value selects
AutoAck: false. As a result, a default durableJetStream consumer is created with
AckExplicit, and messages are redeliveredunless every caller manually acknowledges them.
This is especially damaging to downstream consumers that rely on the documented
default. Under a bulk workload, unacknowledged messages accumulate and are
redelivered, increasing load until consumers can no longer drain the stream.
Steps to reproduce
events/natsjsstream.Consume(topic, events.WithGroup(group))withoutWithAutoAck.JetStream.ConsumerInfo(topic, group).The consumer reports
AckExplicitPolicy.Expected behavior
The default should follow the
eventsAPI contract and the other event streamimplementations by enabling automatic acknowledgement. Explicitly calling
events.WithAutoAck(false, ackWait)must continue to select manualacknowledgement.
Actual behavior
The default selects manual acknowledgement because
AutoAckis left at itsfalse zero value.
Downstream impact
This was observed with ownCloud Infinite Scale 8.1.0 during a bulk WebDAV import
of roughly 100,000 files. Durable consumers used
AckExplicit, pending messageswere repeatedly redelivered, files remained in processing, and NATS became
overloaded. Setting the NATSJS default to
AutoAck: truecreatedAckNoneconsumers and allowed the queue to drain.
Related downstream reports:
Proposed fix
Initialize
events.ConsumeOptionswithAutoAck: trueinv4/events/natsjs/nats.goand add an integration test that verifies:AckNonePolicy;WithAutoAck(false, ...)still usesAckExplicitPolicy.