pingcap / pingcap/ticdc

eventcollector: dispatcher session management is coupled with statistics tracking in dispatcherStat

Open
#5,002 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contribution first-time-contributor
Dominant language
Go
Stars
56
Forks
63
Avg merge
2d 20h
Merged PRs (30d)
34

Description

Problem

In the current implementation, dispatcherStat is responsible for both:

  1. Connection lifecycle management — tracking which event service the dispatcher is registered to (dispatcherConnState), handling ready/not-reusable signal events, managing remote candidates, and coordinating registration/reset/remove flows.
  2. Statistics and event processing — tracking checkpoint ts, epoch state, commit ts deduplication, and processing incoming data events.

This coupling makes the code harder to reason about. The connection state (connState) fields are accessed both from lifecycle coordination logic and from data event handling paths, making it difficult to understand the invariants of each subsystem independently.

Solution

Introduce a dispatcherSession type to encapsulate all connection lifecycle logic:

  • Ownership of dispatcherConnState (event service ID, ready state, remote candidates)
  • registerTo / commitReady / reset / remove / removeFrom operations
  • handleSignalEvent for TypeReadyEvent / TypeNotReusableEvent

dispatcherStat retains ownership of statistics and event processing, and delegates all session-related operations to dispatcherSession via a session field.

This separation makes each type's responsibility clear and easier to test independently.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating dispatcherStat and trace its dispatcherConnState access, then inspect the registerTo, commitReady, reset, remove, removeFrom, and handleSignalEvent paths. Separate those lifecycle operations into dispatcherSession while keeping checkpoint, epoch, commit deduplication, and data-event processing in dispatcherStat; done means dispatcherStat delegates session behavior through its session field and the two responsibilities can be tested independently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
distributed-systems
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.