Repository navigation
fix(knowledge): retry the staged model promotion through transient Windows locks - #79
Merged
1 commit merged intoNov 19, 2026
Merged
1 commit merged into
1 commit merged into
Conversation
…ndows locks A fully downloaded model is promoted by renaming .staging/<model> into the final cache immediately after the release ack. On Windows the rename reliably fails with EPERM even though every process handle is closed: antivirus or the search indexer still holds the freshly written weights for a moment. The download then surfaces as failed even though the staging directory is complete, and the next attempt re-downloads everything. Retry the promotion rename (rm final + rename) on EPERM/EACCES/EBUSY/ ENOTEMPTY with a ~10s backoff budget; any other error propagates immediately and the staging directory stays intact for a clean retry. Verified live on Windows 11: bge-small-zh-v1.5 promotion now succeeds where 0.5.4 failed deterministically on both C: and D: caches.
5e13845
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.
Fixes #78
问题
模型下载完成后,
.staging/<model>提升为最终缓存的 rename 在 Windows 上稳定失败EPERM(详见 issue):即使 release ack 已返回、进程句柄已释放,Defender/搜索索引器对刚落盘权重仍有短暂扫描锁,而提升路径没有任何重试,扫描窗口内的失败直接作为“下载失败”上抛。修复
loadLocalModel()的提升步骤改为promoteDownload():rm(finalPath)+rename(staging → final)作为一个单元重试;EPERM / EACCES / EBUSY / ENOTEMPTY重试,退避[100, 250, 500, 1000, 1000, 2000, 2000, 3000](总量约 10s);不杀 worker、不改变现有“先校验后提升”的原子性:rename 仍是单步原子操作,重试只是重复尝试。
测试
tests/local-worker-lifecycle.spec.ts新增两例(partial mocknode:fs/promises的rename):EPERM后第三次提升成功,最终缓存就位、staging 清空、状态ready;ENOENT)不消耗重试预算直接上抛,staging 完整保留。tool-contract.spec.ts环境性失败(链接的 DSH 检出 era 不匹配,未修改主干上同样 15 failed)外,其余全部通过,无回归。实机验证(Windows 11,DSH Desktop 0.2.2-rc.1)
0.5.4 在本机 4/4 确定性失败(两个模型 × C/D 两盘)。同环境安装本分支构建后删除缓存重下
Xenova/bge-small-zh-v1.5:下载 19%→100%,提升成功,状态ready/loaded,向量检索(hybrid)恢复正常。