Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
RekGRpth committed Nov 2, 2024
1 parent faabf0e commit 248dad2
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions restore/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func CopyTableIn(queryContext context.Context, connectionPool *dbconn.DBConn, ta
return rowsLoaded, nil
}

func restoreSingleTableData(queryContext context.Context, fpInfo *filepath.FilePathInfo, entry toc.CoordinatorDataEntry, tableName string, whichConn int) (error, error) {
func restoreSingleTableData(queryContext context.Context, cancel context.CancelFunc, fpInfo *filepath.FilePathInfo, entry toc.CoordinatorDataEntry, tableName string, whichConn int) error {
origSize, destSize, resizeCluster, batches := GetResizeClusterInfo()

var numRowsRestored int64
Expand Down Expand Up @@ -108,7 +108,8 @@ func restoreSingleTableData(queryContext context.Context, fpInfo *filepath.FileP
agentErr := utils.CheckAgentErrorsOnSegments(globalCluster, globalFPInfo)
if agentErr != nil {
gplog.Error(agentErr.Error())
return nil, agentErr
cancel()
return agentErr
}
}

Expand All @@ -122,7 +123,7 @@ func restoreSingleTableData(queryContext context.Context, fpInfo *filepath.FileP
utils.CreateSkipFileOnSegments(fmt.Sprintf("%d", entry.Oid), tableName, globalCluster, globalFPInfo)
}
}
return copyErr, nil
return copyErr
}
numRowsRestored += partialRowsRestored
}
Expand All @@ -140,7 +141,7 @@ func restoreSingleTableData(queryContext context.Context, fpInfo *filepath.FileP
err := CheckRowsRestored(numRowsRestored, numRowsBackedUp, tableName)
if err != nil {
gplog.Error(err.Error())
return err, nil
return err
}

if resizeCluster || entry.DistByEnum {
Expand All @@ -158,7 +159,7 @@ func restoreSingleTableData(queryContext context.Context, fpInfo *filepath.FileP
}
}

return nil, nil
return nil
}

func ExpandReplicatedTable(origSize int, tableName string, whichConn int) error {
Expand Down Expand Up @@ -295,7 +296,6 @@ func restoreDataFromTimestamp(fpInfo filepath.FilePathInfo, dataEntries []toc.Co
}
// Truncate table before restore, if needed
var err error
var agentErr error
if MustGetFlagBool(options.INCREMENTAL) || MustGetFlagBool(options.TRUNCATE_TABLE) {
gplog.Verbose("Truncating table %s prior to restoring data", tableName)
_, err := connectionPool.Exec(`TRUNCATE `+tableName, whichConn)
Expand All @@ -304,13 +304,7 @@ func restoreDataFromTimestamp(fpInfo filepath.FilePathInfo, dataEntries []toc.Co
}
}
if err == nil {
err, agentErr = restoreSingleTableData(ctx, &fpInfo, entry, tableName, whichConn)
if agentErr != nil {
atomic.AddInt32(&numErrors, 1)
dataProgressBar.(*pb.ProgressBar).NotPrint = true
cancel()
return
}
err = restoreSingleTableData(ctx, cancel, &fpInfo, entry, tableName, whichConn)
}

if err != nil {
Expand Down

0 comments on commit 248dad2

Please sign in to comment.