Skip to content

Commit

Permalink
tables: disable row insertion consistency check in mutation checker; …
Browse files Browse the repository at this point in the history
…and fix the cache problem (#35104) (#35123)

close #35103
  • Loading branch information
ti-srebot authored Jun 2, 2022
1 parent edd2f0a commit 4c39b09
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 7 additions & 1 deletion store/driver/txn/txn_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type tikvTxn struct {
*tikv.KVTxn
idxNameCache map[int64]*model.TableInfo
snapshotInterceptor kv.SnapshotInterceptor
// columnMapsCache is a cache used for the mutation checker
columnMapsCache interface{}
}

// NewTiKVTxn returns a new Transaction.
Expand All @@ -52,7 +54,7 @@ func NewTiKVTxn(txn *tikv.KVTxn) kv.Transaction {
totalLimit := atomic.LoadUint64(&kv.TxnTotalSizeLimit)
txn.GetUnionStore().SetEntrySizeLimit(entryLimit, totalLimit)

return &tikvTxn{txn, make(map[int64]*model.TableInfo), nil}
return &tikvTxn{txn, make(map[int64]*model.TableInfo), nil, nil}
}

func (txn *tikvTxn) GetTableInfo(id int64) *model.TableInfo {
Expand Down Expand Up @@ -237,6 +239,8 @@ func (txn *tikvTxn) SetOption(opt int, val interface{}) {
txn.KVTxn.SetRPCInterceptor(val.(interceptor.RPCInterceptor))
case kv.AssertionLevel:
txn.KVTxn.SetAssertionLevel(val.(kvrpcpb.AssertionLevel))
case kv.TableToColumnMaps:
txn.columnMapsCache = val
}
}

Expand All @@ -246,6 +250,8 @@ func (txn *tikvTxn) GetOption(opt int) interface{} {
return !txn.KVTxn.IsCasualConsistency()
case kv.TxnScope:
return txn.KVTxn.GetScope()
case kv.TableToColumnMaps:
return txn.columnMapsCache
default:
return nil
}
Expand Down
17 changes: 10 additions & 7 deletions table/tables/mutation_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ func CheckDataConsistency(

columnMaps := getColumnMaps(txn, t)

if rowToInsert != nil {
if err := checkRowInsertionConsistency(
sessVars, rowToInsert, rowInsertion, columnMaps.ColumnIDToInfo, columnMaps.ColumnIDToFieldType, t.Meta().Name.O,
); err != nil {
return errors.Trace(err)
}
}
// Row insertion consistency check contributes the least to defending data-index consistency, but costs most CPU resources.
// So we disable it for now.
//
// if rowToInsert != nil {
// if err := checkRowInsertionConsistency(
// sessVars, rowToInsert, rowInsertion, columnMaps.ColumnIDToInfo, columnMaps.ColumnIDToFieldType, t.Meta().Name.O,
// ); err != nil {
// return errors.Trace(err)
// }
// }

if err != nil {
return err
Expand Down

0 comments on commit 4c39b09

Please sign in to comment.