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

Allow switching from limits-based to interest-based retention in stream update #4361

Merged
merged 1 commit into from Aug 9, 2023

Conversation

neilalexander
Copy link
Member

This should make it possible to switch from limits-based retention to interest-based retention on an existing stream.

Signed-off-by: Neil Twigg neil@nats.io

server/stream.go Outdated Show resolved Hide resolved
// retention then we will need to check the ack floor of all consumers.
if ocfg.Retention != cfg.Retention && cfg.Retention == InterestPolicy {
toUpdate := make([]*consumer, 0, len(mset.consumers))
for _, c := range mset.consumers {
Copy link
Member

Choose a reason for hiding this comment

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

One important piece, if the consumer is retention interest, then its replication factor must be same as stream, so need to adjust that here and add in an R1 consumer to the test above etc.

c.retention = cfg.Retention
c.mu.Unlock()
if c.retention == InterestPolicy {
c.checkStateForInterestStream()
Copy link
Member

Choose a reason for hiding this comment

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

Nice! I saw this and was confused for a second then realized what you did here..

server/stream.go Outdated Show resolved Hide resolved
t.Helper()
if bytes.Equal(a[:], b[:]) {
t.Fatalf("require not equal, but got: %v != %v", a, b)
if a == b {
Copy link
Member

Choose a reason for hiding this comment

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

Will this do the right thing for 2 different byte slices that have same contents?

Copy link
Member Author

Choose a reason for hiding this comment

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

The function was previously taking a, b [32]byte and fixed-size arrays can be compared using ==, so it will continue to work for what it was being used for.

Trying to pass in slices instead of fixed-size arrays will result in a compile-time error as they are not comparable.

@neilalexander neilalexander force-pushed the neil/switchtointerest branch 2 times, most recently from fc4ea1c to 8168aa2 Compare August 7, 2023 13:51
@neilalexander neilalexander marked this pull request as ready for review August 7, 2023 14:30
@neilalexander neilalexander requested a review from a team as a code owner August 7, 2023 14:30
server/stream.go Outdated Show resolved Hide resolved
@neilalexander neilalexander force-pushed the neil/switchtointerest branch 2 times, most recently from 62537ec to d752c76 Compare August 8, 2023 09:41
Copy link
Member

@wallyqs wallyqs left a comment

Choose a reason for hiding this comment

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

LGTM

…am update

Signed-off-by: Neil Twigg <neil@nats.io>
@neilalexander neilalexander merged commit 5145889 into dev Aug 9, 2023
2 checks passed
@neilalexander neilalexander deleted the neil/switchtointerest branch August 9, 2023 11:42
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.

None yet

3 participants