Skip to content

Commit

Permalink
drainer: Clear the cache instead of refreshing after DDL to avoid unn…
Browse files Browse the repository at this point in the history
…ecessary queries (#865)
  • Loading branch information
suzaku authored Jan 7, 2020
1 parent 0dd2e28 commit 86e7ffb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/loader/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ func (s *loaderImpl) Close() {

var utilGetTableInfo = getTableInfo

func (s *loaderImpl) invalidateTableInfo(schema string, table string) {
s.tableInfos.Delete(quoteSchema(schema, table))
}

func (s *loaderImpl) refreshTableInfo(schema string, table string) (info *tableInfo, err error) {
log.Info("refresh table info", zap.String("schema", schema), zap.String("table", table))

Expand Down Expand Up @@ -559,9 +563,7 @@ func newBatchManager(s *loaderImpl) *batchManager {
fDDLSuccessCallback: func(txn *Txn) {
s.markSuccess(txn)
if needRefreshTableInfo(txn.DDL.SQL) {
if _, err := s.refreshTableInfo(txn.DDL.Database, txn.DDL.Table); err != nil {
log.Error("refresh table info failed", zap.String("database", txn.DDL.Database), zap.String("table", txn.DDL.Table), zap.Error(err))
}
s.invalidateTableInfo(txn.DDL.Database, txn.DDL.Table)
}
},
}
Expand Down

0 comments on commit 86e7ffb

Please sign in to comment.