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 2, 2023
1 parent a3c3229 commit 55f4ea1
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 @@ -585,7 +585,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 @@ -596,10 +597,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 55f4ea1

Please sign in to comment.