Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yzang2019 committed Aug 19, 2024
1 parent 24c632a commit 64d6abe
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tools/cmd/seidb/operations/replay_changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func ReplayChangelogCmd() *cobra.Command {
}

dumpDbCmd.PersistentFlags().StringP("db-dir", "d", "", "Database Directory")
dumpDbCmd.PersistentFlags().Int64P("start-offset", "s", 1, "From offset")
dumpDbCmd.PersistentFlags().Int64P("start-offset", "s", 0, "From offset")
dumpDbCmd.PersistentFlags().Int64P("end-offset", "e", 0, "End offset, default is latest")
dumpDbCmd.PersistentFlags().Bool("no-dry-run", false, "Whether to dry run or re-apply the changelog to DB")

Expand All @@ -45,6 +45,16 @@ func executeReplayChangelog(cmd *cobra.Command, _ []string) {
if err != nil {
panic(err)
}

// use first available offset
if start <= 0 {
startOffset, err := stream.FirstOffset()
if err != nil {
panic(err)
}
start = startOffset
}

if end <= 0 {
// use latest offset
endOffset, err := stream.LastOffset()
Expand Down

0 comments on commit 64d6abe

Please sign in to comment.