Skip to content

Commit 13f5b32

Browse files
committed
Add meta creation in case of full RS error
1 parent 358c353 commit 13f5b32

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pbm/restore/physical.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,14 @@ func (r *PhysRestore) doFullCleanup() error {
284284
if err != nil {
285285
return errors.Wrapf(err, "flush dbpath %s", r.dbpath)
286286
}
287-
return nil
287+
288+
// cleanup went file, bug full cleanup represents error in case of restore
289+
return errors.New("full cleanup applyed")
288290
}
289291

290292
// doFallbackCleanup is node's cleanup strategy for recovering dbpath
291293
// from fallbacksync dir.
292-
// Mark cluster with fallback error.
294+
// It marks cluster with fallback error.
293295
func (r *PhysRestore) doFallbackCleanup() error {
294296
r.log.Warning("apply fallback cleanup strategy: using db data from %s", fallbackDir)
295297
err := r.migrateFromFallbackDirToDBDir()
@@ -300,11 +302,11 @@ func (r *PhysRestore) doFallbackCleanup() error {
300302
if r.nodeInfo.IsClusterLeader() {
301303
err = r.MarkAsFallback()
302304
if err != nil {
303-
return errors.Wrap(err, "mark meta as fallback")
305+
r.log.Warning("mark meta as fallback: %v", err)
304306
}
305307
}
306308

307-
// cleanup went file, bug follback represents error in case of restore
309+
// cleanup went file, bug fallback represents error in case of restore
308310
return errors.New("fallback applyed")
309311
}
310312

@@ -1299,6 +1301,14 @@ func (r *PhysRestore) Snapshot(
12991301

13001302
stat, err := r.toState(defs.StatusDone)
13011303
if err != nil {
1304+
if r.nodeInfo.IsLeader() {
1305+
// before returning try to create meta
1306+
r.log.Info("writing restore meta")
1307+
merr := r.dumpMeta(meta, stat, "")
1308+
if merr != nil {
1309+
r.log.Warning("writing restore meta to storage: %v", merr)
1310+
}
1311+
}
13021312
return errors.Wrapf(err, "moving to state %s", defs.StatusDone)
13031313
}
13041314

0 commit comments

Comments
 (0)