From 3612ba0e0f6dbe4fa7b9aff05b13fcd5088d5bb2 Mon Sep 17 00:00:00 2001 From: Ewan Chou Date: Tue, 22 Nov 2016 17:54:24 +0800 Subject: [PATCH] binlog: add sequence to binlog.TableMutation (#2060) Add sequence in binlog.TableMutation to preserve the original mutation order. --- .../pingcap/tipb/go-binlog/binlog.pb.go | 159 ++++++++++++++---- glide.lock | 6 +- glide.yaml | 2 +- sessionctx/binloginfo/binloginfo_test.go | 17 ++ table/tables/tables.go | 5 + 5 files changed, 150 insertions(+), 39 deletions(-) diff --git a/_vendor/src/github.com/pingcap/tipb/go-binlog/binlog.pb.go b/_vendor/src/github.com/pingcap/tipb/go-binlog/binlog.pb.go index 9aaac9e36c650..f48638d550008 100644 --- a/_vendor/src/github.com/pingcap/tipb/go-binlog/binlog.pb.go +++ b/_vendor/src/github.com/pingcap/tipb/go-binlog/binlog.pb.go @@ -19,10 +19,10 @@ import ( "fmt" proto "github.com/golang/protobuf/proto" - - math "math" ) +import math "math" + import io "io" // Reference imports to suppress errors if they are not otherwise used. @@ -36,6 +36,49 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +type MutationType int32 + +const ( + MutationType_Insert MutationType = 0 + MutationType_Update MutationType = 1 + MutationType_DeleteID MutationType = 2 + MutationType_DeletePK MutationType = 3 + MutationType_DeleteRow MutationType = 4 +) + +var MutationType_name = map[int32]string{ + 0: "Insert", + 1: "Update", + 2: "DeleteID", + 3: "DeletePK", + 4: "DeleteRow", +} +var MutationType_value = map[string]int32{ + "Insert": 0, + "Update": 1, + "DeleteID": 2, + "DeletePK": 3, + "DeleteRow": 4, +} + +func (x MutationType) Enum() *MutationType { + p := new(MutationType) + *p = x + return p +} +func (x MutationType) String() string { + return proto.EnumName(MutationType_name, int32(x)) +} +func (x *MutationType) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(MutationType_value, data, "MutationType") + if err != nil { + return err + } + *x = MutationType(value) + return nil +} +func (MutationType) EnumDescriptor() ([]byte, []int) { return fileDescriptorBinlog, []int{0} } + type BinlogType int32 const ( @@ -77,7 +120,7 @@ func (x *BinlogType) UnmarshalJSON(data []byte) error { *x = BinlogType(value) return nil } -func (BinlogType) EnumDescriptor() ([]byte, []int) { return fileDescriptorBinlog, []int{0} } +func (BinlogType) EnumDescriptor() ([]byte, []int) { return fileDescriptorBinlog, []int{1} } // TableMutation contains mutations in a table. type TableMutation struct { @@ -90,8 +133,10 @@ type TableMutation struct { // If the table has PK but PK is not handle, we save the PK of the deleted row. DeletedPks [][]byte `protobuf:"bytes,5,rep,name=deleted_pks,json=deletedPks" json:"deleted_pks,omitempty"` // If the table doesn't have PK, we save the row value of the deleted row. - DeletedRows [][]byte `protobuf:"bytes,6,rep,name=deleted_rows,json=deletedRows" json:"deleted_rows,omitempty"` - XXX_unrecognized []byte `json:"-"` + DeletedRows [][]byte `protobuf:"bytes,6,rep,name=deleted_rows,json=deletedRows" json:"deleted_rows,omitempty"` + // Used to apply table mutations in original sequence. + Sequence []MutationType `protobuf:"varint,7,rep,name=sequence,enum=binlog.MutationType" json:"sequence,omitempty"` + XXX_unrecognized []byte `json:"-"` } func (m *TableMutation) Reset() { *m = TableMutation{} } @@ -141,6 +186,13 @@ func (m *TableMutation) GetDeletedRows() [][]byte { return nil } +func (m *TableMutation) GetSequence() []MutationType { + if m != nil { + return m.Sequence + } + return nil +} + type PrewriteValue struct { SchemaVersion int64 `protobuf:"varint,1,opt,name=schema_version,json=schemaVersion" json:"schema_version"` Mutations []TableMutation `protobuf:"bytes,2,rep,name=mutations" json:"mutations"` @@ -249,6 +301,7 @@ func init() { proto.RegisterType((*TableMutation)(nil), "binlog.TableMutation") proto.RegisterType((*PrewriteValue)(nil), "binlog.PrewriteValue") proto.RegisterType((*Binlog)(nil), "binlog.Binlog") + proto.RegisterEnum("binlog.MutationType", MutationType_name, MutationType_value) proto.RegisterEnum("binlog.BinlogType", BinlogType_name, BinlogType_value) } func (m *TableMutation) Marshal() (data []byte, err error) { @@ -308,6 +361,13 @@ func (m *TableMutation) MarshalTo(data []byte) (int, error) { i += copy(data[i:], b) } } + if len(m.Sequence) > 0 { + for _, num := range m.Sequence { + data[i] = 0x38 + i++ + i = encodeVarintBinlog(data, i, uint64(num)) + } + } if m.XXX_unrecognized != nil { i += copy(data[i:], m.XXX_unrecognized) } @@ -461,6 +521,11 @@ func (m *TableMutation) Size() (n int) { n += 1 + l + sovBinlog(uint64(l)) } } + if len(m.Sequence) > 0 { + for _, e := range m.Sequence { + n += 1 + sovBinlog(uint64(e)) + } + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -705,6 +770,26 @@ func (m *TableMutation) Unmarshal(data []byte) error { m.DeletedRows = append(m.DeletedRows, make([]byte, postIndex-iNdEx)) copy(m.DeletedRows[len(m.DeletedRows)-1], data[iNdEx:postIndex]) iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + var v MutationType + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBinlog + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + v |= (MutationType(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Sequence = append(m.Sequence, v) default: iNdEx = preIndex skippy, err := skipBinlog(data[iNdEx:]) @@ -1156,34 +1241,38 @@ var ( func init() { proto.RegisterFile("binlog.proto", fileDescriptorBinlog) } var fileDescriptorBinlog = []byte{ - // 451 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x54, 0x92, 0xdf, 0x8a, 0xd3, 0x40, - 0x14, 0x87, 0x9b, 0xa6, 0xf6, 0xcf, 0x69, 0x52, 0xc2, 0xa0, 0x50, 0x14, 0xb6, 0x6b, 0x45, 0x28, - 0x0a, 0x2b, 0xec, 0x9d, 0xb7, 0x75, 0x6f, 0xaa, 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, 0xf5, 0x36, 0x6a, 0x63, 0x45, 0x7b, 0x57, 0x57, 0x9f, 0x23, 0x9f, 0x0c, - 0xa1, 0xb7, 0xe4, 0x52, 0xe1, 0xa6, 0x33, 0x8f, 0xee, 0xfe, 0x9d, 0x79, 0xbf, 0xf4, 0xfa, 0xab, - 0xd7, 0xcf, 0xff, 0x67, 0xad, 0xfb, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd8, 0xb3, 0x6c, 0x58, 0xea, - 0x02, 0x00, 0x00, + // 517 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x54, 0x92, 0xcd, 0x6e, 0x9b, 0x40, + 0x14, 0x85, 0x03, 0x38, 0xfe, 0xb9, 0x06, 0x0b, 0x8d, 0x52, 0x09, 0xb5, 0x92, 0x4d, 0x5d, 0x55, + 0x42, 0xa9, 0x94, 0x56, 0xde, 0x75, 0xeb, 0x7a, 0x43, 0xd3, 0x48, 0x04, 0xb9, 0xd9, 0x22, 0xf0, + 0x8c, 0x5c, 0x6a, 0xcc, 0x10, 0x66, 0x08, 0xf2, 0xb2, 0x4f, 0xd0, 0x6d, 0x1f, 0x29, 0xcb, 0x3e, + 0x41, 0x55, 0xb9, 0x2f, 0x52, 0xcd, 0x0c, 0xf8, 0x67, 0xc7, 0x3d, 0xf7, 0x9b, 0x7b, 0x98, 0x73, + 0x07, 0xcc, 0x24, 0xcd, 0x33, 0xba, 0xbe, 0x29, 0x4a, 0xca, 0x29, 0xea, 0xaa, 0xea, 0xe5, 0xd5, + 0x9a, 0xae, 0xa9, 0x94, 0xde, 0x8b, 0x2f, 0xd5, 0x9d, 0xfe, 0xd4, 0xc1, 0x5a, 0xc6, 0x49, 0x46, + 0xee, 0x2a, 0x1e, 0xf3, 0x94, 0xe6, 0x68, 0x02, 0x7d, 0x2e, 0x84, 0x28, 0xc5, 0x8e, 0xe6, 0x6a, + 0x9e, 0x31, 0xef, 0x3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ee, 0xc7, 0xda, 0xaf, 0x7f, 0xe3, 0x8b, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa8, 0xad, 0x69, + 0x76, 0x6f, 0x03, 0x00, 0x00, } diff --git a/glide.lock b/glide.lock index ac31b24418921..2c7844f855e63 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 462634d9fb9a754ffc08ee621dd0d07ab08c80f464b5e984e62a0164a87953e9 -updated: 2016-11-04T19:10:28.344048224+08:00 +hash: dfa58f0d029ce6c5c1c888aa0b84212ebbb99456eca7589da5aaa00cf453af90 +updated: 2016-11-22T16:23:03.852130993+08:00 imports: - name: bitbucket.org/ww/goautoneg version: 75cd24fc2f2c2a2088577d12123ddee5f54e0675 @@ -119,7 +119,7 @@ imports: - pkg/metrics - pkg/rpcutil - name: github.com/pingcap/tipb - version: 38084aeaf922fb5d41284865d64b2113f3ae5f1c + version: 17699c2d5e3b549d85eec896afd9d4f87879b0eb subpackages: - go-binlog - go-tipb diff --git a/glide.yaml b/glide.yaml index 05056ca290bb4..6b129bac35dac 100644 --- a/glide.yaml +++ b/glide.yaml @@ -142,7 +142,7 @@ import: - package: github.com/pingcap/pd version: 447b500dc50e6a5f5cf46abf3bacaf67abb718c1 - package: github.com/pingcap/tipb - version: 38084aeaf922fb5d41284865d64b2113f3ae5f1c + version: 17699c2d5e3b549d85eec896afd9d4f87879b0eb subpackages: - go-binlog - go-tipb diff --git a/sessionctx/binloginfo/binloginfo_test.go b/sessionctx/binloginfo/binloginfo_test.go index b070ca8ddffbf..ea4f38c43b081 100644 --- a/sessionctx/binloginfo/binloginfo_test.go +++ b/sessionctx/binloginfo/binloginfo_test.go @@ -145,6 +145,7 @@ func (s *testBinlogSuite) TestBinlog(c *C) { tk.MustExec("insert local_binlog2 values ('abc', 16), ('def', 18)") tk.MustExec("delete from local_binlog2 where name = 'def'") prewriteVal = getLatestBinlogPrewriteValue(c, pump) + c.Assert(prewriteVal.Mutations[0].Sequence[0], Equals, binlog.MutationType_DeletePK) _, deletedPK, _ := codec.DecodeOne(prewriteVal.Mutations[0].DeletedPks[0]) c.Assert(deletedPK.GetString(), Equals, "def") @@ -161,12 +162,28 @@ func (s *testBinlogSuite) TestBinlog(c *C) { tk.MustExec("delete from local_binlog3 where c1 = 3 and c2 = 3") prewriteVal = getLatestBinlogPrewriteValue(c, pump) + c.Assert(prewriteVal.Mutations[0].Sequence[0], Equals, binlog.MutationType_DeleteRow) gotRows = mutationRowsToRows(c, prewriteVal.Mutations[0].DeletedRows, 1, 3) expected = [][]types.Datum{ {types.NewIntDatum(3), types.NewIntDatum(3)}, } c.Assert(gotRows, DeepEquals, expected) + // Test Mutation Sequence. + tk.MustExec("create table local_binlog4 (c1 int primary key, c2 int)") + tk.MustExec("insert local_binlog4 values (1, 1), (2, 2), (3, 2)") + tk.MustExec("begin") + tk.MustExec("delete from local_binlog4 where c1 = 1") + tk.MustExec("insert local_binlog4 values (1, 1)") + tk.MustExec("update local_binlog4 set c2 = 3 where c1 = 3") + tk.MustExec("commit") + prewriteVal = getLatestBinlogPrewriteValue(c, pump) + c.Assert(prewriteVal.Mutations[0].Sequence, DeepEquals, []binlog.MutationType{ + binlog.MutationType_DeleteID, + binlog.MutationType_Insert, + binlog.MutationType_Update, + }) + checkBinlogCount(c, pump) pump.mu.Lock() diff --git a/table/tables/tables.go b/table/tables/tables.go index 43dcb0ef94e93..b36ba853087e9 100644 --- a/table/tables/tables.go +++ b/table/tables/tables.go @@ -368,6 +368,7 @@ func (t *Table) AddRecord(ctx context.Context, r []types.Datum) (recordID int64, handleVal, _ := codec.EncodeValue(nil, types.NewIntDatum(recordID)) bin := append(handleVal, value...) mutation.InsertedRows = append(mutation.InsertedRows, bin) + mutation.Sequence = append(mutation.Sequence, binlog.MutationType_Insert) } variable.GetSessionVars(ctx).AddAffectedRows(1) return recordID, nil @@ -547,6 +548,7 @@ func (t *Table) addUpdateBinlog(ctx context.Context, h int64, old []types.Datum, bin = append(oldData, newValue...) } mutation.UpdatedRows = append(mutation.UpdatedRows, bin) + mutation.Sequence = append(mutation.Sequence, binlog.MutationType_Update) return nil } @@ -554,6 +556,7 @@ func (t *Table) addDeleteBinlog(ctx context.Context, h int64, r []types.Datum) e mutation := t.getMutation(ctx) if t.meta.PKIsHandle { mutation.DeletedIds = append(mutation.DeletedIds, h) + mutation.Sequence = append(mutation.Sequence, binlog.MutationType_DeleteID) return nil } @@ -576,6 +579,7 @@ func (t *Table) addDeleteBinlog(ctx context.Context, h int64, r []types.Datum) e return errors.Trace(err) } mutation.DeletedPks = append(mutation.DeletedPks, data) + mutation.Sequence = append(mutation.Sequence, binlog.MutationType_DeletePK) return nil } colIDs := make([]int64, len(t.Cols())) @@ -587,6 +591,7 @@ func (t *Table) addDeleteBinlog(ctx context.Context, h int64, r []types.Datum) e return errors.Trace(err) } mutation.DeletedRows = append(mutation.DeletedRows, data) + mutation.Sequence = append(mutation.Sequence, binlog.MutationType_DeleteRow) return nil }