Commit 6b5b38a
committed
[yugabyte#19817] PLAT: Kill all running PG processes via 'tserver start/stop' script
Summary:
The current implementation of `tserver start` and `tserver stop` scripts fail to kill all running PG processes if the PIDs of these processes contain a varying number of digits.
As an example, consider a PID list as follows:
- 925
- 4165
- 4166
- 7267
- 15228
- 94482
- 94663
It is observed that the PIDS 925, 4165, 4166 and 7267 are skipped over.
The list of PIDs of running PG processes is fetched from the `ps` command whose output by default is width padded to the length of the widest row (the process whose PID contains the most digits).
Currently, the `tserver start/stop` script skips over those PIDs that contain any padding.
In other words, processes whose PID does not contain the same number of digits as the largest PID are skipped over.
This revision alters the output format of the `ps` command to contain no padding to ensure that all PG processes are killed.
The `--no-headers` option is the more explicit equivalent to setting the field headers to blank via the syntax `-o <field>=`
Test Plan:
Run the following manual test to ensure that the output of the `ps` command is formatted correctly:
```
# Capture a list of processes whose PIDs have a varying number of digits.
# The init process (PID=1) is a good candidate.
mapfile -t pg_pids < <(ps --no-headers -p 1 --ppid 1 -o pid:1)
# Print out the process PID list to visually verify no padding.
printf '%s\n' "${pg_pids[@]}"
# Run the process PID list through the regex used in tserver stop to verify that all PIDs are captured.
# The count of process captured by the regex must be identical to the number of PIDs in the list.
count=0
for pg_pid in "${pg_pids[@]}";
do
if [[ ${pg_pid} =~ ^[0-9]+$ ]]; then
count=$((count+1))
fi
done
echo "Num processes: ${#pg_pids[@]}"
echo "Count: $count"
```
Reviewers: telgersma, smishra, sanketh, muthu
Reviewed By: telgersma, muthu
Subscribers: yql, yugaware
Tags: #jenkins-ready
Differential Revision: https://phorge.dev.yugabyte.com/D314971 parent 0acd4ac commit 6b5b38a
File tree
1 file changed
+4
-1
lines changed- managed/devops/roles/configure-cluster-server/templates
1 file changed
+4
-1
lines changedLines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
185 | 187 | | |
186 | | - | |
| 188 | + | |
| 189 | + | |
187 | 190 | | |
188 | 191 | | |
189 | 192 | | |
| |||
0 commit comments