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

[FlexiDag]Add read-write lock in dag db store #4101

Merged
merged 4 commits into from
May 22, 2024

Conversation

jackzhhuang
Copy link
Collaborator

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Other information

header.id(),
ghostdata.selected_parent,
&mut merge_set,
) {
);
drop(reachability_writer);
Copy link
Collaborator

@nkysg nkysg May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we don't need this drop. Please see this https://amanieu.github.io/parking_lot/parking_lot/struct.RwLock.html

Does not require any drop glue when dropped.
this is a demo from the above link.

use parking_lot::RwLock;

let lock = RwLock::new(5);

// many reader locks can be held at once
{
    let r1 = lock.read();
    let r2 = lock.read();
    assert_eq!(*r1, 5);
    assert_eq!(*r2, 5);
} // read locks are dropped at this point

// only one write lock may be held, however
{
    let mut w = lock.write();
    *w += 1;
    assert_eq!(*w, 6);
} // write lock is dropped here


self.storage
.relations_store
.write()
.insert(real_origin, BlockHashes::new(vec![]))?;
// self.storage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment code?

@@ -179,7 +258,7 @@ fn test_dag_genesis_fork() {
let _ghostdata = dag.ghostdata_by_hash(header.id()).unwrap().unwrap();
}

// fork, produce a new dag gensis
// // fork, produce a new dag gensis
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra // ?

@nkysg nkysg linked an issue May 22, 2024 that may be closed by this pull request
@nkysg nkysg self-requested a review May 22, 2024 02:33
@jackzhhuang jackzhhuang merged commit 72ca5ab into dag-master May 22, 2024
3 of 5 checks passed
@jackzhhuang jackzhhuang deleted the dag-master-db-reentrance branch May 22, 2024 04:59
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.

[Bug Report]The commit operation in Flexidag should support reentrance.
3 participants