JackieTien97 commented on code in PR #18546:
URL: https://github.com/apache/iotdb/pull/18546#discussion_r3892676968
##########
scripts/sbin/stop-edge.sh:
##########
@@ -31,9 +41,14 @@ is_same_edge_home() {
return 0
;;
*)
- return 1
;;
esac
+ # Fall back to comparing resolved paths, so that a start-edge.sh invoked
with
+ # IOTDB_HOME pointing at a symlink is still recognised here.
+ local home="${command_line#*-DIOTDB_HOME=}"
+ home="${home%% -D*}"
+ [ -n "$home" ] && [ "$home" != "$command_line" ] || return 1
+ [ "$(resolve_home "$home")" = "${IOTDB_HOME_RESOLVED}" ]
Review Comment:
**[P1] Resolve relative process homes using the process's working directory**
`start-edge.sh` accepts `IOTDB_HOME=.` and passes it unchanged to the JVM.
If an instance was started this way in `/srv/edge-a`, running
`/srv/edge-b/sbin/stop-edge.sh` from `/srv/edge-b` with `IOTDB_HOME` unset
resolves the process's `.` to B. Consequently, `find_edge_processes` considers
A a match and terminates it, even if B has no PID file or running instance. The
base script rejects this process; the new fallback accepts it.
Please normalize the home to a physical absolute path at launch, or resolve
relative process values against that process's working directory; do not
resolve them against the stopping shell's working directory.
##########
scripts/sbin/stop-edge.sh:
##########
@@ -20,7 +20,17 @@
# Stop IoTDB Edge (the merged ConfigNode + DataNode process).
-IOTDB_HOME="$(cd "$(dirname "$0")"/.. && pwd)"
+if [ -z "${IOTDB_HOME}" ]; then
+ IOTDB_HOME="$(cd "$(dirname "$0")"/.. && pwd)"
+fi
+
+# Resolve symlinks and relative segments so that the same installation reached
+# through a different path still compares equal.
+resolve_home() {
+ (cd "$1" 2>/dev/null && pwd -P) || printf '%s' "$1"
Review Comment:
**[P2] Use physical cd semantics before resolving `..`**
`pwd -P` only resolves the directory reached by `cd`; plain `cd` has already
collapsed `..` logically. With `/x/link` pointing to `/y/sub`, a process home
`/x/link/../edge` accesses `/y/edge`, but this helper returns `/x/edge` when
that directory exists. Consequently, stopping `/x/edge` can terminate the
`/y/edge` instance, while stopping `/y/edge` can miss it. This also reproduces
with an absolute `IOTDB_HOME`, independently of the relative-path issue.
Use `cd -P -- "$1"` before `pwd -P` and cover a symlink followed by `..` in
the regression cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]