Skip to content

ADR-60: JetStream reliable stream sourcing/mirroring on WQ/Interest streams#389

Open
MauriceVanVeen wants to merge 1 commit intomainfrom
maurice/durable-sourcing
Open

ADR-60: JetStream reliable stream sourcing/mirroring on WQ/Interest streams#389
MauriceVanVeen wants to merge 1 commit intomainfrom
maurice/durable-sourcing

Conversation

@MauriceVanVeen
Copy link
Member

@MauriceVanVeen MauriceVanVeen commented Nov 6, 2025

Stream sourcing/mirroring on WorkQueue or Interest streams is not reliable due to the use of an ephemeral AckNone consumer. This ADR proposes a design for durable stream sourcing/mirroring that works reliably on all stream retention types.

Signed-off-by: Maurice van Veen github@mauricevanveen.com

@roeschter

This comment was marked as outdated.

@roeschter

This comment was marked as outdated.

@neilalexander
Copy link
Member

@roeschter Please add comments inline using the review function, otherwise it's extremely difficult to thread and track replies to individual comments.

Copy link
Contributor

@roeschter roeschter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing specifications?
-Will the sourcing side verify that the consumer has the right AckPolicy of AckFlowControl?
-What will happen to sourcing from a workqueue is NOT consumer is set? WE shouldn't fail (compatibility), but should we at least print a warning

@jnmoyne
Copy link
Contributor

jnmoyne commented Dec 1, 2025

LGTM

@MauriceVanVeen
Copy link
Member Author

Opened a draft PR on the server with a working version for this. I'll update this ADR with some refinements soon.

@MauriceVanVeen
Copy link
Member Author

This ADR is now also updated to reflect the initial implemention. Requiring to specify MaxAckPending as upper bound for pending messages, unset AckWait/BackOff, and infinite MaxDeliver.

@MauriceVanVeen MauriceVanVeen force-pushed the maurice/durable-sourcing branch from f741e0a to ed4847e Compare December 5, 2025 09:05
Copy link
Collaborator

@ripienaar ripienaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, feels like we need a proper ok from @derekcollison also maybe?

@MauriceVanVeen MauriceVanVeen force-pushed the maurice/durable-sourcing branch from 06e8ab3 to 00aef99 Compare January 6, 2026 15:26
@MauriceVanVeen MauriceVanVeen changed the title ADR-57: JetStream durable stream sourcing/mirroring ADR-58: JetStream durable stream sourcing/mirroring Jan 6, 2026
@MauriceVanVeen MauriceVanVeen force-pushed the maurice/durable-sourcing branch from 00aef99 to e7c3980 Compare January 6, 2026 15:40
adr/ADR-58.md Outdated
and delivery sequence (`Nats-Last-Consumer`) as headers to signal which messages have been successfully stored.
- The server receiving the flow control response will ack messages based on these stream/delivery sequences. For
WorkQueue and Interest streams this may result in messages deletion.
- Acknowledgements happen based on flow control limits, usually a data window size. But if the stream is idle the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vaguely remember there is a reasons for moving the ack floor. In the next section we talk about flow control ack being done according to window size. So this one is for very slow moevign streams?

But if the source/mirror is idle (low message rate) the Heartbeat will also trigger a flow control message to move the acknowledgement floor up even if the window size has not been reached.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, if a stream receives small messages very slowly, it will not trigger the flow control messages often. So, if the stream hasn't received messages for Heartbeat amount of time, then a flow control message will also be sent. This ensures that a WorkQueue/Interest stream can remove messages after ack in such a slow/idle stream case.

@MauriceVanVeen
Copy link
Member Author

Updated the ADR to include a "hybrid option" between ephemeral consumer and a pre-created durable consumer that needs to be fully managed by the user. This hybrid is a "server-managed" durable consumer. The server creates a durable instead of ephemeral consumer, but otherwise functions in exactly the same way. Importantly, it allows for easy migration from ephemeral to durable sourcing, as well as not requiring too much additional work from the user when not necessary.

…treams

Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
@MauriceVanVeen MauriceVanVeen force-pushed the maurice/durable-sourcing branch from 8a72c01 to b12edc3 Compare March 11, 2026 15:09
@MauriceVanVeen MauriceVanVeen changed the title ADR-58: JetStream durable stream sourcing/mirroring ADR-60: JetStream reliable stream sourcing/mirroring on WQ/Interest streams Mar 11, 2026
@MauriceVanVeen
Copy link
Member Author

Updated the ADR and server PR to automatically "upgrade" the ephemeral sourcing consumer to be durable if sourcing from a WQ/Interest stream. This ensures this type of sourcing will work reliably after performing the server upgrade. The "bring your own consumer" approach is also kept, but is an opt-in still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants