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

Valnodes forceprune #1262

Merged
merged 9 commits into from
Apr 22, 2022
Merged

Conversation

moniya12
Copy link
Contributor

Closes: #XXX

Description

Add forceprune to CLI (Ability to compact/prune via CLI)

Please review cmd/osmosisd/cmd/forceprune.go

Forceprune provides options to prune blockstore.db and state.db. By default, it would prune blockstore.db and state.db up to 14 days (unbounding period). In state.db while it keeps validator and consensus information up to 14 days it prunes abci responses (keeping only last 1000 blocks abci response).

Forceprune does not touch application.db or indexer.

ABCI Responses are stored in index db and so redundant especially if one is running pruned nodes. As a result we are removing ABCI data from state.db aggressively by default. One can override height for blockstore.db and state.db by using -f option and for abci response by using -m option.

Example osmosisd forceprune -f 188000 -m 1000.


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

Add forceprune to CLI (Ability to compact/prune via CLI)
Forceprune provides options to prune blockstore.db and state.db. By default, it would prune blockstore.db and state.db up to 14 days (unbounding period). In state.db while it keeps validator and consensus information up to 14 days it prunes abci responses (keeping only last 1000 blocks abci response). 
If required, one can override 14 days of blocks. 
Forceprune does not touch application.db or indexer.
Copy link
Member

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

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

Thanks for PR'ing this! It will be really helpful for node operators!

@czarcas7ic tested it on nodes I believe. The PR lgtm once it passes linting. (Most of these should get fixed if you run make format. Any remaining ones will come up in make lint)

@codecov-commenter
Copy link

codecov-commenter commented Apr 16, 2022

Codecov Report

Merging #1262 (8caa057) into main (68f2661) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1262   +/-   ##
=======================================
  Coverage   19.81%   19.81%           
=======================================
  Files         210      210           
  Lines       27884    27884           
=======================================
  Hits         5525     5525           
  Misses      21333    21333           
  Partials     1026     1026           

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 68f2661...8caa057. Read the comment docs.

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

Thank you for this change. I left some comments, please take a look

cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
Copy link
Contributor

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

This is similar to how i setup cosmprund, while it works perfectly fine its super slow, interested to hear your speeds on 100GB+.

My next design was going to create a new db and migrate the blocks over, while more complex you can do it in a fraction of the time.

@faddat
Copy link
Member

faddat commented Apr 18, 2022

moniya12#4

That'll fix ci for this.

I am actually going to test this code right now, here's the scenario:

I have a machine at hetzner where I have been struggling to make a rocksdb image for distribution.

When the state gets too big it slows to the pace of a camel.

I am going to combine this with some of my other recent work and see where it gets us.

@faddat
Copy link
Member

faddat commented Apr 18, 2022

@marbar3778 and @moniya12

I'm trying cosmosprund on rocksdb v7 now, I'll make a draft PR into there. Right now, it does not seem that this supports rocks.

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

@moniya12 Thank you for addressing my comments and questions. I took another look and, mostly, had minor style suggestions.

Currently, my only concern is not having defer db_bs.Close(), please let me know what you think

cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Outdated Show resolved Hide resolved
cmd/osmosisd/cmd/forceprune.go Show resolved Hide resolved
moniya12 and others added 2 commits April 19, 2022 14:45
Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>
Moved to const values, added defer close db
@czarcas7ic
Copy link
Member

This is similar to how i setup cosmprund, while it works perfectly fine its super slow, interested to hear your speeds on 100GB+.

My next design was going to create a new db and migrate the blocks over, while more complex you can do it in a fraction of the time.

I did this on a 106GB image and it completed in ~15 minutes

@ValarDragon ValarDragon added the A:backport/v7.x Do not use. backport patches to v7.x branch label Apr 22, 2022
Copy link
Member

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

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

defer db_bs.Close() is added in the logic! I suggest we merge this in, and then do a second follow-up PR, to make the db openings / closings match the desired idioms a bit more

