Skip to content

Commit

Permalink
use defer cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
amyangfei committed Mar 4, 2023
1 parent 287e259 commit 374802c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cdc/sink/dmlsink/txn/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ func (s *mysqlBackend) multiStmtExecute(
}
multiStmtArgs = append(multiStmtArgs, dmls.values[i]...)
}
ctx, cancelFunc := context.WithTimeout(ctx, writeTimeout)
ctx, cancel := context.WithTimeout(ctx, writeTimeout)
defer cancel()
_, execError := tx.ExecContext(ctx, multiStmtSQL, multiStmtArgs...)
if execError != nil {
err := logDMLTxnErr(
Expand All @@ -626,10 +627,8 @@ func (s *mysqlBackend) multiStmtExecute(
log.Warn("failed to rollback txn", zap.Error(rbErr))
}
}
cancelFunc()
return err
}
cancelFunc()
return nil
}

Expand Down

0 comments on commit 374802c

Please sign in to comment.