Skip to content

Commit

Permalink
capture(ticdc): fix the problem that openapi is blocked when pd is ab…
Browse files Browse the repository at this point in the history
…normal (#4778)
  • Loading branch information
CharlesCheung96 committed Mar 9, 2022
1 parent e40d1b8 commit f9d6172
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cdc/capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,17 @@ func NewCapture4Test(o owner.Owner) *Capture {
}

func (c *Capture) reset(ctx context.Context) error {
conf := config.GetGlobalServerConfig()
sess, err := concurrency.NewSession(c.EtcdClient.Client.Unwrap(),
concurrency.WithTTL(conf.CaptureSessionTTL))
if err != nil {
return errors.Annotate(
cerror.WrapError(cerror.ErrNewCaptureFailed, err),
"create capture session")
}

c.captureMu.Lock()
defer c.captureMu.Unlock()
conf := config.GetGlobalServerConfig()
c.info = &model.CaptureInfo{
ID: uuid.New().String(),
AdvertiseAddr: conf.AdvertiseAddr,
Expand All @@ -131,13 +139,6 @@ func (c *Capture) reset(ctx context.Context) error {
// It can't be handled even after it fails, so we ignore it.
_ = c.session.Close()
}
sess, err := concurrency.NewSession(c.EtcdClient.Client.Unwrap(),
concurrency.WithTTL(conf.CaptureSessionTTL))
if err != nil {
return errors.Annotate(
cerror.WrapError(cerror.ErrNewCaptureFailed, err),
"create capture session")
}
c.session = sess
c.election = concurrency.NewElection(sess, etcd.CaptureOwnerKey)

Expand Down

0 comments on commit f9d6172

Please sign in to comment.