Skip to content

Commit

Permalink
etcd_worker: batch etcd patch (pingcap#3277) (pingcap#3393)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored and 3AceShowHand committed Jan 13, 2022
1 parent 47f28b0 commit bb8b7c1
Show file tree
Hide file tree
Showing 18 changed files with 1,707 additions and 71 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 @@ -281,7 +281,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/tiflow/cdc/puller/sorter"
"github.com/pingcap/tiflow/cdc/sink"
"github.com/pingcap/tiflow/pkg/config"
"github.com/pingcap/tiflow/pkg/orchestrator"
"github.com/prometheus/client_golang/prometheus"
)

Expand All @@ -37,6 +38,7 @@ func init() {
sink.InitMetrics(registry)
entry.InitMetrics(registry)
sorter.InitMetrics(registry)
orchestrator.InitMetrics(registry)
if config.NewReplicaImpl {
processor.InitMetrics(registry)
tablepipeline.InitMetrics(registry)
Expand Down
4 changes: 3 additions & 1 deletion cdc/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ func (s *taskSuite) TestWatch(c *check.C) {
}

// Watch with a normal context
ch := s.w.Watch(context.Background())
ctx, cancel = context.WithCancel(context.Background())
defer cancel()
ch := s.w.Watch(ctx)

// Trigger the ErrCompacted error
c.Assert(failpoint.Enable("github.com/pingcap/tiflow/cdc.restart_task_watch", "50%off"), check.IsNil)
Expand Down
10 changes: 10 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/Shopify/sarama v1.27.2
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/apache/pulsar-client-go v0.1.1
github.com/benbjohnson/clock v1.1.0
github.com/bradleyjkemp/grpc-tools v0.2.5
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
Expand Down
Loading

0 comments on commit bb8b7c1

Please sign in to comment.