Skip to content

Keep a file index walk's end and its result in one state - #514

Merged
yansfil merged 1 commit into
mainfrom
fix/flaky-473
Oct 5, 2026
Merged

yansfil merged 1 commit into
mainfrom
fix/flaky-473

Conversation

@yansfil

@yansfil yansfil commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Refs #473

Summary

⌘P 파일 index가 실패한 walk를 한 번 답한 직후의 질의에서 새 walk를 시작하지 않고 Indexing만 답할 수 있던 경쟁을 없앱니다.

  • 원인: hided/src/index.rs의 entry는 결과(data)와 진행 중 표시(building)를 따로 들고 있었습니다. walk thread는 결과를 먼저 쓰고, guard가 drop될 때 building을 내렸습니다. 그 사이에 온 질의는 실패를 답하고 결과를 비웠고, 다음 질의는 결과가 비었지만 building이 아직 켜져 있어 walk를 시작하지 않은 채 Indexing을 답했습니다. test에서는 그 다음 poll이 다른 walk(빈 목록)를 시작해 entries == ["a.txt"]가 실패합니다(242행, CI Linux 2회).
  • 근거: 결과를 쓴 뒤 guard drop 전에 30 ms sleep을 임시로 넣으면 같은 단언이 매번 실패합니다. 수정 뒤에는 같은 자리에 sleep을 넣어도 30/30 통과합니다(임시 sleep은 커밋하지 않음).
  • 수정: entry 상태를 한 lock 아래의 하나의 상태(Empty, Walking, Walked, Failed)로 바꿨습니다. walk의 끝과 결과는 한 번의 변경입니다. walk가 panic하거나 thread가 시작되지 못하면 Walk guard가 Empty로 되돌려, 다음 질의가 다시 walk합니다.
  • 새 test a_walk_that_panics_leaves_the_index_to_walk_again: 다시 쓴 panic 경로를 지킵니다.

Review

  • 조심해서 볼 파일: hided/src/index.rs - Walk guard는 finish로 결과를 쓰면 disarm되고, 끝나지 못한 경우에만 Empty로 되돌립니다. 다른 walk가 시작된 뒤 앞선 guard가 새 walk의 상태를 지우는 일이 없도록 한 구조입니다.
  • 순위 계산(rank)은 이전처럼 lock 밖에서 합니다(Arc<Walked>만 복사).

Evidence

  • 확인한 것: 수정 전 경쟁 창을 넓힌 build에서 실패 재현, 수정 후 같은 조건 30/30 통과. 수정 후 index test를 CPU 부하(yes 14개) 아래 400회 반복해 실패 0. 수정 전 같은 조건 400회도 실패 0이라, 좁은 창은 로컬에서 재현되지 않았고 넓힌 창으로 원인을 확인했습니다.
  • 확인한 것: hided lib test 181 통과, scripts/verify-cargo.sh lint 통과.

@yansfil
yansfil added this pull request to the merge queue Oct 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 5, 2026
@yansfil
yansfil added this pull request to the merge queue Oct 5, 2026
Merged via the queue into main with commit e658575 Oct 5, 2026
28 checks passed
@yansfil
yansfil deleted the fix/flaky-473 branch October 5, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant