-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
116 changed files
with
4,003 additions
and
3,545 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"go.mongodb.org/mongo-driver/bson/primitive" | ||
|
||
"github.com/percona/percona-backup-mongodb/internal/backup" | ||
"github.com/percona/percona-backup-mongodb/internal/ctrl" | ||
"github.com/percona/percona-backup-mongodb/internal/defs" | ||
"github.com/percona/percona-backup-mongodb/internal/errors" | ||
"github.com/percona/percona-backup-mongodb/internal/lock" | ||
"github.com/percona/percona-backup-mongodb/internal/log" | ||
"github.com/percona/percona-backup-mongodb/internal/restore" | ||
) | ||
|
||
func markBcpStale(ctx context.Context, l *lock.Lock, opid string) error { | ||
bcp, err := backup.GetBackupByOPID(ctx, l.Connect(), opid) | ||
if err != nil { | ||
return errors.Wrap(err, "get backup meta") | ||
} | ||
|
||
// not to rewrite an error emitted by the agent | ||
if bcp.Status == defs.StatusError || bcp.Status == defs.StatusDone { | ||
return nil | ||
} | ||
|
||
if logger := log.FromContext(ctx); logger != nil { | ||
logger.Debug(string(ctrl.CmdBackup), "", opid, primitive.Timestamp{}, "mark stale meta") | ||
} | ||
return backup.ChangeBackupStateOPID(l.Connect(), opid, defs.StatusError, | ||
"some of pbm-agents were lost during the backup") | ||
} | ||
|
||
func markRestoreStale(ctx context.Context, l *lock.Lock, opid string) error { | ||
r, err := restore.GetRestoreMetaByOPID(ctx, l.Connect(), opid) | ||
if err != nil { | ||
return errors.Wrap(err, "get retore meta") | ||
} | ||
|
||
// not to rewrite an error emitted by the agent | ||
if r.Status == defs.StatusError || r.Status == defs.StatusDone { | ||
return nil | ||
} | ||
|
||
if logger := log.FromContext(ctx); logger != nil { | ||
logger.Debug(string(ctrl.CmdRestore), "", opid, primitive.Timestamp{}, "mark stale meta") | ||
} | ||
return restore.ChangeRestoreStateOPID(ctx, l.Connect(), opid, defs.StatusError, | ||
"some of pbm-agents were lost during the restore") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.