Skip to content

Allow per-message Nats-TTL to be bigger than JetStream Stream's MaxAge property #7371

@nikopavlica

Description

@nikopavlica

Proposed change

Either of
A) By allowing Nats-TTL to be bigger than stream's MaxAge.

or
B) Adding a new config to the stream DefaultTTL
This could be used as a default TTL for all new messages that don't have the TTL set - in case existing MaxAge is used as a hard limit on maximum message age.

Use case

When publishing a message for storage into jetstream, we can now either:

  • set a Nats-TTL: <duration>, where <duration> that is shorter than stream's configured MaxAge
  • set a Nats-TTL: never, to have this message never expire at all, but then handle purging of such message on our own. Which is the exact thing that TTL tries to solve.

It would be useful to have some messages with longer TTL, just as it is useful to have some with Nats-TTL: never.

Main benefit, that I see, are:

  • instead of always sending Nats-TTL: <default-shorter-duration> on every message we don't need such long TTL, we could leave the defaults up to stream configuration, and only set on exceptional messages. This is especially helpful in existing streams with active publishers. If we'd like to have some messages with bigger TTL, we'd now first need to update all publishers to send shorter TTL, before updating the stream's config to allow for bigger TTL.
  • Reducing confusion around Nats-TTL; ADR-43 doesn't mention anything about limiting the TTL to the stream's max age. And given that it can be set to never, it is really non-intuitive that it can't be longer than MaxAge.

Contribution

I'd be interested to contribute - if time permits :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalEnhancement idea or proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions