Skip to content

Commit

Permalink
etcd_worker: batch etcd patch (#3277) (#3390)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Dec 10, 2021
1 parent 6fd27fc commit f37133e
Show file tree
Hide file tree
Showing 15 changed files with 1,418 additions and 47 deletions.
2 changes: 1 addition & 1 deletion cdc/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (c *Capture) Run(ctx context.Context) (err error) {
return errors.Trace(err)
}
log.Info("start to listen processor task...")
if err := etcdWorker.Run(ctx, c.session, 200*time.Millisecond); err != nil {
if err := etcdWorker.Run(ctx, c.session, 200*time.Millisecond, c.info.AdvertiseAddr); err != nil {
// We check ttl of lease instead of check `session.Done`, because
// `session.Done` is only notified when etcd client establish a
// new keepalive request, there could be a time window as long as
Expand Down
3 changes: 2 additions & 1 deletion cdc/capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ func (c *Capture) runEtcdWorker(ctx cdcContext.Context, reactor orchestrator.Rea
if err != nil {
return errors.Trace(err)
}
if err := etcdWorker.Run(ctx, c.session, timerInterval); err != nil {
captureAddr := c.info.AdvertiseAddr
if err := etcdWorker.Run(ctx, c.session, timerInterval, captureAddr); err != nil {
// We check ttl of lease instead of check `session.Done`, because
// `session.Done` is only notified when etcd client establish a
// new keepalive request, there could be a time window as long as
Expand Down
2 changes: 2 additions & 0 deletions cdc/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/pingcap/ticdc/cdc/puller/sorter"
"github.com/pingcap/ticdc/cdc/sink"
"github.com/pingcap/ticdc/pkg/config"
"github.com/pingcap/ticdc/pkg/orchestrator"
"github.com/prometheus/client_golang/prometheus"
)

Expand All @@ -36,6 +37,7 @@ func init() {
puller.InitMetrics(registry)
sink.InitMetrics(registry)
entry.InitMetrics(registry)
orchestrator.InitMetrics(registry)
sorter.InitMetrics(registry)
if config.NewReplicaImpl {
processor.InitMetrics(registry)
Expand Down
1 change: 1 addition & 0 deletions cdc/model/reactor_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (s *GlobalReactorState) Update(key util.EtcdKey, value []byte, _ bool) erro
}

// GetPatches implements the ReactorState interface
// Every []DataPatch slice in [][]DataPatch slice is the patches of a ChangefeedReactorState
func (s *GlobalReactorState) GetPatches() [][]orchestrator.DataPatch {
pendingPatches := s.pendingPatches
for _, changefeedState := range s.Changefeeds {
Expand Down
10 changes: 10 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ error = '''
the etcd txn should be aborted and retried immediately
'''

["CDC:ErrEtcdTxnOpsExceed"]
error = '''
patch ops:%d of a single changefeed exceed etcd txn max ops:%d
'''

["CDC:ErrEtcdTxnSizeExceed"]
error = '''
patch size:%d of a single changefeed exceed etcd txn max size:%d
'''

["CDC:ErrEventFeedAborted"]
error = '''
single event feed aborted
Expand Down
Loading

0 comments on commit f37133e

Please sign in to comment.