Skip to content

Commit

Permalink
Timeouted wait until pipe created before restoring from it
Browse files Browse the repository at this point in the history
  • Loading branch information
RekGRpth committed May 14, 2024
1 parent 76cd98a commit 60c53b6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion restore/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ func CopyTableIn(queryContext context.Context, connectionPool *dbconn.DBConn, ta
readFromDestinationCommand := "cat"
customPipeThroughCommand := utils.GetPipeThroughProgram().InputCommand
origSize, destSize, resizeCluster := GetResizeClusterInfo()
checkPipeExistsCommand := fmt.Sprintf("(timeout 60 bash -c \"while [ ! -p \"%s\" ]; do sleep 1; done\" || (echo \"Pipe not found %s\">&2; exit 1)) && ", destinationToRead, destinationToRead)

if singleDataFile || resizeCluster {
//helper.go handles compression, so we don't want to set it here
customPipeThroughCommand = "cat -"
} else if MustGetFlagString(options.PLUGIN_CONFIG) != "" {
checkPipeExistsCommand = ""
readFromDestinationCommand = fmt.Sprintf("%s restore_data %s", pluginConfig.ExecutablePath, pluginConfig.ConfigPath)
}

copyCommand = fmt.Sprintf("PROGRAM '%s %s | %s'", readFromDestinationCommand, destinationToRead, customPipeThroughCommand)
copyCommand = fmt.Sprintf("PROGRAM '%s%s %s | %s'", checkPipeExistsCommand, readFromDestinationCommand, destinationToRead, customPipeThroughCommand)

query := fmt.Sprintf("COPY %s%s FROM %s WITH CSV DELIMITER '%s' ON SEGMENT;", tableName, tableAttributes, copyCommand, tableDelim)

Expand Down

0 comments on commit 60c53b6

Please sign in to comment.