Skip to content

Commit

Permalink
fix data manually
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Nov 11, 2024
1 parent f7463de commit e095354
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
4 changes: 0 additions & 4 deletions app/versiondb.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ func (app *App) setupVersionDB(
}

// see: https://github.com/crypto-org-chain/cronos/issues/1683
if err := versionDB.FixData(exposeStoreKeys); err != nil {
return nil, err
}

versionDB.SetSkipVersionZero(true)

service := versiondb.NewStreamingService(versionDB, exposeStoreKeys)
Expand Down
1 change: 1 addition & 0 deletions versiondb/client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func ChangeSetGroupCmd(opts Options) *cobra.Command {
ChangeSetToVersionDBCmd(),
RestoreAppDBCmd(opts),
RestoreVersionDBCmd(),
FixDataCmd(opts.DefaultStores),
)
return cmd
}
29 changes: 29 additions & 0 deletions versiondb/client/fixdata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package client

import (
"github.com/crypto-org-chain/cronos/versiondb/tsrocksdb"
"github.com/spf13/cobra"
)

func FixDataCmd(stores []string) *cobra.Command {
cmd := &cobra.Command{
Use: "fixdata",
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]
versionDB, err := tsrocksdb.NewStore(dir)
if err != nil {
return err
}

// see: https://github.com/crypto-org-chain/cronos/issues/1683
if err := versionDB.FixData(stores); err != nil {
return err
}

return nil
},
}
return cmd
}
6 changes: 3 additions & 3 deletions versiondb/tsrocksdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ func (s Store) Flush() error {
// FixData fixes wrong data written in versiondb due to rocksdb upgrade, the operation is idempotent.
// see: https://github.com/crypto-org-chain/cronos/issues/1683
// call this before `SetSkipVersionZero(true)`.
func (s Store) FixData(storeKeys []types.StoreKey) error {
for _, storeKey := range storeKeys {
if err := s.fixDataStore(storeKey.Name()); err != nil {
func (s Store) FixData(storeNames []string) error {
for _, storeName := range storeNames {
if err := s.fixDataStore(storeName); err != nil {
return err
}
}
Expand Down

0 comments on commit e095354

Please sign in to comment.