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

[Bug]: new function prune panics at v0.47.3 #16855

Closed
RaulBernal opened this issue Jul 6, 2023 · 12 comments · Fixed by #16856
Closed

[Bug]: new function prune panics at v0.47.3 #16855

RaulBernal opened this issue Jul 6, 2023 · 12 comments · Fixed by #16856

Comments

@RaulBernal
Copy link

Summary of Bug

When you try to prune the database with the new function simd prune it panics in an error.

Version

v0.47.3 and other forks that use this release

Steps to Reproduce

Run a chain, stop the daemon/binary, try to prune the database

build/simd prune
panic: could not create directory "": mkdir : no such file or directory

goroutine 1 [running]:
github.com/cometbft/cometbft/config.EnsureRoot({0x0, 0x0})
	github.com/cometbft/[email protected]/config/toml.go:35 +0x1f6
github.com/cosmos/cosmos-sdk/server.interceptConfigs(0xc000d9d1e0, {0x1021f5c7e, 0x2e19}, {0x101eb60e0, 0xc000427440}, 0xc001047080)
	github.com/cosmos/[email protected]/server/util.go:230 +0x354
github.com/cosmos/cosmos-sdk/server.InterceptConfigsPreRunHandler(0x0?, {0x1021f5c7e, 0x2e19}, {0x101eb60e0, 0xc000427440}, 0x0?)
	github.com/cosmos/[email protected]/server/util.go:148 +0x3c5
cosmossdk.io/simapp/simd/cmd.NewRootCmd.func1(0xc000716900, {0x1?, 0x102bbbe80?, 0x1?})
	cosmossdk.io/simapp/simd/cmd/root.go:86 +0x2bb
github.com/cometbft/cometbft/libs/cli.concatCobraCmdFuncs.func1(0xc000716900?, {0x103fa8538, 0x0, 0x0})
	github.com/cometbft/[email protected]/libs/cli/setup.go:118 +0x62
github.com/spf13/cobra.(*Command).execute(0xc000716900, {0x103fa8538, 0x0, 0x0})
	github.com/spf13/[email protected]/command.go:891 +0x739
github.com/spf13/cobra.(*Command).ExecuteC(0xc0018c3200)
	github.com/spf13/[email protected]/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/[email protected]/command.go:968
github.com/spf13/cobra.(*Command).ExecuteContext(...)
	github.com/spf13/[email protected]/command.go:961
github.com/cosmos/cosmos-sdk/server/cmd.Execute(0x101bcc9d0?, {0x0, 0x0}, {0xc000b1ff08, 0x13})
	github.com/cosmos/[email protected]/server/cmd/execute.go:32 +0x179
main.main()
	cosmossdk.io/simapp/simd/main.go:14 +0x30

Checked in other forks:

Same here:
EmpowerPlastic/empowerchain#988

image

@julienrbrt
Copy link
Member

Right, the UX isn't so great for this command, some flags are necessary.
The home flag could be gotten from the app and other flags should possibly be positional arguments.

@RaulBernal
Copy link
Author

RaulBernal commented Jul 6, 2023

Right, the UX isn't so great for this command, some flags are necessary. The home flag could be gotten from the app and other flags should possibly be positional arguments.

works:

bcnad prune everything --home /Users/raul/.bcna  
get pruning options from command flags, strategy: 0, keep-recent: 362880
no heights to prune

I will test with more blocks ofc

@RaulBernal
Copy link
Author

RaulBernal commented Jul 6, 2023

Testing with Circulus-1 testnet: (pruning = "default")

$ du -hs .empowerchain/data
129G	.empowerchain/data

$ sudo service empowerd stop

$ empowerd prune everything  --home $HOME/.empowerchain/
get pruning options from command flags, strategy: 0, keep-recent: 362880
pruning heights start from 1, end at 196926
successfully pruned the application root multi stores

$ du -hs .empowerchain/data
124G	.empowerchain/data

Should the "prune everything" keep-recent less than 362889 (default in app.conf) @julienrbrt ?

@julienrbrt
Copy link
Member

julienrbrt commented Jul 6, 2023

This commands takes no argument, so it should be empowerd prune --home $HOME/.empowerchain/ --pruning everything. The UX is a bit weird, I feel like a vararg for pruning would make more sense.

@RaulBernal
Copy link
Author

Checking the --help flag it gets you more info; it works fine, is an UX issue, very agreed:
prune --home './' --app-db-backend 'goleveldb' --pruning 'custom' --pruning-keep-recent 100

Doing the test again with real data is works amazingly fine :) (but GB reduction is not awesome)

$ sudo service empowerd stop

$ du -hs .empowerchain/data
124G	.empowerchain/data

$ empowerd prune --home $HOME/.empowerchain/ --pruning everything
get pruning options from command flags, strategy: 1, keep-recent: 2
pruning heights start from 1, end at 560281
Killed

