Skip to content

Commit

Permalink
Add the commit ts in the exec ddl failed log (#992)
Browse files Browse the repository at this point in the history
* Add the commit ts in the exec ddl failed log

* comment flash test
  • Loading branch information
july2993 authored Aug 3, 2020
1 parent fb0cc0d commit 09a8cfd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions drainer/sync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
package sync

import (
"fmt"

"github.com/pingcap/tidb-binlog/drainer/translator"
pb "github.com/pingcap/tipb/go-binlog"
)
Expand All @@ -34,6 +36,10 @@ type Item struct {
ShouldSkip bool
}

func (i *Item) String() string {
return fmt.Sprintf("commit ts: %v", i.Binlog.CommitTs)
}

// Syncer sync binlog item to downstream
type Syncer interface {
// Sync the binlog item to downstream
Expand Down
2 changes: 1 addition & 1 deletion drainer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ ForLoop:
lastAddComitTS = binlog.GetCommitTs()
err = s.dsyncer.Sync(&dsync.Item{Binlog: binlog, PrewriteValue: preWrite})
if err != nil {
err = errors.Annotatef(err, "add to dsyncer, commit ts %d", binlog.CommitTs)
err = errors.Annotatef(err, "failed to add item")
break ForLoop
}
executeHistogram.Observe(time.Since(beginTime).Seconds())
Expand Down
7 changes: 6 additions & 1 deletion pkg/loader/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,6 @@ func (b *batchManager) execAccumulatedDMLs() (err error) {
func (b *batchManager) execDDL(txn *Txn) error {
if err := b.fExecDDL(txn.DDL); err != nil {
if !pkgsql.IgnoreDDLError(err) {
log.Error("exec failed", zap.String("sql", txn.DDL.SQL), zap.Error(err))
return errors.Trace(err)
}
log.Warn("ignore ddl", zap.Error(err), zap.String("ddl", txn.DDL.SQL))
Expand All @@ -769,6 +768,12 @@ func (b *batchManager) put(txn *Txn) error {
return errors.Trace(err)
}
if err := b.execDDL(txn); err != nil {
meta := zap.Skip()
if s, ok := txn.Metadata.(fmt.Stringer); txn.Metadata != nil && ok {
meta = zap.Stringer("metadata", s)
}

log.Error("exec failed", zap.String("sql", txn.DDL.SQL), meta, zap.Error(err))
return errors.Trace(err)
}
return nil
Expand Down
4 changes: 3 additions & 1 deletion tests/filter/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ run_sql "CREATE TABLE test.do_not_name(id int);"
run_sql "CREATE TABLE test.do_ignore_name(id int);"

# Test this DDL about tiflash will not abort the replication.
run_sql "ALTER TABLE test.do_start1 SET TIFLASH REPLICA 3 LOCATION LABELS \"rack\", \"host\", \"abc\"";
# ERROR 1105 (HY000) at line 1: the tiflash replica count: 3 should be less than the total tiflash server count: 0
# need to setup tiflash now
# run_sql "ALTER TABLE test.do_start1 SET TIFLASH REPLICA 3 LOCATION LABELS \"rack\", \"host\", \"abc\"";

run_sql "INSERT INTO test.do_start1(id) VALUES (1);"
run_sql "INSERT INTO test.do_name(id) VALUES (1);"
Expand Down

0 comments on commit 09a8cfd

Please sign in to comment.