Thanks for adding this @moniya12 / Valnodes team!

@ValarDragon ValarDragon merged commit 15f131e into osmosis-labs:main Apr 22, 2022
mergify bot pushed a commit that referenced this pull request Apr 22, 2022
* Update root.go

Add forceprune to CLI (Ability to compact/prune via CLI)

* Added Forceprune.go

Forceprune provides options to prune blockstore.db and state.db. By default, it would prune blockstore.db and state.db up to 14 days (unbounding period). In state.db while it keeps validator and consensus information up to 14 days it prunes abci responses (keeping only last 1000 blocks abci response).
If required, one can override 14 days of blocks.
Forceprune does not touch application.db or indexer.

* Added description for Forceprune option

* Update forceprune.go

* Fix db close

* Update cmd/osmosisd/cmd/forceprune.go

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>

* Update forceprune.go

Moved to const values, added defer close db

* Fix lint

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>
Co-authored-by: Dev Ojha <dojha@berkeley.edu>
(cherry picked from commit 15f131e)
ValarDragon pushed a commit that referenced this pull request Apr 22, 2022
Forceprune provides options to prune blockstore.db and state.db. By default, it would prune blockstore.db and state.db up to 14 days (unbounding period). In state.db while it keeps validator and consensus information up to 14 days it prunes abci responses (keeping only last 1000 blocks abci response).
If required, one can override 14 days of blocks.
Forceprune does not touch application.db or indexer.
@czarcas7ic czarcas7ic added the A:backport/v4.x backport patches to v4.x branch label Aug 4, 2022
mergify bot pushed a commit that referenced this pull request Aug 4, 2022
* Update root.go

Add forceprune to CLI (Ability to compact/prune via CLI)

* Added Forceprune.go

Forceprune provides options to prune blockstore.db and state.db. By default, it would prune blockstore.db and state.db up to 14 days (unbounding period). In state.db while it keeps validator and consensus information up to 14 days it prunes abci responses (keeping only last 1000 blocks abci response).
If required, one can override 14 days of blocks.
Forceprune does not touch application.db or indexer.

* Added description for Forceprune option

* Update forceprune.go

* Fix db close

* Update cmd/osmosisd/cmd/forceprune.go

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>

* Update forceprune.go

Moved to const values, added defer close db

