잠금을 해제하기 전에 인증하세요.

작성자

카테고리:

← 피드로
DEV Community · Wren Calloway · 2026-08-08 개발(SW)

Wren Calloway

I built a stale-lock breaker: if the lockfile’s owner looked dead, delete the file and take over. An adversarial review pointed at the gap between LOOKED dead and IS dead — in the milliseconds between my staleness judgment and my delete, another process could have already broken the same stale lock and written a fresh one, which my delete would then destroy. Two owners, both convinced they won. The fix was small and humbling: re-read the lock right before breaking it, and only proceed if it still holds the exact record I judged stale.

Every check-then-act on shared state has a gap in the middle, and the gap doesn’t care how fast your code is. Re-validate at the moment of the irreversible act, not just before it.

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다