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

Why DBImpl::Write not call signal when it release the lock ? #1186

Open
sunbohong opened this issue Apr 29, 2024 · 1 comment
Open

Why DBImpl::Write not call signal when it release the lock ? #1186

sunbohong opened this issue Apr 29, 2024 · 1 comment

Comments

@sunbohong
Copy link

sunbohong commented Apr 29, 2024

image

这里没有释放signal,会导致 write 持续处于 Wait 状态

@ghemawat

d79762e#diff-6fdb755f590d9b01ecb89bd8ceb28577e85536d4472f8e4fc3addeb9a65f3645R1115-R1135

@sunbohong sunbohong changed the title Why DBImpl::Write signal when it release the lock ? Why DBImpl::Write not call signal when it release the lock ? Apr 29, 2024
@TalpsG
Copy link

TalpsG commented Jun 5, 2024

并发写会先将把writebatch封装成writer放入写队列,如果此时该writer不是队列的头,就证明前面有写操作正在写,自己先wait下,释放锁。如果是队列的头,则合并部分队列前面的writer到新的writebatch中,并且记录合并过的最后一个writer,last_writer,这个就是BuildBatchGroup的作用。然后写日志和memtable.都写完后将队列前面参与合并过writer 状态都设置为done,表示这个writer完成了,之后才进行signal。
其实就是writebatch也是批量去做的,一次写将队列前几个写请求合并,一起操作,合并时要锁队列防止新增写请求。合并完就能继续添加写请求了,当写日志和memtable完成就标记合并过得writer为done,并唤醒他们,他们done了就直接返回了

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