Stale broker_<key>.d directories accumulate in .ECCE: the reaper's rm -f cannot remove them (Windows)

未關閉
#1,318 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
73/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
bash, linux, shell
領域
devops, tooling

研究方向

Start with packaging/gateway/ecce-gateway-reap around lines 152–157 and read how live_broker is built in ecce-session-lib.sh around lines 54–58; compare those paths with the directory created by packaging/windows/ecce-broker-win. Check the reaper’s callers in ecce-gateway-start and the wrappers’ EXIT trap. Done when reaping preserves both paths for a live session and removes an old inactive .d directory without rm errors.

由索引模型根據 Issue 內容生成。

描述

bug

Observed: repeated test runs on a Windows test machine leave broker_* entries behind
in the user's .ECCE state directory; nothing removes them and they accumulate across
runs.

Mechanism, from the code. On Windows the session broker is started by
packaging/windows/ecce-broker-win, which creates two things under
$ECCE_REALUSERHOME/.ECCE (ecce-broker-win:26-30):

BROKERFILE="$(ecce_broker_file)"      # .../broker_<host>_<id>        (a file)
KEY="$(ecce_session_key)"
DIR="$STATEDIR/broker_$KEY.d"         # .../broker_<host>_<id>.d      (a DIRECTORY)
PIDFILE="$DIR/mosquitto.pid"

Both are removed by stop() (ecce-broker-win:36-47, rm -rf "$DIR" "$BROKERFILE"),
which runs from ecce-broker-win stop or from the watch loop once the session's
windows are gone. A run that is killed, crashes, or ends without those paths running
leaves both behind.

The sweeper that is supposed to catch that is packaging/gateway/ecce-gateway-reap
(called from ecce-gateway-start:154-156 and from the wrappers' EXIT trap),
lines 152-157:

broker_prefix="$STATEDIR/broker_$(ecce_session_prefix)"
for f in "$broker_prefix"*; do
  [ -e "$f" ] || continue
  case " $live_broker " in *" $f "*) continue ;; esac
  [ -n "$(find "$f" -mmin +1 2>/dev/null)" ] && rm -f "$f"
done

Two problems with the .d directory:

  1. The glob broker_<host>_* matches broker_<host>_<id>.d as well as the file, but
    $live_broker is built from ecce_broker_file (ecce-session-lib.sh:54-58), which
    yields only the plain broker_<host>_<id> path. The .d directory therefore never
    matches the live list, not even for a session that is currently running.
  2. rm -f does not remove a directory. So the .d directory is attempted on every
    reap, never removed, and the attempt writes a rm: cannot remove ...: Is a directory line to stderr -- including, per (1), for a live session's own directory.

Consequence. ~/.ECCE grows one broker_<host>_<id>.d directory per session that did
not stop cleanly, each holding a mosquitto.pid and a mosquitto log, for the life of
the account. On a machine used for repeated test runs this is unbounded. The stale
pid files are not read by anything outside their own .d, so there is no known
misbehaviour beyond the litter and the stderr noise, but the reaper is the component
that is meant to keep that directory bounded and for this entry it does not.

Suggested fix: include the .d directory in $live_broker (or exclude *.d from the
broker-file loop and sweep it in a loop of its own), and use rm -rf for it. Either
way, the reap must treat broker_<key> and broker_<key>.d as one unit so a live
session's directory is not a sweep candidate.

Not verified on a Windows machine: the sequence above is read from the scripts. It has
not been confirmed that the surviving entries seen after test runs are specifically the
.d directories rather than the broker files, nor measured how many a typical run
leaves.

主要語言
C
星號
10
分支
8
平均合併
6 小時 32 分鐘
30 天內合併 PR
1

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

FriendsofECCE/ECCE 的其他 Issue

查看 FriendsofECCE/ECCE 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。