Skip to content

Commit

Permalink
fix(restore): don't initialize metrics twice
Browse files Browse the repository at this point in the history
This was a left-over from the PR introducing
indexing (14aef7b). It also initialized metrics
as a part of the indexing procedure, but it
forgot to remove the previous metrics initialization
from the code.
  • Loading branch information
Michal-Leszczynski committed Oct 28, 2024
1 parent 2ba54e2 commit a9a3e78
Showing 1 changed file with 0 additions and 54 deletions.
54 changes: 0 additions & 54 deletions pkg/service/restore/tables_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +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"
Expand Down Expand Up @@ -91,11 +90,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 @@ -306,54 +300,6 @@ 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
}
}
}

// Disables auto compaction on all provided hosts and units.
func (w *tablesWorker) setAutoCompaction(ctx context.Context, hosts []string, enabled bool) error {
f := w.client.EnableAutoCompaction
Expand Down

0 comments on commit a9a3e78

Please sign in to comment.