Skip to content

Commit

Permalink
sink(ticdc): limit encoder-concurrency to avoid crash (pingcap#11775)
Browse files Browse the repository at this point in the history
  • Loading branch information
wk989898 authored and mjonss committed Nov 25, 2024
1 parent 94082c3 commit 205b582
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/sink/codec/encoder_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/pingcap/tidb/pkg/util/cpu"
"github.com/pingcap/tiflow/cdc/model"
"github.com/pingcap/tiflow/cdc/sink/dmlsink"
"github.com/pingcap/tiflow/pkg/config"
Expand Down Expand Up @@ -69,6 +70,11 @@ func NewEncoderGroup(
if concurrency <= 0 {
concurrency = config.DefaultEncoderGroupConcurrency
}
limitConcurrency := cpu.GetCPUCount() * 10
if concurrency > limitConcurrency {
concurrency = limitConcurrency
log.Warn("limit concurrency to avoid crash", zap.Int("concurrency", concurrency), zap.Any("limitConcurrency", limitConcurrency))
}
inputCh := make([]chan *future, concurrency)
for i := 0; i < concurrency; i++ {
inputCh[i] = make(chan *future, defaultInputChanSize)
Expand Down

0 comments on commit 205b582

Please sign in to comment.