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

Split ApplyPruningPointProof to multiple small database transactions #1937

Conversation

stasatdaglabs
Copy link
Collaborator

This fixes #1920

ApplyPruningPointProof is always called on the Staging Consensus during IBD, so there's no risk of data inconsistency.
This PR splits the writes from this function to the database to multiple small transactions, so that the garbage collector has a chance to clean up while data is being written
Note that it's still a big, quick write, so RAM consumption isn't reduced to zero. On my VM I've watched it consume up to 1gb additional memory throughout the process

@codecov
Copy link

codecov bot commented Jan 30, 2022

Codecov Report

Merging #1937 (8ee456b) into dev (b1229f7) will decrease coverage by 0.02%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1937      +/-   ##
==========================================
- Coverage   61.26%   61.24%   -0.03%     
==========================================
  Files         651      651              
  Lines       31114    31112       -2     
==========================================
- Hits        19063    19055       -8     
- Misses       9276     9277       +1     
- Partials     2775     2780       +5     
Impacted Files Coverage Δ
...ocesses/pruningproofmanager/pruningproofmanager.go 57.53% <71.42%> (+0.03%) ⬆️
domain/consensus/consensus.go 69.43% <100.00%> (+0.41%) ⬆️
infrastructure/network/rpcclient/rpc_get_info.go 45.45% <0.00%> (-18.19%) ⬇️
infrastructure/network/rpcclient/rpcclient.go 60.67% <0.00%> (-6.75%) ⬇️
infrastructure/network/netadapter/router/route.go 82.85% <0.00%> (-5.72%) ⬇️
...ructure/network/rpcclient/grpcclient/grpcclient.go 76.56% <0.00%> (-4.69%) ⬇️
...selectedchainstore/headers_selected_chain_store.go 75.58% <0.00%> (+3.48%) ⬆️
...ain/consensus/database/binaryserialization/hash.go 78.26% <0.00%> (+8.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1229f7...8ee456b. Read the comment docs.

@@ -607,13 +608,15 @@ func (ppm *pruningProofManager) dagProcesses(
return reachabilityManagers, dagTopologyManagers, ghostdagManagers
}

func (ppm *pruningProofManager) ApplyPruningPointProof(stagingArea *model.StagingArea, pruningPointProof *externalapi.PruningPointProof) error {
func (ppm *pruningProofManager) ApplyPruningPointProof(pruningPointProof *externalapi.PruningPointProof) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment that this function is not atomic and if it fails the outside scope should probably delete the database?

@someone235 someone235 merged commit 27ba9d0 into kaspanet:dev Feb 6, 2022
someone235 added a commit that referenced this pull request Feb 18, 2022
* Make kaspawallet store the utxos sorted by amount, so that the bigger utxos are spent first - making it less likely a compound will be required

* Start refactor addEntryToUTXOSet

* Add GetUTXOsByBalances command to rpc

* Store list of addresses, updated with the collectAddresses methods
(replacing collectUTXOs methods)

* Fix wrong commands in GetBalanceByAddress

* Rename: refreshExistingUTXOs -> refreshUTXOs

* Display progress of IBD process in Kaspad logs (#1938)

* Report progress percentage when downloading headers in IBD.

* Extract reporting logic to a separate type.

* Report progress for IBD missing block bodies.

* Split ApplyPruningPointProof to multiple small database transactions (#1937)

* Split ApplyPruningPointProof to multiple small database transactions.

* Increase the timeout duration in TestIBDWithPruning.

* Increase the timeout duration in simple-sync.

* Explain that if ApplyPruningPointProof fails, the database must be discarded.

* Increase headers proof timeout and add more progress logs (#1939)

* Increase timeout for pruning proof and add some logs

* Show resolving virtual progress as whole percents

* Add AllowConnectionToDifferentVersions flag to kaspactl (#1940)

* Remove duplicate median time calculation on tx validation (#1943)

Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>

* Drop support for p2p v3 (#1942)

* Drop support for p2p v3

* Remove redundant aliases

* Remove redundant condition

* In profile dump file - use a time format supporting all file systems (#1945)

* Use a time format without ":" to support all file systems

* go fmt

* Bump version to v0.11.12 (#1941)

Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>

Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
Co-authored-by: Ori Newman <orinewman1@gmail.com>
Co-authored-by: Michael Sutton <mikisiton2@gmail.com>
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.

2 participants