From 65603801ccb8efd0a4d1aeeeac45ebcc8cbd1c27 Mon Sep 17 00:00:00 2001 From: Vasiliy Ivanov Date: Thu, 18 Sep 2025 23:23:03 +0200 Subject: [PATCH] Cleanup never terminates helper processes The problem is caused by additional grep command that was introduced in 4bfd4c0. Expressions starting with -- should be escaped properly to returns anything. The command pipeline is failed with: > grep: unrecognized option '--pipe-file on stderr and empty stdout. As a result, process cleanup do nothing. This patch add expression separators for grep command. Ticket: ADBDEV-8304 --- utils/agent_remote.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/agent_remote.go b/utils/agent_remote.go index 82fdb5200..3484afb65 100644 --- a/utils/agent_remote.go +++ b/utils/agent_remote.go @@ -279,7 +279,7 @@ func CheckHelperPids(c *cluster.Cluster, fpInfo filepath.FilePathInfo, operation procPattern := fmt.Sprintf("gpbackup_helper --%s-agent --toc-file %s*", operation, tocFile) pipeFile := fpInfo.GetSegmentPipeFilePath(contentID) pipePattern := fmt.Sprintf("--pipe-file %s", pipeFile) - return fmt.Sprintf(`ps ux | grep "%s" | grep "%s" | grep -v grep | awk '{print $2}'`, procPattern, pipePattern) + return fmt.Sprintf(`ps ux | grep -- "%s" | grep -- "%s" | grep -v grep | awk '{print $2}'`, procPattern, pipePattern) }) pidMap := make(map[string][]int) for _, cmd := range remoteOutput.Commands { @@ -320,7 +320,7 @@ func CleanUpSegmentHelperProcesses(c *cluster.Cluster, fpInfo filepath.FilePathI procPattern := fmt.Sprintf("gpbackup_helper --%s-agent --toc-file %s", operation, tocFile) pipeFile := fpInfo.GetSegmentPipeFilePath(contentID) pipePattern := fmt.Sprintf("--pipe-file %s", pipeFile) - return fmt.Sprintf("PIDS=`ps ux | grep \"%s\" | grep \"%s\" | grep -v grep | awk '{print $2}'`; if [[ ! -z \"$PIDS\" ]]; then kill -USR1 $PIDS; fi", procPattern, pipePattern) + return fmt.Sprintf("PIDS=`ps ux | grep -- \"%s\" | grep -- \"%s\" | grep -v grep | awk '{print $2}'`; if [[ ! -z \"$PIDS\" ]]; then kill -USR1 $PIDS; fi", procPattern, pipePattern) }) case <-time.After(timeout): for host, pids := range helperPids {