Skip to content

Commit

Permalink
Bug fix: a DDL p-binlog will be ignored when the c-binlog queried fro…
Browse files Browse the repository at this point in the history
  • Loading branch information
leoppro authored and july2993 committed Dec 20, 2019
1 parent a7b869c commit c7dfc87
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pump/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,9 @@ func (a *Append) feedPreWriteValue(cbinlog *pb.Binlog) error {

cbinlog.StartTs = pbinlog.StartTs
cbinlog.PrewriteValue = pbinlog.PrewriteValue
cbinlog.DdlQuery = pbinlog.DdlQuery
cbinlog.DdlJobId = pbinlog.DdlJobId
cbinlog.DdlSchemaState = pbinlog.DdlSchemaState

return nil
}
Expand Down
38 changes: 38 additions & 0 deletions pump/storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,44 @@ func (as *AppendSuit) TestWriteCBinlog(c *check.C) {
c.Assert(cBinlog.Tp, check.Equals, pb.BinlogType_Commit)
}

func (as *AppendSuit) TestFeedPreWriteValue(c *check.C) {
a := newAppend(c)
defer cleanAppend(a)

expectPBinlog := &pb.Binlog{
Tp: pb.BinlogType_Prewrite,
StartTs: 42,
PrewriteKey: []byte("PrewriteKey"),
PrewriteValue: []byte("PrewriteValue"),
DdlQuery: []byte("create table t(a int);"),
DdlJobId: 6,
DdlSchemaState: 5,
}

req := a.writeBinlog(expectPBinlog)
c.Assert(req.err, check.IsNil)

cBinlog := &pb.Binlog{
Tp: pb.BinlogType_Commit,
StartTs: 42,
CommitTs: 50,
}
req = a.writeBinlog(cBinlog)
c.Assert(req.err, check.IsNil)

err := a.feedPreWriteValue(cBinlog)
c.Assert(err, check.IsNil)

c.Assert(cBinlog.StartTs, check.Equals, expectPBinlog.StartTs)
c.Assert(cBinlog.CommitTs, check.Equals, int64(50))
c.Assert(cBinlog.Tp, check.Equals, pb.BinlogType_Commit)
c.Assert(cBinlog.PrewriteKey, check.IsNil)
c.Assert(cBinlog.PrewriteValue, check.BytesEquals, expectPBinlog.PrewriteValue)
c.Assert(cBinlog.DdlQuery, check.BytesEquals, expectPBinlog.DdlQuery)
c.Assert(cBinlog.DdlJobId, check.Equals, expectPBinlog.DdlJobId)
c.Assert(cBinlog.DdlSchemaState, check.Equals, expectPBinlog.DdlSchemaState)
}

type OpenDBSuit struct {
dir string
}
Expand Down

0 comments on commit c7dfc87

Please sign in to comment.