diff --git a/pkg/lockservice/lock_table_allocator.go b/pkg/lockservice/lock_table_allocator.go index 5ab48eb67486..9cd0913f9acc 100644 --- a/pkg/lockservice/lock_table_allocator.go +++ b/pkg/lockservice/lock_table_allocator.go @@ -88,7 +88,8 @@ func (l *lockTableAllocator) KeepLockTableBind(serviceID string) bool { return b.active() } -func (l *lockTableAllocator) Valid(binds []pb.LockTable) bool { +func (l *lockTableAllocator) Valid(binds []pb.LockTable) []uint64 { + var invalid []uint64 l.mu.RLock() defer l.mu.RUnlock() for _, b := range binds { @@ -103,10 +104,10 @@ func (l *lockTableAllocator) Valid(binds []pb.LockTable) bool { zap.String("current", current.DebugString()), zap.String("received", b.DebugString())) } - return false + invalid = append(invalid, b.Table) } } - return true + return invalid } func (l *lockTableAllocator) Close() error { diff --git a/pkg/lockservice/lock_table_allocator_test.go b/pkg/lockservice/lock_table_allocator_test.go index 47643aa414fb..02faa87c0ff4 100644 --- a/pkg/lockservice/lock_table_allocator_test.go +++ b/pkg/lockservice/lock_table_allocator_test.go @@ -171,7 +171,7 @@ func TestValid(t *testing.T) { time.Hour, func(a *lockTableAllocator) { b := a.Get("s1", 1) - assert.True(t, a.Valid([]pb.LockTable{b})) + assert.Empty(t, a.Valid([]pb.LockTable{b})) }) } @@ -182,7 +182,7 @@ func TestValidWithServiceInvalid(t *testing.T) { func(a *lockTableAllocator) { b := a.Get("s1", 1) b.ServiceID = "s2" - assert.False(t, a.Valid([]pb.LockTable{b})) + assert.NotEmpty(t, a.Valid([]pb.LockTable{b})) }) } @@ -193,7 +193,7 @@ func TestValidWithVersionChanged(t *testing.T) { func(a *lockTableAllocator) { b := a.Get("s1", 1) b.Version++ - assert.False(t, a.Valid([]pb.LockTable{b})) + assert.NotEmpty(t, a.Valid([]pb.LockTable{b})) }) } diff --git a/pkg/lockservice/service_observability.go b/pkg/lockservice/service_observability.go index dd763ba82105..302f5036de8a 100644 --- a/pkg/lockservice/service_observability.go +++ b/pkg/lockservice/service_observability.go @@ -49,10 +49,25 @@ func (s *service) GetWaitingList( return true, waitingList, nil } -func (s *service) ForceRefreshLockTableBinds() { +func (s *service) ForceRefreshLockTableBinds(targets ...uint64) { + contains := func(id uint64) bool { + if len(targets) == 0 { + return true + } + for _, v := range targets { + if v == id { + return true + } + } + return false + } + s.tables.Range(func(key, value any) bool { - value.(lockTable).close() - s.tables.Delete(key) + id := key.(uint64) + if contains(id) { + value.(lockTable).close() + s.tables.Delete(key) + } return true }) } @@ -62,6 +77,9 @@ func (s *service) GetLockTableBind(tableID uint64) (pb.LockTable, error) { if err != nil { return pb.LockTable{}, err } + if l == nil { + return pb.LockTable{}, nil + } return l.getBind(), nil } diff --git a/pkg/lockservice/types.go b/pkg/lockservice/types.go index a08b9f14cca9..eb2399725f3e 100644 --- a/pkg/lockservice/types.go +++ b/pkg/lockservice/types.go @@ -110,7 +110,7 @@ type LockService interface { // GetWaitingList get special txnID's waiting list GetWaitingList(ctx context.Context, txnID []byte) (bool, []pb.WaitTxn, error) // ForceRefreshLockTableBinds force refresh all lock tables binds - ForceRefreshLockTableBinds() + ForceRefreshLockTableBinds(targets ...uint64) // GetLockTableBind returns lock table bind GetLockTableBind(tableID uint64) (pb.LockTable, error) // IterLocks iter all locks on current lock service. len(keys) == 2 if is range lock, @@ -168,7 +168,7 @@ type LockTableAllocator interface { // period of time to maintain the binding, the binding will become invalid. KeepLockTableBind(serviceID string) bool // Valid check for changes in the binding relationship of a specific locktable. - Valid(binds []pb.LockTable) bool + Valid(binds []pb.LockTable) []uint64 // Close close the lock table allocator Close() error } diff --git a/pkg/pb/txn/txn.pb.go b/pkg/pb/txn/txn.pb.go index c28090b58a98..72057bfc5161 100644 --- a/pkg/pb/txn/txn.pb.go +++ b/pkg/pb/txn/txn.pb.go @@ -1019,6 +1019,7 @@ func (m *TxnCommitRequest) GetDisable1PCOpt() bool { // TxnCommitResponse response of TxnCommitRequest. type TxnCommitResponse struct { + InvalidLockTables []uint64 `protobuf:"varint,1,rep,packed,name=InvalidLockTables,proto3" json:"InvalidLockTables,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1057,6 +1058,13 @@ func (m *TxnCommitResponse) XXX_DiscardUnknown() { var xxx_messageInfo_TxnCommitResponse proto.InternalMessageInfo +func (m *TxnCommitResponse) GetInvalidLockTables() []uint64 { + if m != nil { + return m.InvalidLockTables + } + return nil +} + // TxnCommitRequest CN sent the rollback request to coordinator TN. type TxnRollbackRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1691,89 +1699,90 @@ func init() { func init() { proto.RegisterFile("txn.proto", fileDescriptor_4f782e76b37adb9a) } var fileDescriptor_4f782e76b37adb9a = []byte{ - // 1311 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xdb, 0x6e, 0xdb, 0x46, - 0x13, 0x36, 0x75, 0x24, 0x47, 0x07, 0x53, 0x1b, 0xc7, 0x61, 0xfc, 0xfb, 0x57, 0x04, 0x22, 0x08, - 0x14, 0xa1, 0x95, 0x1a, 0x07, 0xe9, 0x45, 0x0b, 0x18, 0xb0, 0xe5, 0x43, 0x0d, 0x44, 0xb6, 0xb1, - 0x62, 0x5b, 0xa4, 0x37, 0x05, 0x25, 0x6d, 0x65, 0xc2, 0x12, 0xc9, 0x92, 0x6b, 0x43, 0x7e, 0x96, - 0xbe, 0x50, 0x2e, 0xf3, 0x00, 0x45, 0xd1, 0x1a, 0xe8, 0x4d, 0x6f, 0xfb, 0x02, 0xc5, 0x2e, 0x77, - 0x25, 0x92, 0x92, 0x92, 0xc2, 0xbd, 0xd2, 0xee, 0x1c, 0xbe, 0x59, 0xcd, 0xcc, 0x37, 0xbb, 0x04, - 0x8d, 0xce, 0xdc, 0xb6, 0x1f, 0x78, 0xd4, 0x43, 0x59, 0x3a, 0x73, 0x77, 0x3e, 0x1f, 0x3b, 0xf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84, 0x9e, 0x63, 0x31, 0xe7, 0x5d, 0xaa, 0xe7, - 0x51, 0x4d, 0x3e, 0xc0, 0x44, 0x25, 0xf4, 0x02, 0x7a, 0xb4, 0x78, 0x56, 0x49, 0x61, 0x11, 0xe9, - 0x50, 0x96, 0xd5, 0x61, 0xb5, 0xd1, 0x55, 0x16, 0xfa, 0xe8, 0xf8, 0xf0, 0xdb, 0x53, 0x5d, 0x3b, - 0xdc, 0xff, 0xf0, 0x47, 0x5d, 0x79, 0x7f, 0x5f, 0x57, 0x3e, 0xdc, 0xd7, 0x95, 0xdf, 0xef, 0xeb, - 0xca, 0x0f, 0x9f, 0xc5, 0x3e, 0x2d, 0xa7, 0x36, 0x0d, 0x9c, 0x99, 0x17, 0x38, 0x63, 0xc7, 0x95, - 0x1b, 0x97, 0x74, 0xfc, 0xeb, 0x71, 0xc7, 0x1f, 0x74, 0xe8, 0xcc, 0x1d, 0x14, 0xf8, 0x37, 0xe3, - 0xeb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x1c, 0x8b, 0x23, 0xf6, 0xa1, 0x0e, 0x00, 0x00, + // 1326 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xdd, 0x6e, 0xdb, 0x36, + 0x14, 0x8e, 0xfc, 0x2b, 0x1d, 0xff, 0x44, 0x66, 0xd3, 0x54, 0xcd, 0x3a, 0xd7, 0x10, 0x8a, 0xc2, + 0x35, 0x3a, 0x7b, 0x6d, 0xd1, 0x5d, 0x6c, 0x40, 0x81, 0xc4, 0xf9, 0x99, 0x81, 0x3a, 0x09, 0x68, + 0x6d, 0x43, 0x77, 0x33, 0xc8, 0x36, 0xe7, 0x08, 0xb1, 0x25, 0x4d, 0x62, 0x02, 0xe7, 0x59, 0xf6, + 0x42, 0xbd, 0xec, 0x03, 0x0c, 0xc3, 0x16, 0x60, 0x37, 0xbb, 0xdd, 0x0b, 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0x5e, + 0xe4, 0xee, 0x0f, 0xa4, 0x7b, 0x4a, 0x8d, 0xd3, 0xf6, 0xe8, 0x0d, 0x54, 0x05, 0xf1, 0x25, 0x82, + 0xca, 0x11, 0x76, 0x25, 0x42, 0x52, 0x8b, 0x53, 0xd6, 0xe8, 0x10, 0xf4, 0x13, 0x42, 0xc5, 0xdc, + 0x12, 0x08, 0x1a, 0x47, 0x30, 0x24, 0x42, 0x5a, 0x8f, 0x57, 0x3c, 0xd0, 0x39, 0xec, 0x88, 0x21, + 0x12, 0x75, 0x83, 0x44, 0x02, 0x8e, 0xf4, 0x28, 0x99, 0x8c, 0xa4, 0x0d, 0x5e, 0xeb, 0x89, 0xbe, + 0x87, 0x5d, 0xf9, 0x57, 0x53, 0x98, 0x25, 0x8e, 0x59, 0x4f, 0x67, 0x28, 0x85, 0xba, 0xc1, 0x1b, + 0x1d, 0x41, 0x15, 0x93, 0x99, 0x77, 0x4d, 0xfa, 0xa2, 0x81, 0x8d, 0x32, 0xc7, 0xfb, 0x7c, 0x81, + 0x97, 0xd0, 0x2e, 0xd2, 0x96, 0x14, 0xa3, 0x2f, 0xa1, 0x78, 0xe6, 0xb3, 0xa1, 0x13, 0x1a, 0x95, + 0x64, 0xbe, 0x85, 0x87, 0xd0, 0x62, 0x69, 0x66, 0xbe, 0x83, 0xda, 0x8a, 0x16, 0xd5, 0x01, 0x30, + 0xa1, 0xc1, 0x0d, 0xa3, 0x5f, 0x68, 0x28, 0x8d, 0x6c, 0x33, 0x8f, 0x63, 0x12, 0x36, 0x15, 0xf8, + 0xae, 0xe7, 0x52, 0x12, 0x5c, 0xdb, 0x53, 0xde, 0xf9, 0x59, 0x9c, 0x14, 0x9a, 0xff, 0xe4, 0xa1, + 0xc4, 0xb1, 0x05, 0xd9, 0x3e, 0xce, 0xa1, 0xfa, 0x46, 0x0e, 0xfd, 0x7f, 0xf6, 0x3c, 0x03, 0xd5, + 0x9a, 0xbb, 0x47, 0x7c, 0x06, 0x47, 0xe4,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xac, 0x67, 0x99, 0xf1, 0xfe, 0xd0, 0x0b, 0xb8, 0x32, 0x87, 0x4a, + 0x50, 0xe4, 0x3b, 0x32, 0xd6, 0xf3, 0xad, 0x5f, 0x15, 0x1e, 0x41, 0xdc, 0x34, 0x2a, 0xe4, 0xd8, + 0xa3, 0x5a, 0xdf, 0x42, 0x1a, 0xe4, 0xf9, 0x73, 0x59, 0x57, 0x58, 0xd8, 0x08, 0x4c, 0xcf, 0x30, + 0x24, 0x59, 0x38, 0x3d, 0xcb, 0x90, 0xc4, 0x21, 0xf4, 0x1c, 0x8b, 0xb9, 0xe8, 0x52, 0x3d, 0x8f, + 0x6a, 0xf2, 0xb9, 0x26, 0x2a, 0xa1, 0x17, 0xd0, 0xbd, 0xe5, 0x23, 0x4c, 0x0a, 0x8b, 0x48, 0x87, + 0xb2, 0xac, 0x0e, 0xab, 0x8d, 0xae, 0xb2, 0xd0, 0x87, 0x47, 0x07, 0xdf, 0x9d, 0xe8, 0xda, 0xc1, + 0x9b, 0x0f, 0x7f, 0xd6, 0x95, 0xf7, 0xb7, 0x75, 0xe5, 0xc3, 0x6d, 0x5d, 0xf9, 0xe3, 0xb6, 0xae, + 0xfc, 0xf8, 0x3c, 0xf6, 0x21, 0x3a, 0xb3, 0x69, 0xe0, 0xcc, 0xbd, 0xc0, 0x99, 0x38, 0xae, 0xdc, + 0xb8, 0xa4, 0xe3, 0x5f, 0x4e, 0x3a, 0xfe, 0xb0, 0x43, 0xe7, 0xee, 0xb0, 0xc0, 0xbf, 0x30, 0x5f, + 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x02, 0x02, 0xbb, 0xe7, 0xcf, 0x0e, 0x00, 0x00, } func (m *TxnMeta) Marshal() (dAtA []byte, err error) { @@ -2512,6 +2521,24 @@ func (m *TxnCommitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } + if len(m.InvalidLockTables) > 0 { + dAtA29 := make([]byte, len(m.InvalidLockTables)*10) + var j28 int + for _, num := range m.InvalidLockTables { + for num >= 1<<7 { + dAtA29[j28] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j28++ + } + dAtA29[j28] = uint8(num) + j28++ + } + i -= j28 + copy(dAtA[i:], dAtA29[:j28]) + i = encodeVarintTxn(dAtA, i, uint64(j28)) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -3229,6 +3256,13 @@ func (m *TxnCommitResponse) Size() (n int) { } var l int _ = l + if len(m.InvalidLockTables) > 0 { + l = 0 + for _, e := range m.InvalidLockTables { + l += sovTxn(uint64(e)) + } + n += 1 + sovTxn(uint64(l)) + l + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -5391,6 +5425,82 @@ func (m *TxnCommitResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: TxnCommitResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTxn + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.InvalidLockTables = append(m.InvalidLockTables, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTxn + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTxn + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTxn + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.InvalidLockTables) == 0 { + m.InvalidLockTables = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTxn + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.InvalidLockTables = append(m.InvalidLockTables, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field InvalidLockTables", wireType) + } default: iNdEx = preIndex skippy, err := skipTxn(dAtA[iNdEx:]) diff --git a/pkg/txn/client/operator.go b/pkg/txn/client/operator.go index e2f759862ce2..d48f6b262aef 100644 --- a/pkg/txn/client/operator.go +++ b/pkg/txn/client/operator.go @@ -834,6 +834,11 @@ func (tc *txnOperator) handleErrorResponse(resp txn.TxnResponse) error { return err } + // commit failed, refresh invalid lock tables + if err != nil && moerr.IsMoErrCode(err, moerr.ErrLockTableBindChanged) { + tc.option.lockService.ForceRefreshLockTableBinds(resp.CommitResponse.InvalidLockTables...) + } + v, ok := moruntime.ProcessLevelRuntime().GetGlobalVariables(moruntime.EnableCheckInvalidRCErrors) if ok && v.(bool) { if moerr.IsMoErrCode(err, moerr.ErrTxnWWConflict) || diff --git a/pkg/txn/client/operator_test.go b/pkg/txn/client/operator_test.go index 5a17c6cd2623..423535597b97 100644 --- a/pkg/txn/client/operator_test.go +++ b/pkg/txn/client/operator_test.go @@ -167,6 +167,50 @@ func TestCommitWithLockTables(t *testing.T) { }) } +func TestCommitWithLockTablesChanged(t *testing.T) { + runOperatorTests(t, func(ctx context.Context, tc *txnOperator, ts *testTxnSender) { + lockservice.RunLockServicesForTest( + zap.DebugLevel, + []string{"s1"}, + time.Second, + func(lta lockservice.LockTableAllocator, ls []lockservice.LockService) { + s := ls[0] + + _, err := s.Lock(ctx, 1, [][]byte{[]byte("k1")}, tc.txnID, lock.LockOptions{}) + assert.NoError(t, err) + _, err = s.Lock(ctx, 2, [][]byte{[]byte("k1")}, tc.txnID, lock.LockOptions{}) + assert.NoError(t, err) + + ts.setManual(func(sr *rpc.SendResult, err error) (*rpc.SendResult, error) { + sr.Responses[0].TxnError = txn.WrapError(moerr.NewLockTableBindChanged(ctx), 0) + sr.Responses[0].CommitResponse = &txn.TxnCommitResponse{ + InvalidLockTables: []uint64{1}, + } + return sr, nil + }) + + tc.mu.txn.Mode = txn.TxnMode_Pessimistic + tc.option.lockService = s + tc.AddLockTable(lock.LockTable{Table: 1}) + tc.AddLockTable(lock.LockTable{Table: 2}) + tc.mu.txn.TNShards = append(tc.mu.txn.TNShards, metadata.TNShard{TNShardRecord: metadata.TNShardRecord{ShardID: 1}}) + err = tc.Commit(ctx) + assert.Error(t, err) + + // table 1 will be removed + bind, err := s.GetLockTableBind(1) + require.NoError(t, err) + require.Equal(t, lock.LockTable{}, bind) + + // table 2 will be kept + bind, err = s.GetLockTableBind(2) + require.NoError(t, err) + require.NotEqual(t, lock.LockTable{}, bind) + }, + nil) + }) +} + func TestContextWithoutDeadlineWillPanic(t *testing.T) { runOperatorTests(t, func(_ context.Context, tc *txnOperator, _ *testTxnSender) { defer func() { diff --git a/pkg/txn/service/service_cn_handler.go b/pkg/txn/service/service_cn_handler.go index 2390b67a70b8..ca23c998f7cf 100644 --- a/pkg/txn/service/service_cn_handler.go +++ b/pkg/txn/service/service_cn_handler.go @@ -198,10 +198,13 @@ func (s *service) Commit(ctx context.Context, request *txn.TxnRequest, response s.logger.Fatal("commit with empty tn shards") } - if len(request.Txn.LockTables) > 0 && - !s.allocator.Valid(request.Txn.LockTables) { - response.TxnError = txn.WrapError(moerr.NewLockTableBindChanged(ctx), 0) - return nil + if len(request.Txn.LockTables) > 0 { + invalidBinds := s.allocator.Valid(request.Txn.LockTables) + if len(invalidBinds) > 0 { + response.CommitResponse.InvalidLockTables = invalidBinds + response.TxnError = txn.WrapError(moerr.NewLockTableBindChanged(ctx), 0) + return nil + } } txnID := request.Txn.ID diff --git a/pkg/txn/service/service_cn_handler_test.go b/pkg/txn/service/service_cn_handler_test.go index 74a26087dee7..1d8b0e61ac86 100644 --- a/pkg/txn/service/service_cn_handler_test.go +++ b/pkg/txn/service/service_cn_handler_test.go @@ -57,7 +57,7 @@ func TestReadBasic(t *testing.T) { checkReadResponses(t, resp, "") } -func TestReadWithTNShartnotMatch(t *testing.T) { +func TestReadWithTNShardNotMatch(t *testing.T) { sender := NewTestSender() defer func() { assert.NoError(t, sender.Close()) @@ -79,7 +79,6 @@ func TestReadWithTNShartnotMatch(t *testing.T) { resp := readTestData(t, sender, 1, rTxn, 1) checkResponses(t, resp, txn.WrapError(moerr.NewTNShardNotFound(context.TODO(), "", 1), 0)) - // newTxnError(moerr.ErrDNShardNotFound, "txn not active")) } func TestReadWithSelfWrite(t *testing.T) { @@ -128,7 +127,7 @@ func TestReadBlockWithClock(t *testing.T) { assert.Equal(t, int64(3), ts) } -func TestReadCannotBlockByUncomitted(t *testing.T) { +func TestReadCannotBlockByUncommitted(t *testing.T) { sender := NewTestSender() defer func() { assert.NoError(t, sender.Close()) @@ -428,7 +427,7 @@ func TestWriteBasic(t *testing.T) { assert.Equal(t, GetTestValue(1, wTxn), v) } -func TestWriteWithTNShartnotMatch(t *testing.T) { +func TestWriteWithTNShardNotMatch(t *testing.T) { sender := NewTestSender() defer func() { assert.NoError(t, sender.Close()) @@ -471,7 +470,6 @@ func TestWriteWithWWConflict(t *testing.T) { wTxn2 := NewTestTxn(2, 1) checkResponses(t, writeTestData(t, sender, 1, wTxn2, 1), txn.WrapError(moerr.NewTAEWrite(context.TODO()), 0)) - // newTxnError(moerr.ErrTAEWrite, "write conlict")) } func TestCommitWithSingleTNShard(t *testing.T) { @@ -509,7 +507,7 @@ func TestCommitWithSingleTNShard(t *testing.T) { } } -func TestCommitWithTNShartnotMatch(t *testing.T) { +func TestCommitWithTNShardNotMatch(t *testing.T) { sender := NewTestSender() defer func() { assert.NoError(t, sender.Close()) @@ -739,7 +737,7 @@ func TestRollback(t *testing.T) { checkData(t, wTxn, s2, 2, 0, false) } -func TestRollbackWithTNShartnotFound(t *testing.T) { +func TestRollbackWithTNShardNotFound(t *testing.T) { sender := NewTestSender() defer func() { assert.NoError(t, sender.Close()) diff --git a/proto/txn.proto b/proto/txn.proto index ae62e450faf9..89f0bc721ea1 100644 --- a/proto/txn.proto +++ b/proto/txn.proto @@ -275,6 +275,7 @@ message TxnCommitRequest { // TxnCommitResponse response of TxnCommitRequest. message TxnCommitResponse { + repeated uint64 InvalidLockTables = 1; } // TxnCommitRequest CN sent the rollback request to coordinator TN.