Repository navigation
Conversation
TestImageGatesSurviveDirectorySwapAndRecovery/install 偶发报 sdk\emulator\emulator.exe「找不到路径」。等待条件先看 sdk\emulator、 再看 previous,两眼之间正好赶上 swapIn 的第一次改名(sdk\emulator 改到 previous)时,会看到旧的 sdk\emulator 和新出现的 previous, 以为换好了,其实第二次改名还没做,sdk\emulator 不在。 改成先看 previous 再看 sdk\emulator:previous 一直留到 finishInstall(被测试拿着的 mas-avd.json.lock 挡住),在它之后看到的 sdk\emulator 只能是第二次改名放上去的。产品代码不动。 Refs ModAVD/ModAVD#403
Collaborator
总体结论:可以合并以下仅供参考 先看到旧目录确实挪到了备份位置,再认新目录到位,这两眼就不会把换包前后的状态拼错了。关键是测试还在拿着元数据锁,等两份程序都在时,照样要求它们因共享限制而起不来,解锁后再确认新版能启动。没有把「找不到程序」也算通过,这处改法 dot酱认。 dot酱敬上 |
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.
Windows CI 上
TestImageGatesSurviveDirectorySwapAndRecovery/install偶发失败(合并队列里出过一次,最近 60 次运行里只这一次),报sdk\emulator\emulator.exe「找不到路径」(ModAVD/ModAVD#403)。查下来是测试的等待条件有竞态,产品代码没问题;这个 PR 只改测试。原因
swapIn(internal/update/swap.go)换 SDK 是两次目录改名,中间记一次状态:sdk\emulator→.update\previous\emulator(这时sdk\emulator不在)stepOldMoved.update\stage\emulator→sdk\emulator(两个目录都在)finishInstall先recordHistory写 mas-avd.json(要mas-avd.json.lock,测试拿着,最多等 10 秒),然后才tidyUp把 previous 挪走。所以 previous 出现以后,
sdk\emulator只会「不在 → 在」,测试放开锁之前不会再变;两个目录都在之后sdk\emulator不会再消失。测试原来的等待条件是
!isDir(emulator) || !isDir(previous):先看sdk\emulator、再看 previous,两次看之间隔着一点时间。第一眼看到的是第 1 步之前的旧sdk\emulator,第二眼恰好在第 1 步之后看到新出现的 previous,就以为换好了,接着去启动sdk\emulator\emulator.exe,这时第 3 步还没做,目录不在,fork/exec报ERROR_PATH_NOT_FOUND,和 CI 日志一字不差。recover子项开始时就已经是「sdk\emulator不在、previous 在」,碰不上这个竞态,所以只有install出过。产品这边:第 1、3 步之间
sdk\emulator确实短暂不在,这是两次改名换目录本来就有的(和 AUTO-MAS 的 swap_in 一样,Windows 没有原子交换目录);这段时间swapIn拿着所有实例的启动锁,ModAVD 自己的开机都在等,不算问题。改法
等待条件改成先看 previous、再看
sdk\emulator(!isDir(previous) || !isDir(emulator)),加了注释。看到 previous 在以后再看到的sdk\emulator,只能是第 3 步放上去的新目录。没有加 sleep,同步点仍是测试拿着的mas-avd.json.lock。测试
在 Windows 11 本机(
internal/update目录下跑编好的测试程序,都在临时目录里):-test.run=^TestImageGatesSurviveDirectorySwapAndRecovery$ -test.count=200,-test.cpu1、2、4 各一轮(共 1200 个子项):install失败 5 次(cpu 1 两次、cpu 2 三次、cpu 4 零次),报错和 CI 一字不差;recover0 次。cpu 1、2 两轮跑的时候本机同时在跑别的测试,有负载swapIn两次改名之间临时加 200 ms,并在测试两眼之间临时加 100 ms:-test.count=1010 次全失败,报错和 CI 一样(images_windows_test.go:193: image start was not blocked by sharing: ...\sdk\emulator\emulator.exe: ... The system cannot find the path specified.)-test.count=10全过(install、recover都过)-test.count=200,-test.cpu1、2、4 各一轮:全过(1200 个子项 0 失败);cpu 1 那轮同时在跑go test ./internal/update/...,负载和改前差不多go vet ./...:通过go test ./internal/update/...:跑了两次,第二次通过(ok modavd/internal/update 71.6s);第一次挂在TestInstallBlocksRawAndSharedSDKStarts/renamed_PE(改名sdk\emulator时「拒绝访问」)。这条在本机单独跑时几乎每次都这样挂,改前的 main 上一样,和这个 PR 无关,另外跟进Refs ModAVD/ModAVD#403