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(ticdc): Extract all closures to make code maintainable #8337

Merged
12 changes: 6 additions & 6 deletions cdc/processor/sinkmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ func (m *SinkManager) generateSinkTasks() error {
// Task upperbound is limited by barrierTs and schemaResolvedTs.
// But receivedSorterResolvedTs can be less than barrierTs, in which case
// the table is just scheduled to this node.
getUpperBound := func(tableSink *tableSinkWrapper) engine.Position {
upperBoundTs := tableSink.getReceivedSorterResolvedTs()
getUpperBound := func(tableSinkReceivedSorterResolvedTs model.Ts) engine.Position {
upperBoundTs := tableSinkReceivedSorterResolvedTs

barrierTs := m.lastBarrierTs.Load()
if upperBoundTs > barrierTs {
Expand Down Expand Up @@ -406,7 +406,7 @@ func (m *SinkManager) generateSinkTasks() error {
tableSink := tables[i]
slowestTableProgress := progs[i]
lowerBound := slowestTableProgress.nextLowerBoundPos
upperBound := getUpperBound(tableSink)
upperBound := getUpperBound(tableSink.getReceivedSorterResolvedTs())

// The table has no available progress.
if lowerBound.Compare(upperBound) >= 0 {
Expand Down Expand Up @@ -493,8 +493,8 @@ func (m *SinkManager) generateSinkTasks() error {

func (m *SinkManager) generateRedoTasks() error {
// We use the table's resolved ts as the upper bound to fetch events.
getUpperBound := func(tableSink *tableSinkWrapper) engine.Position {
upperBoundTs := tableSink.getReceivedSorterResolvedTs()
getUpperBound := func(tableSinkReceivedSorterResolvedTs model.Ts) engine.Position {
upperBoundTs := tableSinkReceivedSorterResolvedTs

// If a task carries events after schemaResolvedTs, mounter group threads
// can be blocked on waiting schemaResolvedTs get advanced.
Expand Down Expand Up @@ -552,7 +552,7 @@ func (m *SinkManager) generateRedoTasks() error {
tableSink := tables[i]
slowestTableProgress := progs[i]
lowerBound := slowestTableProgress.nextLowerBoundPos
upperBound := getUpperBound(tableSink)
upperBound := getUpperBound(tableSink.getReceivedSorterResolvedTs())

// The table has no available progress.
if lowerBound.Compare(upperBound) >= 0 {
Expand Down
6 changes: 3 additions & 3 deletions cdc/processor/sinkmanager/redo_log_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ func (w *redoWorker) handleTasks(ctx context.Context, taskChan <-chan *redoTask)

func (w *redoWorker) handleTask(ctx context.Context, task *redoTask) (finalErr error) {
lowerBound := task.lowerBound
upperBound := task.getUpperBound(task.tableSink)
upperBound := task.getUpperBound(task.tableSink.getReceivedSorterResolvedTs())
lowerPhs := oracle.GetTimeFromTS(lowerBound.CommitTs)
upperPhs := oracle.GetTimeFromTS(upperBound.CommitTs)
if upperPhs.Sub(lowerPhs) > maxTaskRange {
upperCommitTs := oracle.GoTimeToTS(lowerPhs.Add(maxTaskRange))
if upperPhs.Sub(lowerPhs) > maxTaskTimeRange {
upperCommitTs := oracle.GoTimeToTS(lowerPhs.Add(maxTaskTimeRange))
upperBound = engine.Position{
StartTs: upperCommitTs - 1,
CommitTs: upperCommitTs,
Expand Down
Loading