$ du -hs .empowerchain/data
du: cannot access '.empowerchain/data/application.db/73680854.ldb': No such file or directory
du: cannot access '.empowerchain/data/application.db/73680855.ldb': No such file or directory
du: cannot access '.empowerchain/data/application.db/73686428.ldb': No such file or directory
124G	.empowerchain/data

@RaulBernal
Copy link
Author

BTW @julienrbrt I tried again the last command and also get a "Killed" with a no pruning action.
the size of the data folder was 124G and store was untouched. Maybe it gets too much memory or so.
image
Certainly, is a memory usage issue. I'll try in other powerful server

@RaulBernal
Copy link
Author

Hello @julienrbrt
I tried the fix at Cosmos-SDK v0.46.14 and didn't works:

bcnad prune custom --pruning-keep-recent 100 --pruning-interval 10 
panic: could not create directory "": mkdir : no such file or directory

goroutine 1 [running]:
github.com/tendermint/tendermint/config.EnsureRoot({0x0, 0x0})
        /Users/raul/go/pkg/mod/github.com/cometbft/cometbft@v0.34.29/config/toml.go:35 +0x1f6
github.com/cosmos/cosmos-sdk/server.interceptConfigs(0xc001647860, {0x101efcd6c, 0x2b7c}, {0x101c141e0, 0xc0014dfd40}, 0xc001678000)
        /Users/raul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.46.14/server/util.go:208 +0x354
github.com/cosmos/cosmos-sdk/server.InterceptConfigsPreRunHandler(0x0?, {0x101efcd6c, 0x2b7c}, {0x101c141e0, 0xc0014dfd40}, 0x0?)
        /Users/raul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.46.14/server/util.go:141 +0x3c5
github.com/BitCannaGlobal/bcna/cmd/bcnad/cmd.NewRootCmd.func1(0xc00155e300, {0x1?, 0x102b189c8?, 0x1?})
        /Users/raul/SDK/v0.46/bcna/cmd/bcnad/cmd/root.go:73 +0x2d9
github.com/tendermint/tendermint/libs/cli.concatCobraCmdFuncs.func1(0xc00155e300?, {0xc000701130, 0x1, 0x5})
        /Users/raul/go/pkg/mod/github.com/cometbft/cometbft@v0.34.29/libs/cli/setup.go:118 +0x62
github.com/spf13/cobra.(*Command).execute(0xc00155e300, {0xc0007010e0, 0x5, 0x5})
        /Users/raul/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:891 +0x739
github.com/spf13/cobra.(*Command).ExecuteC(0xc0014b1500)
        /Users/raul/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/raul/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        /Users/raul/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:961
github.com/cosmos/cosmos-sdk/server/cmd.Execute(0x1019450b0?, {0x101e0d580, 0x5}, {0xc000713b48, 0x11})
        /Users/raul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.46.14/server/cmd/execute.go:36 +0x20f
main.main()
        /Users/raul/SDK/v0.46/bcna/cmd/bcnad/main.go:14 +0x38

@julienrbrt
Copy link
Member

Have you used the new command?

@RaulBernal
Copy link
Author

Have you used the new command?
bcnad prune custom --pruning-keep-recent 100 --pruning-interval 10

My last post show the command and the output. It works with --homeflag ofc but I think it was fixed.
Anyway I want to feedback with my experience using the new prune command.

It takes 36 minutes to prune a database where was set to "nothing" as pruning strategy. This was the order of the commands:

  1. check the current space before the pruning:
$ du -hs .bcna/data
114G	.bcna/data 
  1. Stops and run the prune command:
$ bcnad prune custom --pruning-keep-recent 100 --pruning-interval 10  --home $HOME/.bcna
get pruning options from command flags, strategy: 3, keep-recent: 100
pruning heights start from 1, end at 9636439
successfully pruned the application root multi stores
  1. Check the space again. It pruned 4GB and takes 36 minutes in a high specs dedicated server.
du -hs $HOME/.bcna/data
110G	/home/band/.bcna/data

@RaulBernal
Copy link
Author

I've not tested yet at v0.47.4 but with v0.46.14 the flag --home is still necessary

@julienrbrt
Copy link
Member

julienrbrt commented Jul 28, 2023

I've not tested yet at v0.47.4 but with v0.46.14 the flag --home is still necessary

Yes, this is why I said the new prune command, for having no CLI breaking change in a patch release, PruningCmd still behaves the same, there is a new one that has a better UX. Check the changelog -> https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/CHANGELOG.md#improvements :)

@RaulBernal
Copy link
Author

I've not tested yet at v0.47.4 but with v0.46.14 the flag --home is still necessary

Yes, this is why I said the new prune command, for having no CLI breaking change in a patch release, PruningCmd still behaves the same, there is a new one that has a better UX. Check the changelog -> https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/CHANGELOG.md#improvements :)

Got it ;)
I replace the "old" call with pruning.Cmd(a.newApp, app.DefaultNodeHome),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants