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

Add first_seq to StreamConfig #4322

Merged
merged 3 commits into from Jul 26, 2023
Merged

Add first_seq to StreamConfig #4322

merged 3 commits into from Jul 26, 2023

Conversation

neilalexander
Copy link
Member

@neilalexander neilalexander commented Jul 19, 2023

This allows specifying first_seq in the stream config when creating a stream.

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

@neilalexander neilalexander changed the title Add first_seq to StreamConfig for file store Add first_seq to StreamConfig Jul 20, 2023
@neilalexander neilalexander marked this pull request as ready for review July 21, 2023 09:04
@neilalexander neilalexander requested a review from a team as a code owner July 21, 2023 09:04
server/filestore.go Outdated Show resolved Hide resolved
ms.mu.Lock()
purged := uint64(len(ms.msgs))
cb := ms.scb
bytes := int64(ms.state.Bytes)
ms.state.FirstSeq = ms.state.LastSeq + 1
ms.state.FirstSeq = fseq
Copy link
Member

Choose a reason for hiding this comment

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

You need to formalize this in case first is not > last.

So stream of 1-100, purge to 50..

Copy link
Member

Choose a reason for hiding this comment

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

And in that case you can't just wipe the ms.msgs. Or you could error in memory store for partial purge.

Copy link
Member Author

Choose a reason for hiding this comment

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

For now I'll go with erroring on partial purge, as I think the only alternative is to iterate through the entire ms.msgs map and check for lower sequences.

Signed-off-by: Neil Twigg <neil@nats.io>
Signed-off-by: Neil Twigg <neil@nats.io>
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Neil Twigg <neil@nats.io>
@neilalexander neilalexander merged commit 2cb1512 into dev Jul 26, 2023
2 checks passed
@neilalexander neilalexander deleted the neil/initialseq branch July 26, 2023 10:32
@ripienaar
Copy link
Contributor

Is this something we want user facing or keep for development?

ie. Should I add it to the CLI?

@derekcollison
Copy link
Member

Customer requested, so probably yes to add in CLI.

@ripienaar
Copy link
Contributor

I think we should prevent mirrors being added with custom first sequences as if you make it bigger than the seq of the source stream it will not work - I guess till the source stream reaches that seq?

wdyt?

@ripienaar
Copy link
Contributor

We should also fail if someone tries to edit this property as it doesnt work anyway

@jnmoyne
Copy link
Contributor

jnmoyne commented Jul 28, 2023

It should fail if you try to use that option on a stream that is a mirror IMHO.

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

4 participants