Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RekGRpth committed Dec 6, 2024
1 parent 04d77da commit 9a4a45c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
24 changes: 12 additions & 12 deletions filepath/filepath.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,6 @@ func (backupFPInfo *FilePathInfo) GetSegmentPipeFilePath(contentID int, helperId
return backupFPInfo.replaceCopyFormatStringsInPath(templateFilePath, contentID)
}

func FormatSuffix(suffix string, helperIdx ...int) string {
switch len(helperIdx) {
case 0:
break
case 1:
suffix += fmt.Sprintf("%d", helperIdx[0])
default:
gplog.Fatal(errors.New("helperIdx slice should have <= 1 elements"), "")
}
return suffix
}

func (backupFPInfo *FilePathInfo) GetSegmentPipePathForCopyCommand(helperIdx ...int) string {
return fmt.Sprintf("<SEG_DATA_DIR>/gpbackup_<SEGID>_%s_%d_%s", backupFPInfo.Timestamp, backupFPInfo.PID, FormatSuffix("pipe", helperIdx...))
}
Expand Down Expand Up @@ -304,3 +292,15 @@ func GetSegPrefix(connectionPool *dbconn.DBConn) string {
segPrefix = segPrefix[:len(segPrefix)-2] // Remove "-1" segment ID from string
return segPrefix
}

func FormatSuffix(suffix string, helperIdx ...int) string {
switch len(helperIdx) {
case 0:
break
case 1:
suffix += fmt.Sprintf("%d", helperIdx[0])
default:
gplog.Fatal(errors.New("helperIdx slice should have <= 1 elements"), "")
}
return suffix
}
9 changes: 9 additions & 0 deletions utils/agent_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
path "path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -368,3 +369,11 @@ func CreateSkipFileOnSegments(oid uint32, tableName string, c *cluster.Cluster,
return fmt.Sprintf("Could not create skip file %s_%d on segments", GetSkipFilename(fpInfo.GetSegmentPipeFilePath(contentID, helperIdx...)), oid)
})
}

func GetErrorFilename(pipeFile string) string {
return regexp.MustCompile(`_pipe(\d*)$`).ReplaceAllString(pipeFile, "_error$1")
}

func GetSkipFilename(pipeFile string) string {
return regexp.MustCompile(`_pipe(\d*)$`).ReplaceAllString(pipeFile, "_skip$1")
}
2 changes: 1 addition & 1 deletion utils/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func (plugin *PluginConfig) BackupSegmentTOCs(c *cluster.Cluster, fpInfo filepat
cluster.ON_SEGMENTS,
func(contentID int) string {
tocFile := fpInfo.GetSegmentTOCFilePath(contentID)
errorFile := fmt.Sprintf("%s_error", fpInfo.GetSegmentPipeFilePath(contentID))
errorFile := GetErrorFilename(fpInfo.GetSegmentPipeFilePath(contentID))
command = fmt.Sprintf(`while [[ ! -f "%s" && ! -f "%s" ]]; do sleep 1; done; ls "%s"`, tocFile, errorFile, tocFile)
return command
})
Expand Down
8 changes: 0 additions & 8 deletions utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,3 @@ func GetFileHash(filename string) ([32]byte, error) {
}
return filehash, nil
}

func GetErrorFilename(pipeFile string) string {
return regexp.MustCompile(`_pipe(\d*)$`).ReplaceAllString(pipeFile, "_error$1")
}

func GetSkipFilename(pipeFile string) string {
return regexp.MustCompile(`_pipe(\d*)$`).ReplaceAllString(pipeFile, "_skip$1")
}

0 comments on commit 9a4a45c

Please sign in to comment.