You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by do...@apache.org on 2022/01/19 14:11:30 UTC

[accumulo-testing] branch main updated: Eliminate possible race condition in `agitator stop` script (#187)

This is an automated email from the ASF dual-hosted git repository.

domgarguilo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo-testing.git


The following commit(s) were added to refs/heads/main by this push:
     new 7bab482  Eliminate possible race condition in `agitator stop` script (#187)
7bab482 is described below

commit 7bab4824f69c0c4e6b8c1336fd39262946a5c09f
Author: Dom G <do...@gmail.com>
AuthorDate: Wed Jan 19 09:11:22 2022 -0500

    Eliminate possible race condition in `agitator stop` script (#187)
    
    * Kill all processes in agitators proccess group
    * Improve log msg
    
    Co-authored-by: Christopher Tubbs <ct...@apache.org>
---
 bin/agitator | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/bin/agitator b/bin/agitator
index 3f532a7..47355d7 100755
--- a/bin/agitator
+++ b/bin/agitator
@@ -157,10 +157,13 @@ function start_agitator() {
 
 function stop_agitator() {
   [[ -n $AGITATOR_USER ]] || AGITATOR_USER=$(whoami)
-  echo "Stopping all processes matching 'sleep' as $AGITATOR_USER"
-  pkill -f sleep 2>/dev/null
-  echo "Stopping all processes matching 'agitator' as $AGITATOR_USER"
-  pkill -f agitator 2>/dev/null
+  echo "Stopping all processes in the same process group as 'agitator' as user $AGITATOR_USER"
+  ## get process ids of all agitator processes (return 1 if none found)
+  local agitator_pids=(); agitator_pids=($(pgrep -f "agitator start")) || return 1
+  ## get the group process ids of all agitator processes
+  local group_pids=(); group_pids=($(ps -o pgid= -p "${agitator_pids[@]}"))
+  ## kill all processes in the process groups (should include agitators and their sleep processes)
+  kill -- "${group_pids[@]/#/-}"
 }
 
 function parse_fail() {