* Fix lint

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>
Co-authored-by: Dev Ojha <dojha@berkeley.edu>
(cherry picked from commit 15f131e)
czarcas7ic added a commit that referenced this pull request Aug 5, 2022
* Valnodes forceprune (#1262)

* Update root.go

Add forceprune to CLI (Ability to compact/prune via CLI)

* Added Forceprune.go

Forceprune provides options to prune blockstore.db and state.db. By default, it would prune blockstore.db and state.db up to 14 days (unbounding period). In state.db while it keeps validator and consensus information up to 14 days it prunes abci responses (keeping only last 1000 blocks abci response).
If required, one can override 14 days of blocks.
Forceprune does not touch application.db or indexer.

* Added description for Forceprune option

* Update forceprune.go

* Fix db close

* Update cmd/osmosisd/cmd/forceprune.go

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>

* Update forceprune.go

Moved to const values, added defer close db

* Fix lint

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>
Co-authored-by: Dev Ojha <dojha@berkeley.edu>
(cherry picked from commit 15f131e)

* Update docker.yml

* Update lint.yml

* Update Makefile

* Update lint.yml

* Update Makefile

Co-authored-by: moniya12 <91159097+moniya12@users.noreply.github.com>
Co-authored-by: Adam Tucker <adam@osmosis.team>
@czarcas7ic czarcas7ic added the A:backport/v6.x backport patches to v6.x branch label Aug 5, 2022
mergify bot pushed a commit that referenced this pull request Aug 5, 2022
* Update root.go

Add forceprune to CLI (Ability to compact/prune via CLI)

* Added Forceprune.go

Forceprune provides options to prune blockstore.db and state.db. By default, it would prune blockstore.db and state.db up to 14 days (unbounding period). In state.db while it keeps validator and consensus information up to 14 days it prunes abci responses (keeping only last 1000 blocks abci response).
If required, one can override 14 days of blocks.
Forceprune does not touch application.db or indexer.

* Added description for Forceprune option

* Update forceprune.go

* Fix db close

* Update cmd/osmosisd/cmd/forceprune.go

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>

* Update forceprune.go

Moved to const values, added defer close db

* Fix lint

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>
Co-authored-by: Dev Ojha <dojha@berkeley.edu>
(cherry picked from commit 15f131e)
czarcas7ic pushed a commit that referenced this pull request Aug 5, 2022
* Update root.go

Add forceprune to CLI (Ability to compact/prune via CLI)

* Added Forceprune.go

Forceprune provides options to prune blockstore.db and state.db. By default, it would prune blockstore.db and state.db up to 14 days (unbounding period). In state.db while it keeps validator and consensus information up to 14 days it prunes abci responses (keeping only last 1000 blocks abci response).
If required, one can override 14 days of blocks.
Forceprune does not touch application.db or indexer.

* Added description for Forceprune option

* Update forceprune.go

* Fix db close

* Update cmd/osmosisd/cmd/forceprune.go

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>

* Update forceprune.go

Moved to const values, added defer close db

* Fix lint

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>
Co-authored-by: Dev Ojha <dojha@berkeley.edu>
(cherry picked from commit 15f131e)

Co-authored-by: moniya12 <91159097+moniya12@users.noreply.github.com>
@czarcas7ic czarcas7ic added the A:backport/v3.x backport patches to v3.x branch label Aug 5, 2022
mergify bot pushed a commit that referenced this pull request Aug 5, 2022
* Update root.go

Add forceprune to CLI (Ability to compact/prune via CLI)

* Added Forceprune.go

Forceprune provides options to prune blockstore.db and state.db. By default, it would prune blockstore.db and state.db up to 14 days (unbounding period). In state.db while it keeps validator and consensus information up to 14 days it prunes abci responses (keeping only last 1000 blocks abci response).
If required, one can override 14 days of blocks.
Forceprune does not touch application.db or indexer.

* Added description for Forceprune option

* Update forceprune.go

* Fix db close

* Update cmd/osmosisd/cmd/forceprune.go

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>

* Update forceprune.go

Moved to const values, added defer close db

* Fix lint

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>
Co-authored-by: Dev Ojha <dojha@berkeley.edu>
(cherry picked from commit 15f131e)
czarcas7ic pushed a commit that referenced this pull request Aug 5, 2022
* Update root.go

Add forceprune to CLI (Ability to compact/prune via CLI)

* Added Forceprune.go

Forceprune provides options to prune blockstore.db and state.db. By default, it would prune blockstore.db and state.db up to 14 days (unbounding period). In state.db while it keeps validator and consensus information up to 14 days it prunes abci responses (keeping only last 1000 blocks abci response).
If required, one can override 14 days of blocks.
Forceprune does not touch application.db or indexer.

* Added description for Forceprune option

* Update forceprune.go

* Fix db close

* Update cmd/osmosisd/cmd/forceprune.go

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>

* Update forceprune.go

Moved to const values, added defer close db

* Fix lint

Co-authored-by: Roman <34196718+p0mvn@users.noreply.github.com>
Co-authored-by: Dev Ojha <dojha@berkeley.edu>
(cherry picked from commit 15f131e)

Co-authored-by: moniya12 <91159097+moniya12@users.noreply.github.com>
@github-actions github-actions bot mentioned this pull request May 1, 2024
@github-actions github-actions bot mentioned this pull request May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v3.x backport patches to v3.x branch A:backport/v4.x backport patches to v4.x branch A:backport/v6.x backport patches to v6.x branch A:backport/v7.x Do not use. backport patches to v7.x branch
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants