Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

puller: close kvclient correctly when stopping a processor (#11957) #11980

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cdc/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1089,4 +1089,8 @@

func (d *ddlHandler) WaitForReady(_ context.Context) {}

func (d *ddlHandler) Close() {}
func (d *ddlHandler) Close() {
if d.puller != nil {
d.puller.Close()
}

Check warning on line 1095 in cdc/processor/processor.go

View check run for this annotation

Codecov / codecov/patch

cdc/processor/processor.go#L1092-L1095

Added lines #L1092 - L1095 were not covered by tests
}
6 changes: 4 additions & 2 deletions cdc/processor/sourcemanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,10 @@ func (m *SourceManager) Close() {
zap.String("changefeed", m.changefeedID.ID))

start := time.Now()

log.Info("All pullers have been closed",
if m.puller != nil {
m.puller.Close()
}
log.Info("SourceManager puller have been closed",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.Duration("cost", time.Since(start)))
Expand Down
19 changes: 16 additions & 3 deletions cdc/puller/ddl_puller.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@
func (p *ddlJobPullerImpl) WaitForReady(_ context.Context) {}

// Close implements util.Runnable.
func (p *ddlJobPullerImpl) Close() {}
func (p *ddlJobPullerImpl) Close() {
if p.mp != nil {
p.mp.Close()
}

Check warning on line 170 in cdc/puller/ddl_puller.go

View check run for this annotation

Codecov / codecov/patch

cdc/puller/ddl_puller.go#L169-L170

Added lines #L169 - L170 were not covered by tests
}

// Output implements DDLJobPuller, it returns the output channel of DDL job.
func (p *ddlJobPullerImpl) Output() <-chan *model.DDLJobEntry {
Expand Down Expand Up @@ -714,6 +718,12 @@
zap.String("changefeed", h.changefeedID.ID),
zap.Uint64("resolvedTS", atomic.LoadUint64(&h.resolvedTS)))

defer func() {
log.Info("DDL puller stopped",
zap.String("namespace", h.changefeedID.Namespace),
zap.String("changefeed", h.changefeedID.ID))
}()

return g.Wait()
}

Expand All @@ -731,10 +741,13 @@

// Close the ddl puller, release all resources.
func (h *ddlPullerImpl) Close() {
log.Info("close the ddl puller",
h.cancel()
if h.ddlJobPuller != nil {
h.ddlJobPuller.Close()
}
log.Info("DDL puller closed",
zap.String("namespace", h.changefeedID.Namespace),
zap.String("changefeed", h.changefeedID.ID))
h.cancel()
}

func (h *ddlPullerImpl) ResolvedTs() uint64 {
Expand Down
10 changes: 10 additions & 0 deletions cdc/puller/multiplexing_puller.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,16 @@
return eg.Wait()
}

// Close closes the puller.
func (p *MultiplexingPuller) Close() {
if p.client != nil {
p.client.Close()
}
log.Info("MultiplexingPuller is closed",
zap.String("namespace", p.changefeed.Namespace),
zap.String("changefeed", p.changefeed.ID))

Check warning on line 366 in cdc/puller/multiplexing_puller.go

View check run for this annotation

Codecov / codecov/patch

cdc/puller/multiplexing_puller.go#L360-L366

Added lines #L360 - L366 were not covered by tests
}

// runEventHandler consumes events from inputCh:
// 1. If the event is a kv event, consume by calling progress.consume.f.
// 2. If the event is a resolved event, send it to the resolvedEventsCache of the corresponding progress.
Expand Down
Loading