-
Notifications
You must be signed in to change notification settings - Fork 273
Problem: no command to fix corrupted data in versiondb #1685
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
7aa274d
Problem: no command to fix corrupted data in versiondb
966ce20
rename
2c81bca
support SkipVersionZero
9711730
support SkipVersionZero
9711b73
cleanup
fe0b46b
cleanup
3d87d5b
cleanup
f18863a
destroy
2025ac8
fix data manually
ccd3257
Update CHANGELOG.md
8005948
Update versiondb/tsrocksdb/store.go
4e07bb9
cli
1fa9d14
cleanup
9dc36ab
Update versiondb/client/fixdata.go
8d0ba74
rename
5328448
fix test
3fe6f96
check nil
mmsqe cd306a4
don't return nil as empty slice
95d74ce
add dryrun mode
4c66b89
cleanup
2eceb45
separete read from iteration
194772c
store name flag
6528386
validate timestamp
423a12c
skip non-zero version
665bc78
Merge branch 'main' into fix-versiondb
1241c3c
update gomod2nix
7845baf
fix build
f8abc94
flush after fix
ccfc3f5
fix
mmsqe 277a4d7
revert
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package client | ||
|
|
||
| import ( | ||
| "github.com/crypto-org-chain/cronos/versiondb/tsrocksdb" | ||
| "github.com/linxGnu/grocksdb" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| const ( | ||
| FlagDryRun = "dry-run" | ||
| FlagStore = "store-name" | ||
| ) | ||
|
|
||
| func FixDataCmd(defaultStores []string) *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "fixdata <dir>", | ||
| Args: cobra.ExactArgs(1), | ||
| Short: "Fix wrong data in versiondb, see: https://github.com/crypto-org-chain/cronos/issues/1683", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| dir := args[0] | ||
| dryRun, err := cmd.Flags().GetBool(FlagDryRun) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| stores, err := cmd.Flags().GetStringArray(FlagStore) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if len(stores) == 0 { | ||
| stores = defaultStores | ||
| } | ||
|
|
||
| var ( | ||
| db *grocksdb.DB | ||
| cfHandle *grocksdb.ColumnFamilyHandle | ||
| ) | ||
|
|
||
| if dryRun { | ||
| db, cfHandle, err = tsrocksdb.OpenVersionDBForReadOnly(dir, false) | ||
| } else { | ||
| db, cfHandle, err = tsrocksdb.OpenVersionDB(dir) | ||
| } | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
yihuang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| versionDB := tsrocksdb.NewStoreWithDB(db, cfHandle) | ||
| if err := versionDB.FixData(stores, dryRun); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().Bool(FlagDryRun, false, "Dry run, do not write to the database, open the database in read-only mode.") | ||
| cmd.Flags().StringArray(FlagStore, []string{}, "Store names to fix, if not specified, all stores will be fixed.") | ||
| return cmd | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.