-
Notifications
You must be signed in to change notification settings - Fork 89
BlockFetch: wait until the block has been written to disk #1850
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
Conversation
Alternatively, we also wait until the block has been processed by chain selection, which means we don't need the first commit. In that case, the use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGreatTM! One minor comment.
@@ -251,18 +252,19 @@ addBlockSync cdb@CDB {..} BlockToAdd { blockToAdd = b, .. } = do | |||
VolDB.putBlock cdbVolDB b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This alternative currently delivers the WrittenToDisk
promise after chain selection, whereas it could deliver it before. Is there a reason to favor one option over the other? "Promptness" of written-to-disk would favor changing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're totally right, I glossed over it. I'll fix it.
@@ -332,7 +333,20 @@ instance DB (ChainDB m blk) where | |||
-------------------------------------------------------------------------------} | |||
|
|||
data AddBlockPromise m blk = AddBlockPromise | |||
{ blockProcessed :: STM m (Point blk) | |||
{ blockWrittenToDisk :: STM m Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other minor comment: you've organized the new promise around "written to disk". Based on the code I'm seeing, it looks like "added to VolDB" would also be accurate. Just pointing that out, in case the less-specific name is appealing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take your point. But IMO "written to disk" is fine.
This allows the caller to wait until the block has been written to disk (but not yet processed by chain selection).
12b442e
to
acea7f8
Compare
@mrBliss Yes, it does what we expected. Basic test use two nodes, trace the BlockFetch client and BlockFetch decision for one node, inspect the output. Here's the diff in that output that I see by applying your fix.
Crucial observation: there are less |
Thanks for verifying it! |
bors r+ |
Fixes #1845.