Skip to content

Commit fa09332

Browse files
committed
fix(cli/toolchain): remove stale locks after 5 minutes to prevent CI matrix cache deadlocks
1 parent 6f5d642 commit fa09332

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cli/toob-cli/internal/toolchain/manager.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,16 @@ func downloadAndExtract(url, destDir, expectedSha256, expectedVersion string) er
187187
defer os.Remove(lockPath)
188188
break
189189
}
190+
191+
// Stale lock detection (e.g. if the previous downloading process crashed/timed out)
192+
if stat, statErr := os.Stat(lockPath); statErr == nil {
193+
if time.Since(stat.ModTime()) > 5*time.Minute {
194+
ui.Warn("Lock file for %s is older than 5 minutes. Assuming previous process crashed. Removing stale lock...", tcName)
195+
os.Remove(lockPath)
196+
continue
197+
}
198+
}
199+
190200
ui.Warn("Waiting for another process to finish downloading %s...", tcName)
191201
time.Sleep(2 * time.Second)
192202
}

0 commit comments

Comments
 (0)