Drop frostfs_node_engine_container_size_bytes and ..._count_total metric for removed containers #889

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-node:fix/drop_zero_metrics into master 2024-09-04 19:51:05 +00:00

Now metrics frostfs_node_engine_container_size_bytes and frostfs_node_engine_container_objects_total for removed container will be deleted after container removal.
Shard's GC checks every epoch metabase for containers with size = 0, checks container availability and size for this container on other shards, then deletes metric.

Also small refactoring for metabase inhume/delete: removed redundant fields, renamed counters.

Relates #864

Now metrics `frostfs_node_engine_container_size_bytes` and `frostfs_node_engine_container_objects_total` for removed container will be deleted after container removal. Shard's GC checks every epoch metabase for containers with size = 0, checks container availability and size for this container on other shards, then deletes metric. Also small refactoring for metabase inhume/delete: removed redundant fields, renamed counters. Relates #864
dstepanov-yadro reviewed 2023-12-27 17:16:45 +00:00
@ -291,0 +307,4 @@
func (s *containerSource) IsContainerAvailable(ctx context.Context, id cid.ID) (bool, error) {
if s == nil || s.cs == nil {
return true, nil
Author
Member

By default all containers are available

By default all containers are available
dstepanov-yadro force-pushed fix/drop_zero_metrics from 6464d55743 to c516e58eaa 2023-12-27 17:23:40 +00:00 Compare
dstepanov-yadro requested review from storage-core-committers 2023-12-27 17:47:23 +00:00
dstepanov-yadro requested review from storage-core-developers 2023-12-27 17:47:24 +00:00
dstepanov-yadro changed title from Drop frostfs_node_engine_container_size_bytes metric for removed containers to Drop frostfs_node_engine_container_size_bytes and ..._count_total metric for removed containers 2023-12-28 09:29:21 +00:00
elebedeva reviewed 2023-12-28 13:46:53 +00:00
@ -291,0 +302,4 @@
}
type containerSource struct {
cs container.Source
Member

Is it necessary to wrap container.Source in a new type?

Is it necessary to wrap ```container.Source``` in a new type?
Author
Member

Yes. container.Source is an interface, but atomic.Value doesn't support changing type. From docs: All calls to CompareAndSwap for a given Value must use values of the same concrete type.

Yes. `container.Source` is an interface, but `atomic.Value` doesn't support changing type. From docs: `All calls to CompareAndSwap for a given Value must use values of the same concrete type. `
elebedeva marked this conversation as resolved
fyrchik reviewed 2023-12-29 09:51:07 +00:00
@ -291,0 +320,4 @@
if err == nil {
return true, nil
}
if client.IsErrContainerNotFound(err) {
Owner

Get is not enough, there should be a DeletionInfo somewhere.

`Get` is not enough, there should be a `DeletionInfo` somewhere.
Author
Member

Fixed

Fixed
fyrchik marked this conversation as resolved
@ -262,0 +417,4 @@
}
}
func (e *StorageEngine) selectNonExistedIDs(ctx context.Context, ids []cid.ID) (map[cid.ID]struct{}, error) {
Owner

nonExistent?

`nonExistent`?
Author
Member

Fixed

Fixed
fyrchik marked this conversation as resolved
@ -483,0 +647,4 @@
return metaerr.Wrap(err)
}
// ZeroCountContainers returns containers with count = 0.
Owner

It is not obvious, what count is from the comment.

It is not obvious, what `count` is from the comment.
Author
Member

Fixed

Fixed
fyrchik marked this conversation as resolved
dstepanov-yadro force-pushed fix/drop_zero_metrics from 80a25a549d to 0cd1bc08fe 2023-12-29 11:40:13 +00:00 Compare
dstepanov-yadro force-pushed fix/drop_zero_metrics from 0cd1bc08fe to ef8328176e 2024-01-09 07:00:05 +00:00 Compare
achuprov approved these changes 2024-01-09 08:49:00 +00:00
achuprov reviewed 2024-01-09 08:51:04 +00:00
@ -262,0 +271,4 @@
return
}
if len(idMap) == 0 {
Member

Is this check really necessary?

Is this check really necessary?
Author
Member

Yes: container may be empty, but still exist

Yes: container may be empty, but still exist
Member

Accidentally approved the PR.

Accidentally approved the PR.
dstepanov-yadro force-pushed fix/drop_zero_metrics from ef8328176e to 9bc8c45e74 2024-01-09 09:36:15 +00:00 Compare
acid-ant approved these changes 2024-01-09 12:34:12 +00:00
fyrchik reviewed 2024-01-09 15:45:17 +00:00
@ -291,0 +305,4 @@
cs container.Source
}
func (s *containerSource) IsContainerAvailable(ctx context.Context, id cid.ID) (bool, error) {
Owner

WasRemoved arguably serves the same purpose, but with inverted result. Isn't it enough? Like we only want to remove metric if WasRemoved returns true, nil.

`WasRemoved` arguably serves the same purpose, but with inverted result. Isn't it enough? Like we _only_ want to remove metric if `WasRemoved` returns `true, nil`.
Author
Member

Fixed

Fixed
fyrchik marked this conversation as resolved
@ -483,0 +693,4 @@
return result, nil
}
func (db *DB) DeleteContainerCount(ctx context.Context, id cid.ID) error {
Owner

Why are DeleteContainerCount and DeleteContainerSize separate methods? It seems they become 0 simultaneously and are removed together too.

Why are `DeleteContainerCount` and `DeleteContainerSize` separate methods? It seems they become 0 simultaneously and are removed together too.
Author
Member

Nope, count may have non zero phy counter, but size (it is logical size) is already 0.

Nope, count may have non zero `phy` counter, but size (it is logical size) is already 0.
fyrchik marked this conversation as resolved
dstepanov-yadro force-pushed fix/drop_zero_metrics from 9bc8c45e74 to aec318b414 2024-01-10 07:26:26 +00:00 Compare
fyrchik approved these changes 2024-01-10 07:32:54 +00:00
@ -219,2 +221,4 @@
rebuildWorkersCount uint32
containerSource atomic.Value // type containerSource
Owner

Btw, why is it not atomic.Pointer?

Btw, why is it not `atomic.Pointer`?
Author
Member

old school, fixed.

old school, fixed.
dstepanov-yadro force-pushed fix/drop_zero_metrics from aec318b414 to 4b8b4da681 2024-01-10 07:45:42 +00:00 Compare
fyrchik approved these changes 2024-01-10 08:22:50 +00:00
fyrchik merged commit 4b8b4da681 into master 2024-01-10 08:33:52 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#889
No description provided.