Repository navigation
Conversation
… it is the judged one (AGT-4903) recoverTelemetryLock judged the lock owner and then unlinked the path, so a live lock taken between the judgement and the unlink was deleted. The lock is now renamed aside first; the moved file is deleted only when its token (or, for a malformed lock, its mtime) matches what was judged. Otherwise it is put back with link(), which never overwrites a newer lock.
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.
무엇
src/telemetry/telemetry.ts의 stale lock 회수를reclaimJudgedTelemetryLock으로 바꿨습니다.rename으로*.reclaim-<uuid>에 격리합니다(원자적).link로 되돌립니다.link는 그 사이 다른 프로세스가 잡은 더 새로운 lock을 덮어쓰지 않습니다.recoverTelemetryLock은 stat을 owner 읽기보다 먼저 합니다. 그래서 그 사이에 교체된 lock을 판단한 lock으로 착각하지 않습니다.왜
AGT-4903 (AGT-3443 잔여). 기존 코드는 owner를 읽고 판단한 다음
unlinkSync(TELEMETRY_LOCK)로 경로를 지웠습니다. 판단과 삭제 사이에 다른 프로세스가 lock을 새로 잡으면 그 살아 있는 lock이 지워졌습니다(TOCTOU).AGT-3488 쪽(
src/support/fileLock.ts)의 회수 로직은 모듈 내부 함수이고, namespace 증명이 없으며, "mtime+token 재확인 후 unlink" 방식이라 재확인과 unlink 사이의 창이 그대로 남습니다. 그래서 이슈가 제안한 rename 격리 방식으로 따로 구현했습니다.검증
npx vitest run src/telemetry/→ 4 files, 46 tests 통과(신규 3개 포함).telemetry.lockReclaim.test.ts(liveness stub으로 판단 시점에 경합을 주입):fresh-owner)이 남고 격리 파일도 남지 않습니다.origin/main의 telemetry.ts로 되돌리면 첫 테스트가 실패하는 것을 확인했습니다(mutation check).npm run typecheck통과, oxlint 0 warnings.남는 한계
rename에서 link로 되돌리기까지의 아주 짧은 창에 세 번째 프로세스가 lock을 잡으면, 되돌리기는 EEXIST로 실패하고 원래 holder는 자기 lock을 잃습니다. 그래도 그 holder의 해제는 token을 확인하므로 새 lock을 지우지 않습니다. telemetry 쓰기는
mergeState로 수렴하므로 영향은 제한적입니다.