Skip to content
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

Save prev commit seq if progress is done #91

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading