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

fix a lock contention issue #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix a lock contention issue #10

wants to merge 1 commit into from

Conversation

kedebug
Copy link

@kedebug kedebug commented Dec 16, 2013

考虑一种极端的并发情况:

  1. 假设当前根结点是 x,线程 a, b 同时写入数据
  2. a 此时持有 x 的 write_lock() 准备分裂操作,b 此时持有 x 的 read_lock() 等待 a 线程完成操作写入
  3. 极端情况考虑,此时缓冲树增高,产生新的根节点 y,但是 b 将要 write 的 msg 成为 y 的右子树部分(即新分裂的部分)
  4. b 终于得到 read_lock() 准备写操作,但是得到的是 x 的读权限,并非新的根节点 y
    可想而知,会有bug产生。我对代码进行简单的修改,可以在不损失效率的情况下,避免这种竞态环境下的错误。

@BohuTANG
Copy link

@kedebug
Root节点的分裂是很重要的!

cascaDB在Lock上也在改进,计划:
所有的lock不应该直接加在Node上,外面需要个Container,所有的lock和unlock统一交给cache来管理。
当对Root进行split的时候,其他线程会一直在Container上进行spin,root nid要保持不变。

这样就不会出现你描述的情况了。
严格避免Lock下的Data Race和Dead Lock问题,应该是我们接下来的一个重点。
Thanx.

@kedebug
Copy link
Author

kedebug commented Dec 16, 2013

@shuttler 很高兴能得到您的回复,并且也非常期待cascadb能在这方面做出改进。

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

Successfully merging this pull request may close these issues.

2 participants