-
Notifications
You must be signed in to change notification settings - Fork 27
LedgerDB.V2: make sure to actually close handles #1516
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
base: main
Are you sure you want to change the base?
Conversation
closeDiscarded = do | ||
closePruned | ||
-- Do /not/ close the anchor of @toClose@, as that is also the | ||
-- tip of @olddb'@ which will be used in @newdb@. | ||
case toClose of | ||
AS.Empty _ -> pure () | ||
_ AS.:< closeOld' -> closeLedgerSeq (LedgerSeq closeOld') | ||
-- Finally, close the anchor of @lseq@ (which is a duplicate of | ||
-- the head of @olddb'@). | ||
close $ tables $ AS.anchor lseq |
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 think this is correct, but it is rather non-obvious.
It would be "nicer" if newdb
would use the anchor state of lseq
instead of the head state of olddb'
(but we would need a special purpose AS.join
for this as this isn't possible in general when the anchor is "strictly smaller" than the element type). In that case, we could simply write
closeDiscarded = closePruned *> closeLedgerSeq (LedgerSeq closeOld)
instead of what I have here.
8da1177
to
0dcd9c5
Compare
0dcd9c5
to
981971e
Compare
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.
Very nice catch, Alex. The fix looks very reasonable.
For tracking whether we are leaking any handles, in a test to be added in a follow-up commit
for testing that we do not leak any, in a follow-up commit
981971e
to
0c5b137
Compare
Closes #1515
The first three commits add a regression test by enrichting the existing LedgerDB state machine test, making sure that
The fourth commit then fixes the bug, causing the regression test to succeed.
Note that this bug fix reveals another bug (causing the
mock-test
failure forLeaderSchedule.simple convergence
), which is in turn fixed by #1513.