Skip to content

Commit

Permalink
Add no dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
yzang2019 committed Aug 10, 2024
1 parent 6e0b75c commit c350de5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/cmd/seidb/operations/replay_changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func ReplayChangelogCmd() *cobra.Command {
dumpDbCmd.PersistentFlags().StringP("db-dir", "d", "", "Database Directory")
dumpDbCmd.PersistentFlags().Int64P("start-offset", "s", 0, "From offset")
dumpDbCmd.PersistentFlags().Int64P("end-offset", "e", 1, "End offset")
dumpDbCmd.PersistentFlags().Bool("dry-run", true, "Whether to dry run or re-apply the changelog to DB")
dumpDbCmd.PersistentFlags().Bool("no-dry-run", false, "Whether to dry run or re-apply the changelog to DB")

return dumpDbCmd
}
Expand All @@ -34,7 +34,7 @@ func executeReplayChangelog(cmd *cobra.Command, _ []string) {
dbDir, _ := cmd.Flags().GetString("db-dir")
start, _ := cmd.Flags().GetInt64("start-offset")
end, _ := cmd.Flags().GetInt64("end-offset")
dryRun, _ := cmd.Flags().GetBool("dry-run")
noDryRun, _ := cmd.Flags().GetBool("no-dry-run")
if dbDir == "" {
panic("Must provide database dir")
}
Expand All @@ -49,7 +49,7 @@ func executeReplayChangelog(cmd *cobra.Command, _ []string) {
}

// open the database if apply is true
if !dryRun {
if noDryRun {
ssConfig := config.DefaultStateStoreConfig()
ssConfig.KeepRecent = 0
ssConfig.DBDirectory = dbDir
Expand Down Expand Up @@ -80,6 +80,7 @@ func processChangelogEntry(index uint64, entry proto.ChangelogEntry) error {
fmt.Printf("store: %s, key: %X\n", storeName, kv.Key)
}
if ssStore != nil {
fmt.Printf("Re-applied changeset for height %d\n", entry.Version)
err := ssStore.ApplyChangeset(entry.Version, changeset)
if err != nil {
return err
Expand Down

0 comments on commit c350de5

Please sign in to comment.