Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject TTL messages when not enabled, strip TTL header from sourcing/mirroring #6298

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

neilalexander
Copy link
Member

Now that sourcing/mirroring strips the TTL header, it is safe to reject messages with the Nats-TTL header if AllowMsgTTL is not set on the stream.

Sourcing/mirroring tests are both clustered and non-clustered as there are different codepaths for sourcing/mirroring when clustered.

Signed-off-by: Neil Twigg [email protected]

@neilalexander neilalexander marked this pull request as ready for review December 23, 2024 17:16
@neilalexander neilalexander requested a review from a team as a code owner December 23, 2024 17:16
@@ -2418,6 +2418,12 @@ func (mset *stream) processInboundMirrorMsg(m *inMsg) bool {
return false
}

// If the TTL header is set, remove it.
hdr := m.hdr
if len(hdr) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I think instead of removing we flag that the messages is sourced to this function and if so we ignore this plus a bunch of others..

@@ -3447,8 +3453,10 @@ func (mset *stream) processInboundSourceMsg(si *sourceInfo, m *inMsg) bool {
hdr, msg := m.hdr, m.msg

// If we are daisy chained here make sure to remove the original one.
// If the TTL header is set, remove it.
Copy link
Member

Choose a reason for hiding this comment

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

Let's rework this logic to not remove but ignore.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this wise? If we have to rebuild the mirroring/sourcing stream, how do we know whether or not to recover the TTLs? Do we just never recover the TTLs if there are mirrors/sources present?

@@ -4780,6 +4789,19 @@ func (mset *stream) processJetStreamMsg(subject, reply string, hdr, msg []byte,
}
}

// TTL'd messages are rejected entirely if TTLs are not enabled on the stream.
if ttl, _ := getMessageTTL(hdr); ttl != 0 && !mset.cfg.AllowMsgTTL {
mset.mu.Unlock()
Copy link
Member

Choose a reason for hiding this comment

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

We can do this before proposing to the NRG so no need to bump CLFS etc.

Copy link
Member

Choose a reason for hiding this comment

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

This was specific to the downstream stream not having per msg ttls enabled correct?

Base automatically changed from neil/ttl to main December 24, 2024 15:35
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.

2 participants