Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sdojjy committed May 16, 2022
1 parent f2e9aeb commit 64cd3c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
5 changes: 3 additions & 2 deletions cdc/capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/log"
"github.com/pingcap/tiflow/pkg/util"
"go.etcd.io/etcd/client/v3/concurrency"
"go.etcd.io/etcd/server/v3/mvcc"
"go.uber.org/zap"
Expand Down Expand Up @@ -290,7 +291,7 @@ func (c *Capture) run(stdCtx context.Context) error {
// when the etcd worker of processor returns an error, it means that the processor throws an unrecoverable serious errors
// (recoverable errors are intercepted in the processor tick)
// so we should also stop the processor and let capture restart or exit
processorErr = c.runEtcdWorker(ctx, c.processorManager, globalState, processorFlushInterval, orchestrator.ProcessorRole)
processorErr = c.runEtcdWorker(ctx, c.processorManager, globalState, processorFlushInterval, util.RoleProcessor.String())
log.Info("the processor routine has exited", zap.Error(processorErr))
}()
wg.Add(1)
Expand Down Expand Up @@ -388,7 +389,7 @@ func (c *Capture) campaignOwner(ctx cdcContext.Context) error {
c.MessageRouter.RemovePeer(captureID)
})

err = c.runEtcdWorker(ownerCtx, owner, orchestrator.NewGlobalState(), ownerFlushInterval, orchestrator.OwnerRole)
err = c.runEtcdWorker(ownerCtx, owner, orchestrator.NewGlobalState(), ownerFlushInterval, util.RoleOwner.String())
c.setOwner(nil)
log.Info("run owner exited", zap.Error(err))
// if owner exits, resign the owner key
Expand Down
15 changes: 5 additions & 10 deletions pkg/orchestrator/etcd_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import (
"github.com/pingcap/failpoint"
"github.com/pingcap/log"
"github.com/pingcap/tiflow/pkg/chdelay"
cerrors "github.com/pingcap/tiflow/pkg/errors"
"github.com/pingcap/tiflow/pkg/etcd"
"github.com/pingcap/tiflow/pkg/orchestrator/util"
pkgutil "github.com/pingcap/tiflow/pkg/util"
"github.com/prometheus/client_golang/prometheus"
"go.etcd.io/etcd/api/v3/etcdserverpb"
"go.etcd.io/etcd/api/v3/mvccpb"
Expand All @@ -32,22 +36,13 @@ import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"golang.org/x/time/rate"

cerrors "github.com/pingcap/tiflow/pkg/errors"
"github.com/pingcap/tiflow/pkg/etcd"
"github.com/pingcap/tiflow/pkg/orchestrator/util"
)

const (
// When EtcdWorker commits a txn to etcd or ticks its reactor
// takes more than etcdWorkerLogsWarnDuration, it will print a log
etcdWorkerLogsWarnDuration = 1 * time.Second
deletionCounterKey = "/meta/ticdc-delete-etcd-key-count"

// ProcessorRole is the role of the processor etcd worker
ProcessorRole = "processor"
// OwnerRole is the role of the owner etcd worker
OwnerRole = "owner"
)

// EtcdWorker handles all interactions with Etcd
Expand Down Expand Up @@ -140,7 +135,7 @@ func (worker *EtcdWorker) Run(ctx context.Context, session *concurrency.Session,
defer cancel()
watchCh := worker.client.Watch(watchCtx, worker.prefix.String(), role, clientv3.WithPrefix(), clientv3.WithRev(worker.revision+1))

if role == ProcessorRole {
if role == pkgutil.RoleProcessor.String() {
failpoint.Inject("ProcessorEtcdDelay", func() {
delayer := chdelay.NewChannelDelayer(time.Second*3, watchCh, 1024, 16)
defer delayer.Close()
Expand Down

0 comments on commit 64cd3c6

Please sign in to comment.