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

Add explicit read locks #917

Closed
keith-turner opened this issue Sep 5, 2017 · 0 comments
Closed

Add explicit read locks #917

keith-turner opened this issue Sep 5, 2017 · 0 comments
Assignees
Milestone

Comments

@keith-turner
Copy link
Contributor

The percolator paper mentioned that read locks were not implemented because they were usually uneeded and expensive. I agree with this, in most situations you do want to read data without a read lock. However I do find that sometimes I would like a read lock. For example consider a use case with graph type data. An edge is added to Fluo and joined with information from the two nodes it connects. I want multiple edge operations to be able to proceed concurrently, as long as the node information does not change. Conceptually, I would like an edge operation to get a read lock on the two nodes its interacting with. If multiple edge operations concurrently get a read lock on the same node, none of them will collide. However a node operation that got a write lock on the node would cause collisions.

From an API perspective, one possible way to implement this is adding the following :

public interface TransactionBase {
  //return snapshot where reads acquire a read lock
  SnapshotBase withReadLock();
}

This would enable writing code like the following :

try(Transaction tx = fluoClient.newTransaction()) {
  //read w/o read lock
  Bytes val1 = tx.get(row1, col1);
  
  //read data with read lock
  Bytes val2 = tx.withReadLock().get(row2, col2);
    .
    .
    .
  tx.commit(); //will collide if row2+col2 was written OR may cause a concurrent write to row2+col2 to fail
}
@keith-turner keith-turner self-assigned this Sep 12, 2017
keith-turner added a commit to keith-turner/fluo that referenced this issue Oct 23, 2017
keith-turner added a commit to keith-turner/fluo that referenced this issue Oct 23, 2017
@keith-turner keith-turner mentioned this issue Oct 26, 2017
@mikewalch mikewalch added this to the 1.2.0 milestone Jan 11, 2018
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