-
Notifications
You must be signed in to change notification settings - Fork 33
Fix double allocate of resources in getStateRef
#1702
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
ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2.hs
Outdated
Show resolved
Hide resolved
a98d9d7 to
460b69c
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.
Nice catch! Do you think it makes sense to add some assertions on the registry itself. For example if we don't expect more than 3k items in there, we could provide an assertion in a similar manner we do with NoThunks for detecting thunks.
|
@bladyjoker I think the process of finding that something is retained by the resource registry is "easy" enough to find that something is retained:
Another issue is that the problem is not allocating a new resource but instead that the previous resources still remain, so such an assertion might flag a false positive. It reminds me of limiting the allocation size of the program in the RTS in the hopes that you hit exactly the allocation that goes over the limit, which is a brittle approach. |
ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/DBAnalyser/Analysis.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/DBAnalyser/Analysis.hs
Show resolved
Hide resolved
ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2.hs
Outdated
Show resolved
Hide resolved
|
The problem is not exactly the one you described.
Notice how in option 4 we are missing the The way I solved it was by not allocating again the LedgerTablesHandle in the I think we could solve this by passing around the key that needs to be released upon commit, so that the line instead releases such key. Re-doing this in a more obviously correct way sounds like a good idea, but perhaps we could defer it to a later PR? I actually think this PR could be merged without all the LSM stuff. |
460b69c to
d7635f4
Compare
d7635f4 to
46f4d49
Compare
|
That's how I understood the issue, maybe
was misleading in #1702 (comment); I edited it to
for clarity. Also, the fact that the LSM V2 backend happens to use
FTR that's exactly what I also mentioned in #1702 (comment), see "This would also be the exact place where we would need to close via ResourceKey in the dual approach mentioned above."
That sounds good to me, let's open an issue for the first point 👍 |
46f4d49 to
5ce9b14
Compare
|
The issue for simplifying this handling: #1704 |
5ce9b14 to
13dbc27
Compare
ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2/Forker.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2.hs
Outdated
Show resolved
Hide resolved
13dbc27 to
a22bee3
Compare
Description
The
duplicatefunction for LSM trees is already allocating the tables in a resource registry. We were then allocating this resource again in the registry and we would only free this second allocation if we never committed the forker thus not replacingfoeResourcesToRelease. If we replaced it withcloseDiscarded, we would point to thecloseof the tables but forget about the resource allocated bygetStateRefwhich would hold a reference to the tables forever.