Stabilize async Lucene index test by removing shared temp-root deletion#444
Conversation
Greptile SummaryThis PR fixes an intermittent
Confidence Score: 5/5Safe to merge — the change is a minimal, targeted removal of a shared-path deletion that was the root cause of the reported race condition. The only code removed is the recursive deletion of the shared base directory; per-test GUID scoping and per-test cleanup in the finally block are untouched. Directory.CreateDirectory is idempotent and safe to call from concurrent test runners, so the fix directly addresses the race. No production code is affected. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant T1 as Test Run 1 (inMemory:false)
participant T2 as Test Run 2 (inMemory:false)
participant FS as Filesystem (/tmp/ExamineTests)
Note over T1,T2: BEFORE (race condition)
T1->>FS: Directory.Delete(tempBasePath, true)
T2->>FS: Directory.Delete(tempBasePath, true)
T1->>FS: CreateDirectory(GUID-1)
T2->>FS: CreateDirectory(GUID-2)
T1->>FS: FSDirectory.Open(GUID-1) — may fail if T2 deleted base
Note over T1,T2: AFTER (race resolved)
T1->>FS: Directory.CreateDirectory(tempBasePath)
T2->>FS: Directory.CreateDirectory(tempBasePath)
T1->>FS: CreateDirectory(GUID-1)
T2->>FS: CreateDirectory(GUID-2)
T1->>FS: FSDirectory.Open(GUID-1) — safe, base always exists
T2->>FS: FSDirectory.Open(GUID-2) — safe, base always exists
T1->>FS: finally: temp.Delete(GUID-1, true)
T2->>FS: finally: temp.Delete(GUID-2, true)
Reviews (1): Last reviewed commit: "test: avoid deleting shared temp root in..." | Re-trigger Greptile |
The
buildGitHub Actions job was failing due to an intermittent test race inLuceneIndexTests. A filesystem-backed async index test could delete a shared temp root while another run was still writing Lucene segment files, causingDirectoryNotFoundException.Problem scope
Index_Read_And_Write_Ensure_No_Errors_In_Async(..., inMemory: false)when usingFSDirectoryunder/tmp/ExamineTests.Code change
/tmp/ExamineTests) from test setup.Why this resolves the failure