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

Đang mở
#1,318 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
73/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
bash, linux, shell
Lĩnh vực
devops, tooling

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C
Star
10
Fork
8
Merge trung bình
6 giờ 32 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của FriendsofECCE/ECCE

Tất cả issue của FriendsofECCE/ECCE

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.