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

processor: fix processor doesn't fully exit after p.stop is called #693

Merged
merged 2 commits into from
Jun 28, 2020
Merged
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
9 changes: 6 additions & 3 deletions cdc/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ type processor struct {
globalResolvedTs uint64
checkpointTs uint64

ddlPuller puller.Puller
schemaStorage *entry.SchemaStorage
ddlPuller puller.Puller
ddlPullerCancel context.CancelFunc
schemaStorage *entry.SchemaStorage

tsRWriter storage.ProcessorTsRWriter
output chan *model.PolymorphicEvent
Expand Down Expand Up @@ -213,7 +214,8 @@ func newProcessor(
func (p *processor) Run(ctx context.Context) {
wg, cctx := errgroup.WithContext(ctx)
p.wg = wg
ddlPullerCtx := util.PutTableIDInCtx(cctx, 0)
ddlPullerCtx, ddlPullerCancel := context.WithCancel(util.PutTableIDInCtx(cctx, 0))
p.ddlPullerCancel = ddlPullerCancel

wg.Go(func() error {
return p.positionWorker(cctx)
Expand Down Expand Up @@ -862,6 +864,7 @@ func (p *processor) stop(ctx context.Context) error {
for _, tbl := range p.tables {
tbl.cancel()
}
p.ddlPullerCancel()
// mark tables share the same context with its original table, don't need to cancel
p.stateMu.Unlock()
atomic.StoreInt32(&p.stopped, 1)
Expand Down