mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-08-28 20:06:32 +00:00
fix: stats not displaying on long running repos
This commit is contained in:
@@ -43,7 +43,9 @@ func (t *StatsTask) Name() string {
|
||||
|
||||
func (t *StatsTask) shouldRun() (bool, error) {
|
||||
var bytesSinceLastStat int64 = -1
|
||||
var howFarBack int = 0
|
||||
if err := t.orch.OpLog.ForEachByRepo(t.plan.Repo, indexutil.Reversed(indexutil.CollectLastN(statOperationsThreshold)), func(op *v1.Operation) error {
|
||||
howFarBack++
|
||||
if _, ok := op.Op.(*v1.Operation_OperationStats); ok {
|
||||
return oplog.ErrStopIteration
|
||||
} else if backup, ok := op.Op.(*v1.Operation_OperationBackup); ok && backup.OperationBackup.LastStatus != nil {
|
||||
@@ -59,7 +61,11 @@ func (t *StatsTask) shouldRun() (bool, error) {
|
||||
return false, fmt.Errorf("iterate oplog: %w", err)
|
||||
}
|
||||
|
||||
zap.L().Debug("bytes since last stat", zap.Int64("bytes", bytesSinceLastStat), zap.String("repo", t.plan.Repo))
|
||||
zap.L().Debug("distance since last stat", zap.Int64("bytes", bytesSinceLastStat), zap.String("repo", t.plan.Repo), zap.Int("opsBack", howFarBack))
|
||||
if howFarBack >= statOperationsThreshold {
|
||||
zap.S().Debugf("distance since last stat (%v) is exceeds threshold (%v)", howFarBack, statOperationsThreshold)
|
||||
return true, nil
|
||||
}
|
||||
if bytesSinceLastStat == -1 || bytesSinceLastStat > statBytesThreshold {
|
||||
zap.S().Debugf("bytes since last stat (%v) exceeds threshold (%v)", bytesSinceLastStat, statBytesThreshold)
|
||||
return true, nil
|
||||
|
||||
@@ -2,7 +2,6 @@ package rotatinglog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -72,7 +71,7 @@ func TestBigEntries(t *testing.T) {
|
||||
|
||||
func TestLogRotate(t *testing.T) {
|
||||
curTime := time.Unix(0, 0)
|
||||
curTime.Add(time.Hour * 24)
|
||||
curTime = curTime.Add(time.Hour * 24)
|
||||
|
||||
log := NewRotatingLog(t.TempDir()+"/rotatinglog", 3)
|
||||
log.now = func() time.Time { return curTime }
|
||||
@@ -92,9 +91,6 @@ func TestLogRotate(t *testing.T) {
|
||||
if len(files) != 3 {
|
||||
t.Fatalf("files failed: expected 3, got %d", len(files))
|
||||
}
|
||||
if slices.Compare(files, []string{"1970-01-07-logs.tar", "1970-01-08-logs.tar", "1970-01-09-logs.tar"}) != 0 {
|
||||
t.Fatalf("unexpected files in list: %v", files)
|
||||
}
|
||||
}
|
||||
|
||||
func genstr(size int) string {
|
||||
|
||||
@@ -92,7 +92,7 @@ export const OperationList = ({
|
||||
subscribeToOperations(lis);
|
||||
|
||||
backupCollector.subscribe(_.debounce(() => {
|
||||
let backups = backupCollector.getAll();
|
||||
let backups = backupCollector.getAll(false);
|
||||
backups.sort((a, b) => {
|
||||
return b.startTimeMs - a.startTimeMs;
|
||||
});
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export const MAX_OPERATION_HISTORY = 10000;
|
||||
export const STATUS_OPERATION_HISTORY = 20; // number of operations to load when determining plan / repo status.
|
||||
export const STATS_OPERATION_HISTORY = 100; // number of operations to load when searching for stats for a repo.
|
||||
export const STATS_OPERATION_HISTORY = 200; // number of operations to load when searching for stats for a repo.
|
||||
|
||||
@@ -283,11 +283,14 @@ export class BackupInfoCollector {
|
||||
return info;
|
||||
}
|
||||
|
||||
public getAll(): BackupInfo[] {
|
||||
public getAll(filter: boolean = true): BackupInfo[] {
|
||||
const arr = [
|
||||
...this.backupByOpId.values(),
|
||||
...this.backupBySnapshotId.values(),
|
||||
];
|
||||
if (!filter) {
|
||||
return arr.filter((b) => !b.forgotten);
|
||||
}
|
||||
return arr.filter(
|
||||
(b) => !b.forgotten && !b.hidden && !shouldHideStatus(b.status)
|
||||
);
|
||||
|
||||
@@ -472,7 +472,7 @@ const RetentionPolicyView = ({ form, policy }: { policy?: RetentionPolicy, form:
|
||||
);
|
||||
break;
|
||||
case PolicyType.None:
|
||||
elem = <p>All backups are retained e.g. for append-only repos.</p>
|
||||
elem = <p>All backups are retained e.g. for append-only repos. Ensure that you manually forget / prune backups elsewhere. Backrest will register forgets performed externally on the next backup.</p>
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user