Skip to content
Snippets Groups Projects
Unverified Commit 692c285f authored by Manish R Jain's avatar Manish R Jain
Browse files

Backup Bug: Fix the bug due to which a single node cluster couldn't run

backup.
parent bd7f3e11
No related branches found
No related tags found
No related merge requests found
......@@ -514,8 +514,12 @@ func backupHandler(w http.ResponseWriter, r *http.Request) {
}
ctx := context.Background()
worker.BackupOverNetwork(ctx)
x.SetStatus(w, x.ErrorOk, "Backup completed.")
err = worker.BackupOverNetwork(ctx)
if err != nil {
x.SetStatus(w, err.Error(), "Backup failed.")
} else {
x.SetStatus(w, x.ErrorOk, "Backup completed.")
}
}
// server is used to implement graph.DgraphServer
......
......@@ -271,11 +271,11 @@ func (w *grpcWorker) Backup(ctx context.Context, req *BackupPayload) (*BackupPay
}
}
func BackupOverNetwork(ctx context.Context) {
func BackupOverNetwork(ctx context.Context) error {
// If we haven't even had a single membership update, don't run backup.
if groups().LastUpdate() == 0 {
if len(*peer) > 0 && groups().LastUpdate() == 0 {
x.Trace(ctx, "This server hasn't yet been fully initiated. Please retry later.")
return
return x.Errorf("Uninitiated server. Please retry later")
}
// Let's first collect all groups.
gids := groups().KnownGroups()
......@@ -292,9 +292,11 @@ func BackupOverNetwork(ctx context.Context) {
bp := <-ch
if bp.Status != BackupPayload_SUCCESS {
x.Trace(ctx, "Backup status: %v for group id: %d", bp.Status, bp.GroupId)
return fmt.Errorf("Backup status: %v for group id: %d", bp.Status, bp.GroupId)
} else {
x.Trace(ctx, "Backup successful for group: %v", bp.GroupId)
}
}
x.Trace(ctx, "DONE backup")
return nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment