Skip to content

fix: if target table exists then replace ,else rename by default #633

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
18 changes: 15 additions & 3 deletions pkg/ccr/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -1314,12 +1314,24 @@ func (j *Job) fullSync() error {

// check table exists to ensure the idempotent
if exist, err := j.IDest.CheckTableExistsByName(alias); err != nil {
log.Warnf("the tmp swap table %s is not exists return ", alias)
return err
} else if exist {
log.Infof("fullsync swap table with alias, table: %s, alias: %s", targetName, alias)
swap := false // drop the old table
if err := j.IDest.ReplaceTable(alias, targetName, swap); err != nil {
return err
if target_exist, err2 := j.IDest.CheckTableExistsByName(targetName); err2 != nil {
log.Warnf("the dest table %s is check exists error ", targetName)
} else if target_exist {
log.Warnf("the dest table %s already exists, start replace",
targetName)
swap := false // drop the old table
if err := j.IDest.ReplaceTable(alias, targetName, swap); err != nil {
return err
}
} else {
log.Warnf("the dest table %s is not exists, start rename", targetName)
if err := j.IDest.RenameTableWithName(alias, targetName); err != nil {
return err
}
}
} else {
log.Infof("fullsync the table alias has been swapped, table: %s, alias: %s", targetName, alias)
Expand Down
Loading