Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD committed Nov 29, 2022
1 parent 63dfc31 commit 71a7896
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions dm/relay/binlog_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"path/filepath"
"sync"

"github.com/pingcap/errors"
"github.com/pingcap/tiflow/dm/pkg/log"
"github.com/pingcap/tiflow/dm/pkg/terror"
"go.uber.org/atomic"
Expand Down Expand Up @@ -93,7 +92,7 @@ func (w *BinlogWriter) run() {
}

if w.file == nil {
w.err.CompareAndSwap(nilErr, terror.ErrRelayWriterNotOpened.Delegate(errors.New("file not opened")))
w.err.CompareAndSwap(nilErr, terror.ErrRelayWriterNotOpened.Generate())
errOccurs = true
return
}
Expand Down Expand Up @@ -186,7 +185,7 @@ func (w *BinlogWriter) Close() error {

func (w *BinlogWriter) Write(rawData []byte) error {
if w.file == nil {
return terror.ErrRelayWriterNotOpened.Delegate(errors.New("file not opened"))
return terror.ErrRelayWriterNotOpened.Generate()
}
w.input <- rawData
w.offset.Add(int64(len(rawData)))
Expand Down
2 changes: 1 addition & 1 deletion dm/relay/binlog_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (t *testBinlogWriterSuite) TestWrite() {
// not opened
w := NewBinlogWriter(log.L(), dir)
err := w.Write(data1)
require.Contains(t.T(), err.Error(), "not opened")
require.Contains(t.T(), err.Error(), "no underlying writer opened")

// open non exist dir
err = w.Open("not-exist-uuid", "bin.000001")
Expand Down
2 changes: 1 addition & 1 deletion dm/relay/relay_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (w *FileWriter) handleFormatDescriptionEvent(ev *replication.BinlogEvent) (
}
err = w.Flush()
if err != nil {
return WResult{}, terror.Annotatef(err, "write binlog file header for %s", fullName)
return WResult{}, terror.Annotatef(err, "flush binlog file for %s", fullName)
}
}

Expand Down
2 changes: 1 addition & 1 deletion dm/relay/relay_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (t *testFileWriterSuite) TestRotateEventWithFormatDescriptionEvent(c *check
defer w1.Close()
w1.Init(uuid, filename)
_, err = w1.WriteEvent(rotateEv)
c.Assert(err, check.ErrorMatches, ".*file not opened.*")
c.Assert(err, check.ErrorMatches, ".*no underlying writer opened")

// 2. fake RotateEvent before FormatDescriptionEvent
relayDir = c.MkDir() // use a new relay directory
Expand Down

0 comments on commit 71a7896

Please sign in to comment.