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

sink(ticdc): refine sink interface and add init method (#5196) #5432

Closed
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
12 changes: 12 additions & 0 deletions cdc/processor/pipeline/sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ func (c *mockFlowController) GetConsumption() uint64 {
return 0
}

<<<<<<< HEAD
=======
func (s *mockSink) Init(tableID model.TableID) error {
return nil
}

func (s *mockSink) TryEmitRowChangedEvents(ctx context.Context, rows ...*model.RowChangedEvent) (bool, error) {
_ = s.EmitRowChangedEvents(ctx, rows...)
return true, nil
}

>>>>>>> c6966a492 (sink(ticdc): refine sink interface and add init method (#5196))
func (s *mockSink) EmitRowChangedEvents(ctx context.Context, rows ...*model.RowChangedEvent) error {
for _, row := range rows {
s.received = append(s.received, struct {
Expand Down
25 changes: 25 additions & 0 deletions cdc/processor/pipeline/sorter.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,36 @@ func (n *sorterNode) Receive(ctx pipeline.NodeContext) error {
default:
ctx.SendToNextNode(msg)
}
<<<<<<< HEAD
return nil
=======
}

func (n *sorterNode) releaseResource(changefeedID string) {
defer tableMemoryHistogram.DeleteLabelValues(changefeedID)
// Since the flowController is implemented by `Cond`, it is not cancelable by a context
// the flowController will be blocked in a background goroutine,
// We need to abort the flowController manually in the nodeRunner
n.flowController.Abort()
>>>>>>> c6966a492 (sink(ticdc): refine sink interface and add init method (#5196))
}

func (n *sorterNode) Destroy(ctx pipeline.NodeContext) error {
defer tableMemoryHistogram.DeleteLabelValues(ctx.ChangefeedVars().ID, ctx.GlobalVars().CaptureInfo.AdvertiseAddr)
n.cancel()
<<<<<<< HEAD
return n.wg.Wait()
=======
n.releaseResource(ctx.ChangefeedVars().ID)
return n.eg.Wait()
}

func (n *sorterNode) ResolvedTs() model.Ts {
return atomic.LoadUint64(&n.resolvedTs)
}

// BarrierTs returns the sorter barrierTs
func (n *sorterNode) BarrierTs() model.Ts {
return atomic.LoadUint64(&n.barrierTs)
>>>>>>> c6966a492 (sink(ticdc): refine sink interface and add init method (#5196))
}
Loading