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

[ADDED] StartRevision option to KV watcher #1489

Merged
merged 8 commits into from Dec 18, 2023
Merged

Conversation

shadow3x3x3
Copy link
Contributor

fix #1488

@derekcollison
Copy link
Member

There is a DeliverNew delivery policy, which combined with a filter subject might do the trick.

@ripienaar
Copy link
Contributor

@Jarema has some summary of our internal discussions here that we need to capture when evaluating this PR.

Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

Hey!

Thanks for the proposal and effort to make a PR!

As this feature may look like a no brainer, it can introduce a potential footgun to the users:
If you start Watcher from some sequence, you will entirely skip keys that were not updated since that sequence.
We were discussing if this should go in at all, but there is a valid use case:
To resume watching the keys after some errors/crash, as user might now want to start the whole process from the start.
This might also apply for some long running process even if it's scheduled downtime. Right now there is no way to start from where the work on watcher was left off.

So, to avoid making a footgun for people who will see it and use it without proper consideration, let's rename StartRevision to ResumeFromSeq clearly stating the intent of this option.

@shadow3x3x3
Copy link
Contributor Author

So, to avoid making a footgun for people who will see it and use it without proper consideration, let's rename StartRevision to ResumeFromSeq clearly stating the intent of this option.

Yes, I completely agree.

This might also apply for some long running process even if it's scheduled downtime. Right now there is no way to start from where the work on watcher was left off.

At the moment, we are encountering a challenge where, in an unreliable network, multiple clients reconnecting can only commence watching from the start. This leads to some resource wastage, particularly when the bucket has a lengthy history.

Appreciate your attention to this feature. I've updated the relevant names. Kindly verify when you have a moment. Thanks!

@ripienaar
Copy link
Contributor

At the moment, we are encountering a challenge where, in an unreliable network, multiple clients reconnecting can only commence watching from the start. This leads to some resource wastage, particularly when the bucket has a lengthy history.

A watch from a reconnecting client should continue where it left off, is that not the case?

If that's what you are trying to solve then there's a bug to fix because they should resume.

@shadow3x3x3
Copy link
Contributor Author

A watch from a reconnecting client should continue where it left off, is that not the case?

Thank you for your reminder.

It seems I'm closing the existing watch every time I reconnect and then watching again upon reconnection.

However, it seems unnecessary; I just need to keep watching to retrieve the data again. 😅

Then, should we proceed with this PR?

@ripienaar
Copy link
Contributor

I think we need the resume functionality, but this is good it means we can strongly state this as resume and your main problem is solved. Good outcome all round I think.

@Jarema wdyt?

@Jarema
Copy link
Member

Jarema commented Dec 14, 2023

Yes, I agree. This is good!

Will do a proper review of the code soon.

Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

This looks good, just one change request.

Sorry for getting back and forth with naming, but your argument named for new option revision gave us the hint that the whole method should be around reviosion, not sequence. After all this is KV abstraction over stream :).

@@ -402,6 +402,14 @@ func MetaOnly() WatchOpt {
})
}

// ResumeFromSeq instructs the key watcher to resume from a specific sequence number.
func ResumeFromSeq(revision uint64) WatchOpt {
Copy link
Member

Choose a reason for hiding this comment

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

As this is KV abstraction over Stream, we should probably use KV naming convetions.

This should become ResumeFromRevision.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Related Sequence names have been updated to Revision.

Please take a look, thanks!

Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks for your contribution!

Copy link
Collaborator

@piotrpio piotrpio left a comment

Choose a reason for hiding this comment

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

LGTM!

@piotrpio piotrpio merged commit dce16a5 into nats-io:main Dec 18, 2023
1 check passed
@piotrpio piotrpio mentioned this pull request Jan 12, 2024
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.

Add start revision option for KVStore
5 participants