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

an issue about sema of Segment #4

Open
erician opened this issue Jul 30, 2019 · 0 comments
Open

an issue about sema of Segment #4

erician opened this issue Jul 30, 2019 · 0 comments

Comments

@erician
Copy link

erician commented Jul 30, 2019

In my opinion, you want to implement rwlock with sema, which is a data member of Segment, but there is something wrong with it. Consider this situation: the first thread (T1) goes to C1(showed in bellow codes) and sleeps, and the second thread(T2) splits the same segment with INPLACE mode and changes the pattern. When T1 wakes up, it inserts the key-value into that segment, but, this key-value may not belong to that segment since the pattern may be not right, and it will be treated as invalid record and removed, which is an issue.

int Segment::Insert(Key_t& key, Value_t value, size_t loc, size_t key_hash) {
#ifdef INPLACE
  if (sema == -1) return 2;
  if ((key_hash >> (8*sizeof(key_hash)-local_depth)) != pattern) return 2;
  auto lock = sema;                                       #C1
  int ret = 1;
  while (!CAS(&sema, &lock, lock+1)) {
    lock = sema;
  }
.....
@erician erician changed the title the issue about sema of Segment an issue about sema of Segment Jul 30, 2019
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

1 participant