Repository navigation
Conversation
… a file lock (AGT-4902) reportInFlight only guarded one process. Two daemons firing the same cron both read an empty watermark and published every project twice. A run now holds an async file lock next to the watermark from the watermark read to the last write; the second instance waits, reads the first one's record and skips what was published. A lock held past the wait skips the run; a dead holder's lock is reclaimed.
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.
무엇
generateDailyReports한 번의 실행 전체를src/support/fileLock.ts의 비동기withFileLock(~/.openswarm/daily-reporter-watermark.json.lock)으로 감쌌습니다. watermark 읽기부터 마지막 쓰기까지 잠금 안에서 일어나므로, 두 번째 인스턴스는 기다렸다가 첫 번째가 남긴 기록을 읽고 이미 발행한 프로젝트를 건너뜁니다(완료된 날이면 통째로 skip).withFileLock의 기존 dead-pid 회수로 처리됩니다.왜
AGT-4902 (AGT-3443 잔여).
reportInFlight는 한 프로세스 안만 막습니다. 같은 cron 시각에 데몬 두 개가 돌면 둘 다 빈 watermark를 읽고 같은 프로젝트 상태 업데이트를 두 번 올렸습니다.이슈는
runnerState.ts의withFileLockSync/withRunnerStateLock재사용을 제안했지만, 둘 다 동기 작업만 감쌀 수 있어서 네트워크 호출을 포함하는 실행에는 맞지 않습니다. 같은 소유권 규칙을 쓰는 비동기 짝인withFileLock을 썼습니다.검증
npx vitest run src/automation/dailyReporter→ 4 files, 10 tests 통과(기존 7 + 신규 3).dailyReporter.lock.test.ts: (1) 별도 모듈 인스턴스 두 개를 동시에 돌려도 프로젝트당 발행 1회이고 watermark가 complete, (2) 살아 있는 소유자가 잠금을 쥐고 있으면 발행 없이 skip하고 그 잠금을 건드리지 않음, (3) 죽은 pid의 잠금은 회수하고 발행.npm run typecheck통과, oxlint 0 warnings.알려진 한계
withFileLock의 stale 판정은kill(pid, 0)만 쓰고 namespace 증명이 없습니다(withRunnerStateLock과 다름). 컨테이너 안의 데몬이~/.openswarm을 호스트 데몬과 공유하면, 다른 pid namespace의 살아 있는 잠금을 죽은 것으로 보고 회수할 수 있습니다. 같은 namespace에서 도는 일반 배치에서는 해당하지 않습니다.