Skip to content

Commit

Permalink
fix: currentRecords may be nil (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
dk-lockdown committed Jun 15, 2022
1 parent b455766 commit e7c8747
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/dt/mysql_undo_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,18 @@ func (executor MysqlUndoExecutor) dataValidationAndGoOn(tx proto.Tx) (bool, erro
log.Info("Stop RollbackLocal because there is no data change between the before data snapshot and the after data snapshot.")
return false, nil
} else {
oldRows, _ := json.Marshal(executor.sqlUndoLog.AfterImage.Rows)
newRows, _ := json.Marshal(currentRecords.Rows)
var (
oldRows, newRows []byte
err error
)
if oldRows, err = json.Marshal(executor.sqlUndoLog.AfterImage.Rows); err != nil {
return false, err
}
if currentRecords != nil {
if newRows, err = json.Marshal(currentRecords.Rows); err != nil {
return false, err
}
}
log.Errorf("check dirty datas failed, old and new data are not equal, tableName:[%s], oldRows:[%s], newRows:[%s].",
executor.sqlUndoLog.TableName, string(oldRows), string(newRows))
return false, errors.New("Has dirty records when undo.")
Expand Down

0 comments on commit e7c8747

Please sign in to comment.