-
Notifications
You must be signed in to change notification settings - Fork 96
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
Bugfix: prune user buckets #812
Conversation
This was previously hardcoded to 24-hours. This allows the pruning time to be runtime (and startup) configurable. This can help in cases where the are frequent partitions, or frequent deletion of buckets.
riak_cs_utils:fetch_user was returning the wrong boolean for `KeepDeleted` buckets. This meant that buckets were being pruned in the opposite scenario from when they should. This change also prunes buckets even when there are no siblings.
|
user_buckets_prune_time() -> | ||
get_env(riak_cs, user_buckets_prune_time, ?USER_BUCKETS_PRUNE_TIME). | ||
|
||
-spec set_user_buckets_prune_time(integer()) -> ok | {error, invalid_value}. |
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.
pos_integer()
instead of integer()
like above?
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.
Addressed in 908f373.
Also I would suggest improving spec of -spec fetch_user(KeyId::binary(), pid()) ->
{ok, {riakc_obj(), ShouldKeepDeletedBuckets::boolean()}} |
{error, term()}. For clearer understanding and preventing misuse of boolean. |
Looks like this also fixes #799. |
+1 to merge regardless of above nitpick comments. Also confirmed that creating bucket after deleting another bucket removes old Eventually we'd add riak_test about this? |
-spec cleanup_bucket(cs_bucket()) -> boolean(). | ||
cleanup_bucket(?RCS_BUCKET{last_action=created}) -> | ||
false; | ||
cleanup_bucket(?RCS_BUCKET{last_action=deleted, | ||
modification_time=ModTime}) -> | ||
timer:now_diff(os:timestamp(), ModTime) > 86400. | ||
timer:now_diff(os:timestamp(), ModTime) > | ||
riak_cs_config:user_buckets_prune_time(). |
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.
Sorry for stepping in and I don't execute this fix ...
timer:now_diff/2
returns time interval in micro seconds and riak_cs_config:user_buckets_prune_time()
seems to be represented by seconds. Any mismatch??
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.
Nice catch! Fixed in 3ffac5d.
Per review feedback on #812.
This fixes a bug where seconds were used to compare with microseconds. This would cause deleted buckets to be pruned two orders of magnitude before they were supposed to.
I'm re-running all tests now. |
Yes. I'd like to try and think of a way of testing it that doesn't resort to |
code changes look good. dialyzer is clean regarding changes. tests running now. |
👍 |
+1, yay! |
Fixes #798.