Skip to content

Commit d79da30

Browse files
committed
Merge remote-tracking branch 'origin/dev' into PBM-1511-fallback-config-params
2 parents 345b400 + fb9b1c9 commit d79da30

File tree

7 files changed

+31
-10
lines changed

7 files changed

+31
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Percona Backup for MongoDB
22
[![Go Report Card](https://goreportcard.com/badge/github.com/percona/percona-backup-mongodb)](https://goreportcard.com/report/github.com/percona/percona-backup-mongodb) [![CLA assistant](https://cla-assistant.percona.com/readme/badge/percona/percona-backup-mongodb)](https://cla-assistant.percona.com/percona/percona-backup-mongodb)
33

4-
![PBM logo](backup-mongo.jpeg)
4+
![PBM logo](percona-backup-for-mongodb.png)
55

66
Percona Backup for MongoDB (PBM) is a distributed, low-impact solution for achieving
77
consistent backups of MongoDB sharded clusters and replica sets. Percona Backup for MongoDB supports Percona Server for MongoDB and MongoDB Community Edition v5.0 and higher.

backup-mongo.jpeg

-21.6 KB
Binary file not shown.

cmd/pbm-agent/pitr.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"maps"
66
"time"
77

8+
"go.mongodb.org/mongo-driver/bson/primitive"
89
"go.mongodb.org/mongo-driver/mongo"
910

1011
"github.com/percona/percona-backup-mongodb/pbm/backup"
@@ -110,6 +111,13 @@ func (a *Agent) PITR(ctx context.Context) {
110111
l.Printf("starting PITR routine")
111112

112113
for {
114+
select {
115+
case <-a.closeCMD:
116+
l.Debug(string(ctrl.CmdPITR), "", "", primitive.Timestamp{}, "stopping main loop")
117+
return
118+
default:
119+
}
120+
113121
err := a.pitr(ctx)
114122
if err != nil {
115123
// we need epoch just to log pitr err with an extra context

cmd/pbm/status.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,22 +470,35 @@ func (s storageStat) String() string {
470470
return a.RestoreTS > b.RestoreTS
471471
})
472472

473+
const (
474+
statusSuccess = "success"
475+
statusFailed = "failed"
476+
statusOngoing = "ongoing"
477+
)
478+
479+
var printStatus string
480+
473481
for i := range s.Snapshot {
474482
ss := &s.Snapshot[i]
475483
var status string
476484
switch ss.Status {
477485
case defs.StatusDone:
478486
status = fmt.Sprintf("[restore_to_time: %s]", fmtTS(ss.RestoreTS))
487+
printStatus = statusSuccess
479488
case defs.StatusCancelled:
480489
status = fmt.Sprintf("[!canceled: %s]", fmtTS(ss.RestoreTS))
490+
printStatus = statusFailed
481491
case defs.StatusError:
482492
if errors.Is(ss.Err, errIncompatible) {
483493
status = fmt.Sprintf("[incompatible: %s] [%s]", ss.Err.Error(), fmtTS(ss.RestoreTS))
494+
printStatus = statusSuccess
484495
} else {
485496
status = fmt.Sprintf("[ERROR: %s] [%s]", ss.Err.Error(), fmtTS(ss.RestoreTS))
497+
printStatus = statusFailed
486498
}
487499
default:
488500
status = fmt.Sprintf("[running: %s / %s]", ss.Status, fmtTS(ss.RestoreTS))
501+
printStatus = statusOngoing
489502
}
490503

491504
t := string(ss.Type)
@@ -497,7 +510,7 @@ func (s storageStat) String() string {
497510
if ss.StoreName != "" {
498511
t += ", *"
499512
}
500-
ret += fmt.Sprintf(" %s %s <%s> %s\n", ss.Name, storage.PrettySize(ss.Size), t, status)
513+
ret += fmt.Sprintf(" %s %s <%s> %s %s\n", ss.Name, storage.PrettySize(ss.Size), t, printStatus, status)
501514
}
502515

503516
if len(s.PITR.Ranges) == 0 {

pbm/backup/slicer.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ func startOplogSlicer(
5555
return
5656
}
5757

58-
majority, err := topo.IsWriteMajorityRequested(ctx, m, writeConcern)
59-
if err != nil {
60-
l.Error("failed to inspect requested majority: %v", err)
58+
majority, e := topo.IsWriteMajorityRequested(ctx, m, writeConcern)
59+
if e != nil {
60+
l.Error("failed to inspect requested majority: %v", e)
6161
}
62-
currOpTime, err := topo.GetLastWrite(ctx, m, majority)
63-
if err != nil {
64-
if errors.Is(err, context.Canceled) {
62+
currOpTime, e := topo.GetLastWrite(ctx, m, majority)
63+
if e != nil {
64+
if errors.Is(e, context.Canceled) {
6565
return
6666
}
6767

68-
l.Error("failed to get last write: %v", err)
68+
l.Error("failed to get last write: %v", e)
6969
continue
7070
}
7171
if !currOpTime.After(startOpTime) {

pbm/restore/physical.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ func (r *PhysRestore) Snapshot(
11341134
// the cmd stream anymore and will flood logs with errors on that.
11351135
l.Info("send to stopAgent chan")
11361136
if stopAgentC != nil {
1137-
stopAgentC <- struct{}{}
1137+
close(stopAgentC)
11381138
}
11391139
// anget will be stopped only after we exit this func
11401140
// so stop heartbeats not to spam logs while the restore is running

percona-backup-for-mongodb.png

30.4 KB
Loading

0 commit comments

Comments
 (0)