Skip to content

Commit 5cd635d

Browse files
committed
Exit main PITR loop during physical restore
When main PITR loop is active, it starts to log error messages due to fact that MongoDB is down during physical restore.
1 parent 073af7d commit 5cd635d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

pbm/restore/physical.go

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

0 commit comments

Comments
 (0)