Skip to content

Commit

Permalink
Save prev commit seq if progress is done (selectdb#91)
Browse files Browse the repository at this point in the history
Fix the bug introduced by selectdb#86.

The prev commit seq is indicates the commit seq where the target
cluster has synced, so once restoring is finished, the prev commit
seq should be set to aligned with commit seq
  • Loading branch information
w41ter authored and lsy3993 committed Jun 7, 2024
1 parent 2cb856c commit a0e57cf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/ccr/job_progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ type JobProgress struct {
// Sub sync state machine states
SubSyncState SubSyncState `json:"sub_sync_state"`

// The commit seq where the target cluster has synced.
PrevCommitSeq int64 `json:"prev_commit_seq"`
CommitSeq int64 `json:"commit_seq"`
TableMapping map[int64]int64 `json:"table_mapping"`
Expand Down Expand Up @@ -264,6 +265,9 @@ func (j *JobProgress) CommitNextSubWithPersist(commitSeq int64, subSyncState Sub
j.Persist()
}

// Switch to new sync state.
//
// The PrevCommitSeq is set to commitSeq, if the sub sync state is done.
func (j *JobProgress) NextWithPersist(commitSeq int64, syncState SyncState, subSyncState SubSyncState, persistData string) {
if subSyncState == BeginCreateSnapshot && (syncState == TableFullSync || syncState == DBFullSync) {
j.FullSyncStartAt = time.Now().Unix()
Expand All @@ -275,6 +279,10 @@ func (j *JobProgress) NextWithPersist(commitSeq int64, syncState SyncState, subS
}

j.CommitSeq = commitSeq
if subSyncState == Done {
j.PrevCommitSeq = commitSeq
}

j.SyncState = syncState
j.SubSyncState = subSyncState
j.PersistData = persistData
Expand Down

0 comments on commit a0e57cf

Please sign in to comment.