-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: enable stale permission GC #223
feat: enable stale permission GC #223
Conversation
@@ -102,6 +102,11 @@ service Query { | |||
option (google.api.http).get = "/greenfield/storage/policy_for_group/{resource}/{principal_group_id}"; | |||
} | |||
|
|||
// Queries a policy by policy id | |||
rpc QueryPolicyById(QueryPolicyByIdRequest) returns (QueryPolicyByIdResponse) { |
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.
Currently enabe this api for e2e, might need to hide this api
x/storage/keeper/keeper.go
Outdated
k.permKeeper.ForceDeleteGroupPolicyForResource(ctx, resource.RESOURCE_TYPE_OBJECT, id) | ||
deletedCount++ | ||
// reaches the deletion limit during current endblocker | ||
if deletedCount > maxCleanup { |
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.
I finally know why forget the limit count above. Actually, we should limit the kv count per block. not the resource count.
} | ||
|
||
// the specified block height(iterator-key)'s stale resource permission metadata is purged | ||
if deleteInfo.IsEmpty() { |
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.
If the delete info is not empty, but some permission info associated with certain resources has already been deleted, it still needs update and persist.
x/storage/abci.go
Outdated
@@ -13,6 +13,7 @@ func BeginBlocker(ctx sdk.Context, keeper k.Keeper) { | |||
keeper.ClearDiscontinueObjectCount(ctx) | |||
keeper.ClearDiscontinueBucketCount(ctx) | |||
} | |||
keeper.InitDeleteInfo(ctx) |
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.
Why needs store this empty key if there is no deleted resource in this block.
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.
yeah actually this is redundant, because when appending resource ids to deleteInfo, we are still checking the key existence.
c9aebba
to
48f3a40
Compare
b3fe221
to
2b6af1b
Compare
377ca55
to
ee34014
Compare
// EventStalePolicyCleanup is emitted when specified block height's stale policies is garbage collected | ||
message EventStalePolicyCleanup { | ||
int64 blockNum = 1; | ||
DeleteInfo delete_info =2; |
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.
x/storage/keeper/keeper.go
Outdated
deleteStalePoliciesPrefixStore.Set(iterator.Key(), k.cdc.MustMarshal(deleteInfo)) | ||
return | ||
} | ||
k.permKeeper.ForceDeleteGroupMembers(ctx, id) |
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.
Why don't group members has a maximum cleanup count limit?
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.
added
|
||
func (k Keeper) GarbageCollectResourcesStalePolicy(ctx sdk.Context) { | ||
store := ctx.KVStore(k.storeKey) | ||
deleteStalePoliciesPrefixStore := prefix.NewStore(store, types.DeleteStalePoliciesPrefix) |
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.
Too many duplicated code here, I think we can improve it.
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.
refactored
x/storage/types/types.go
Outdated
if di == nil { | ||
return true | ||
} | ||
if di.BucketIds == nil || (di.BucketIds != nil && len(di.BucketIds.Id) == 0) { |
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.
di.BucketIds != nil
seems unnecessary.
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.
removed
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.
- [ ]
Description
When resource bucket and object are deleted by user, its associated stale policies linked to personal accounts or groups need to be garbage collected. For resource group, its associated stale policy with personal accounts, and all group members meta will be garbage collected. these are done in each endblock auto execution.
Rationale
Get rid of useless stale permission data
Example
NA
Changes
Notable changes: