Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于数据竞争的问题 #1

Open
Lecarus opened this issue Jan 10, 2024 · 9 comments
Open

关于数据竞争的问题 #1

Lecarus opened this issue Jan 10, 2024 · 9 comments

Comments

@Lecarus
Copy link

Lecarus commented Jan 10, 2024

作者你好,你的代码在-race下运行的话有很多数据竞争的问题,你试试加上 -race 试试,我试了很多遍都有并发竞争的问题

@ToniXWD
Copy link
Owner

ToniXWD commented Jan 10, 2024

你是2A的测试吧, 2A里面GetState获取状态时没有加锁, 所以-race会报错,
这里是2B改过之后的代码GetState

@ToniXWD ToniXWD closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
@ToniXWD ToniXWD reopened this Jan 10, 2024
@Lecarus
Copy link
Author

Lecarus commented Jan 10, 2024

不,有时候还是会有数据竞争问题存在😂,而且我想问一下可不可以删去muVote 和voteCount这两个字段?直接在发起投票请求的时候新建一个votes变量?这样就不需要到处加锁了😂

@ToniXWD
Copy link
Owner

ToniXWD commented Jan 10, 2024

你能提供下数据竞争的报错信息吗(用2b的分支),
然后新建变量是可行的,不过还是需要同步的手段,比如原子操作和锁,但我考虑到一个节点可能多次投票,如果是新建一个临时变量的话,每次投票都需要初始化临时变量和临时锁,不如直接放结构体里面,这是我个人的理解

@ToniXWD
Copy link
Owner

ToniXWD commented Jan 11, 2024

我自己试了下, 应该是DPrintf打印的时候没有对数据加锁, 小问题

@Lecarus
Copy link
Author

Lecarus commented Jan 16, 2024

数据竞争的问题解决了,但是大佬我用你lab2b的分支做测试,虽然可以通过测试,但是通过不了实验给出的脚本测试(dstest.py),你看😂
image

@Lecarus
Copy link
Author

Lecarus commented Jan 16, 2024

image

@ToniXWD
Copy link
Owner

ToniXWD commented Jan 16, 2024

dstest.py是什么脚本啊? 为什么我没看到实验给了这个东西啊😂话说我们是一个学期的lab吗? 我是2023的

@Lecarus
Copy link
Author

Lecarus commented Jan 17, 2024

啊,我学的是2022年的,课程文档会提供一个测试脚本链接在 Utility for running MIT 6.824 lab test in parallel and saving failed logs
通过这个脚本,我们可以给指定的测试项目指定测试次数,并将每次偶发的失败日志存储下来方便排查问题

@ToniXWD
Copy link
Owner

ToniXWD commented Jan 17, 2024

那应该是学期不匹配吧, 23年的只要过go test就行

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

No branches or pull requests

2 participants