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

[CHANGED] PurgeDeletes() will now keep markers that are less than 30min old #906

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

kozlovic
Copy link
Member

@kozlovic kozlovic commented Feb 11, 2022

There is a breaking change where PurgeDeletes() accepts now a list
of PurgeOpt, not WatchOpt.

We needed from WatchOpt only the context, and as it standed, it was
bad since user could have passed the IncludeHistory() option to
PurgeDeletes(), which would likely "break" the functionality.

Also, when invoking PurgeDeletes(), the delete markers than are older than
a default of 30 minutes will be deleted, however more recent ones will
be kept. The data is always removed, even if a marker is not.

The user can change the 30 minutes threshold using a new purge
option called DeleteMarkersOlderThan(duration). If set to -1,
it restores the old behavior of deleting delete/purge markers,
regardless of their age.

Signed-off-by: Ivan Kozlovic ivan@synadia.com

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.

I like it, we should place under normal PurgeDeletes though IMO.

We can change over the WatchOpts possibly since I think we only use them for context here.

kv.go Outdated Show resolved Hide resolved
kv.go Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Feb 11, 2022

Coverage Status

Coverage increased (+0.04%) to 85.218% when pulling 4afdb30 on kv_purge_with_time into 3ead809 on main.

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!

@kozlovic
Copy link
Member Author

@derekcollison Yes, but we have a problem. This would work (ability to set the value) only in case where user calls CreateKeyValue(). For KeyValue() (lookup and bind), that won't work. So either we make it a kvs setter, or we pull Wally's PR (remove WatchOpt and add PurgeOpt) but then add the new logic with Keep:1.

@derekcollison
Copy link
Member

Good point. I would say for now remove option to set and we can see how things play out if folks really want to change it. Those tombstones are small so as long as we remove the history itself and keep them should be fine with default of 30mins to start.

@kozlovic
Copy link
Member Author

kozlovic commented Feb 15, 2022

Ok, sounds good. I will keep it internally so that I can override for tests, but otherwise will not expose it.

Argh... tests are in test/ package, so I can't. Will have to move the test into nats package..

@kozlovic kozlovic changed the title [ADDED] KV: ability to delete purges older than a certain time [CHANGED] PurgeDeletes() will now keep markers than are less than 30min old Feb 15, 2022
@kozlovic
Copy link
Member Author

@derekcollison Ok, I have updated the PR by removing the option and move a test to nats package so I can override the 30min for the test. I also changed the PR's title to indicate the change in behavior (especially that it is not configurable atm).

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

@kozlovic
Copy link
Member Author

@derekcollison @wallyqs I think it would make sense to bring Wallys changes (from the gist) so we can have "purge options" to replace "WatchOpt" because otherwise users could really break the PurgeDeletes() call, say by passing IncludeHistory, etc.. Also, it would be nice to be able to set the option of this threshold.
So if you don't mind, I will take Wally's changes and update this PR.

@kozlovic kozlovic changed the title [CHANGED] PurgeDeletes() will now keep markers than are less than 30min old [CHANGED] PurgeDeletes() will now keep markers that are less than 30min old Feb 15, 2022
…in old

There is a breaking change where PurgeDeletes() accepts now a list
of PurgeOpt, not WatchOpt.

We needed from WatchOpt only the context, and as it standed, it was
bad since user could have passed the IncludeHistory() option to
PurgeDeletes(), which would likely "break" the functionality.

Also, when invoking PurgeDeletes(), the delete markers than are older than
a default of 30 minutes will be deleted, however more recent ones will
be kept. The data is always removed, even if a marker is not.

The user can change the 30 minutes threshold using a new purge
option called DeleteMarkersOlderThan(duration). If set to -1,
it restores the old behavior of deleting delete/purge markers,
regardless of their age.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
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!

@kozlovic
Copy link
Member Author

@derekcollison @wallyqs Ok, last iteration I promise :-) I have taken Wally's changes (although I had to remove type purgeOptFn and its configurePurge receiver since they were not used - staticcheck would fail).
So this is still keeping the markers that are less than 30 minutes old by default, but can be changed through option. Also, removes use of WatchOpt for PurgeDeletes() which could have been mis-used.

@kozlovic kozlovic merged commit 519bc35 into main Feb 15, 2022
@kozlovic kozlovic deleted the kv_purge_with_time branch February 15, 2022 18:31
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.

5 participants