Skip to content

Commit

Permalink
fix(restore): init metrics just once
Browse files Browse the repository at this point in the history
Commit 14aef7b introduced metrics initialization during
workload indexing (tablesWorker.initMetrics).
It forgot to remove previous metrics initialization
(tablesWorker.initRestoreMetrics) performed at the beginning
of the restore task.
  • Loading branch information
Michal-Leszczynski committed Oct 8, 2024
1 parent f8c7a97 commit a45aaad
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions pkg/service/restore/tables_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (

"github.com/pkg/errors"
"github.com/scylladb/go-set/strset"
"github.com/scylladb/scylla-manager/v3/pkg/metrics"
. "github.com/scylladb/scylla-manager/v3/pkg/service/backup/backupspec"
"github.com/scylladb/scylla-manager/v3/pkg/service/repair"
"github.com/scylladb/scylla-manager/v3/pkg/util/parallel"
"github.com/scylladb/scylla-manager/v3/pkg/util/query"
Expand Down Expand Up @@ -90,11 +88,6 @@ func newTablesWorker(w worker, repairSvc *repair.Service, totalBytes int64) (*ta

// restore files from every location specified in restore target.
func (w *tablesWorker) restore(ctx context.Context) error {
// Init metrics only on fresh start
if w.run.PrevID == uuid.Nil {
w.initRestoreMetrics(ctx)
}

stageFunc := map[Stage]func() error{
StageDropViews: func() error {
for _, v := range w.run.Views {
Expand Down Expand Up @@ -265,51 +258,3 @@ func (w *tablesWorker) stageRepair(ctx context.Context) error {

return w.repairSvc.Repair(ctx, w.run.ClusterID, w.run.RepairTaskID, repairRunID, repairTarget)
}

func (w *tablesWorker) initRestoreMetrics(ctx context.Context) {
for _, location := range w.target.Location {
err := w.forEachManifest(
ctx,
location,
func(miwc ManifestInfoWithContent) error {
sizePerTableAndKeyspace := make(map[string]map[string]int64)
err := miwc.ForEachIndexIterWithError(
nil,
func(fm FilesMeta) error {
if !unitsContainTable(w.run.Units, fm.Keyspace, fm.Table) {
return nil
}

if sizePerTableAndKeyspace[fm.Keyspace] == nil {
sizePerTableAndKeyspace[fm.Keyspace] = make(map[string]int64)
}
sizePerTableAndKeyspace[fm.Keyspace][fm.Table] += fm.Size
return nil
})
for kspace, sizePerTable := range sizePerTableAndKeyspace {
for table, size := range sizePerTable {
labels := metrics.RestoreBytesLabels{
ClusterID: w.run.ClusterID.String(),
SnapshotTag: w.target.SnapshotTag,
Location: location.String(),
DC: miwc.DC,
Node: miwc.NodeID,
Keyspace: kspace,
Table: table,
}
w.metrics.SetRemainingBytes(labels, size)
}
}
return err
})
progressLabels := metrics.RestoreProgressLabels{
ClusterID: w.run.ClusterID.String(),
SnapshotTag: w.target.SnapshotTag,
}
w.metrics.SetProgress(progressLabels, 0)
if err != nil {
w.logger.Info(ctx, "Couldn't count restore data size")
continue
}
}
}

0 comments on commit a45aaad

Please sign in to comment.