metabase: fix mode metric #1049
No reviewers
Labels
No labels
P0
P1
P2
P3
badger
frostfs-adm
frostfs-cli
frostfs-ir
frostfs-lens
frostfs-node
good first issue
triage
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#1049
Loading…
Reference in a new issue
No description provided.
Delete branch "elebedeva/frostfs-node:fix/metabase-mode-metric"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Close #949
It used to always show CLOSED regardless of actual mode.
Now metric represents actual metabase mode of operations.
Metabase mode right after node is up:
Metabase mode after executing
frostfs-cli control shards set-mode --mode read-only --all --endpoint s01.frostfs.devenv:8081 --wallet ./../frostfs-dev-env/services/storage/wallet01.json
:Signed-off-by: Ekaterina Lebedeva ekaterina.lebedeva@yadro.com
WIP: metabase: fix metabase mode metricto metabase: fix metabase mode metric@ -36,0 +50,4 @@
return nil, ErrDegradedMode
}
if err := db.openDB(mode); err != nil {
This function (
GetShardID()
) is hard to use correctly: it reads the shard ID but also opens the database (and doesn't close it (!))What prevents us from closing it here? This way we could simplify
shard.UpdateID()
and also always use mode.readonly here (degraded check should be on shard it is useful uder operation).Fixed
@ -38,1 +36,3 @@
metabaseOpened = false
if idFromMetabase, err = s.metaBase.GetShardID(s.GetMode()); err != nil {
err = fmt.Errorf("failed to read shard id from metabase: %w", err)
if strings.Contains(err.Error(), "failed to open metabase") {
errors.Is
is more preferable in such situations.9f752b9a1d
toed35d301fc
ed35d301fc
toc209057b57
Change looks to complex. Is it not obvious that
GetShardID
andSetShardID
should open and close metabase. Please explain why not just adddb.metrics.SetMode(mode)
indb.Open
? Looks like this fixes metrics issue.Another issue is that metabase opens to get/set shardID in degraded mode. But this could be fixed only with additional checks in
Shard.UpdateID()
.Just adding
db.metrics.SetMode(mode)
indb.Open
causes this scenario:engine.createShard()
callsshard.UpdateID()
for a new shard. At this point shard id in metabase is empty.shard.UpdateID()
callsshard.metaBase.Open
(db.Open
) to read shard id from metabase.db.Open
reports its mode metrics with missing shard id.To fix this issue functions
GetShardID
andSetShardID
were added.GetShardID
does not report metabase mode metrics at all, andSetShardID
reports metabase mode metrics only if writing shard id to metabase was successful.c209057b57
toc5e18cfc7d
metabase: fix metabase mode metricto metabase: fix mode metric@elebedeva, agree with @dstepanov-yadro - changes is too complex. How about, instead of setting mode in
Open
method, set mode formetabase
whenshard_id
created - somewhere here, as it is done forwritecache
?Setting metabase mode outside of
Open()
seems strange to me. Sure, it solves the problem with undefined shard but it means we should also dometrics.SetMode()
after everymetabase.Open()
(or mode metric would be alwaysCLOSED
) - it seems even more complicated. Adding parameters likereportModeMetric bool
toOpen()
also seems impossible bc this function must implement certain interface declared here.c5e18cfc7d
tod5194ab2a6