fix: OTA 업데이트 시 ETXTBSY (Text file busy) 회피#1
Merged
Conversation
다운로드 임시 경로를 /tmp(별도 fs)에서 INSTALL_DIR(..new)로
이동해 같은 파일시스템 내 mv가 rename(2)로 동작하도록 변경.
rename(2)은 실행 중 ELF에 대해서도 atomic 치환이 보장되므로
Restart=always 서비스에서 stop과 systemd 재시작 사이의 레이스로
'cp: Text file busy' 가 나던 문제 해결.
- TMP_BINARY: /tmp/... → ${INSTALL_DIR}/.${BINARY_NAME}.new
- cp + mv .old 패턴 → mv -f (atomic rename) 한 번으로 교체
- 서비스명 상수화 (SERVICE_NAME)
- mv 실패 시 명시적 에러 분기 추가
scripts/update.sh(cluster), scripts/entertainment-update.sh 동일 패치.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
문제
/opt/{cluster,entertainment}/update.sh실행 시 다음 에러로 업데이트 실패:원인
TMP_BINARY=/tmp/...— tmpfs(/tmp)와 rootfs(/opt)는 다른 파일시스템.mv $OLD $OLD.old후cp $TMP $TARGET.cp는 destination을O_WRONLY로 열기 때문에 실행 중 ELF에 대해ETXTBSY.entertainment-kiosk.service의Restart=always+RestartSec=3때문에systemctl stop직후 3초 내 재시작되어cp와 레이스 발생.해결
${INSTALL_DIR}/.${BINARY_NAME}.new)에 받음.cp+mv .old대신mv -f한 번으로 atomic 교체.mv=rename(2)시스템콜.rename(2)은 실행 중 ELF에 대해서도ETXTBSY없이 inode 포인터를 교체. 실행 중인 프로세스는 unlinked 된 옛 inode를 그대로 사용하다 종료 후 systemd가 새 바이너리로 재시작.SERVICE_NAME)로 가독성 개선.mv실패 시 명시적 에러 분기 추가.영향 범위
scripts/update.sh(Cluster Pi)scripts/entertainment-update.sh(Entertainment Pi)두 스크립트가 동일한 버그를 갖고 있어 함께 패치.
수동 검증
bash -n문법 통과.mv트릭(수동 핫스왑)으로 v0.0.13 적용 성공 확인.후속
이 PR 머지 후
v0.0.14태그 푸시 →release.yml자동 릴리스.