-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Neil Twigg <[email protected]>
… that when checking for next expiry Signed-off-by: Neil Twigg <[email protected]>
…mirroring Signed-off-by: Neil Twigg <[email protected]>
@@ -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 { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
4d4187b
to
6ea9fe0
Compare
Now that sourcing/mirroring strips the TTL header, it is safe to reject messages with the
Nats-TTL
header ifAllowMsgTTL
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]