@@ -51,6 +51,7 @@ func TestGetCandidateNodes(t *testing.T) {
5151 tableID2 := int64 (101 )
5252 span1 := common .TableIDToComparableSpan (common .DefaultKeyspaceID , tableID1 )
5353 span2 := common .TableIDToComparableSpan (common .DefaultKeyspaceID , tableID2 )
54+ startTs := uint64 (100 )
5455
5556 // initialize event store states
5657 coordinator .updateEventStoreState (nodeID1 , & logservicepb.EventStoreState {
@@ -129,22 +130,23 @@ func TestGetCandidateNodes(t *testing.T) {
129130 },
130131 },
131132 })
133+ require .Len (t , coordinator .eventStoreStates .m , 3 )
132134
133135 // check get candidates
134136 {
135- nodes := coordinator .getCandidateNodes (nodeID1 , & span1 , uint64 ( 100 ) )
137+ nodes := coordinator .getCandidateNodes (nodeID1 , & span1 , startTs )
136138 assert .Equal (t , []string {nodeID2 .String ()}, nodes )
137139 }
138140 {
139- nodes := coordinator .getCandidateNodes (nodeID3 , & span1 , uint64 ( 100 ) )
141+ nodes := coordinator .getCandidateNodes (nodeID3 , & span1 , startTs )
140142 assert .Equal (t , []string {nodeID2 .String (), nodeID1 .String ()}, nodes )
141143 }
142144 {
143- nodes := coordinator .getCandidateNodes (nodeID1 , & span2 , uint64 ( 100 ) )
145+ nodes := coordinator .getCandidateNodes (nodeID1 , & span2 , startTs )
144146 assert .Equal (t , []string {nodeID3 .String (), nodeID2 .String ()}, nodes )
145147 }
146148 {
147- nodes := coordinator .getCandidateNodes (nodeID3 , & span2 , uint64 ( 100 ) )
149+ nodes := coordinator .getCandidateNodes (nodeID3 , & span2 , startTs )
148150 assert .Equal (t , []string {nodeID2 .String ()}, nodes )
149151 }
150152
@@ -164,7 +166,7 @@ func TestGetCandidateNodes(t *testing.T) {
164166 },
165167 })
166168 {
167- nodes := coordinator .getCandidateNodes (nodeID3 , & span1 , uint64 ( 100 ) )
169+ nodes := coordinator .getCandidateNodes (nodeID3 , & span1 , startTs )
168170 assert .Equal (t , []string {nodeID1 .String (), nodeID2 .String ()}, nodes )
169171 }
170172
@@ -190,18 +192,49 @@ func TestGetCandidateNodes(t *testing.T) {
190192 },
191193 })
192194 {
193- nodes := coordinator .getCandidateNodes (nodeID3 , & span1 , uint64 ( 100 ) )
195+ nodes := coordinator .getCandidateNodes (nodeID3 , & span1 , startTs )
194196 assert .Equal (t , []string {nodeID2 .String (), nodeID1 .String ()}, nodes )
195197 }
196198
197199 // remove node1 and check again
198200 delete (coordinator .nodes .m , nodeID1 )
199201 {
200- nodes := coordinator .getCandidateNodes (nodeID3 , & span1 , uint64 ( 100 ) )
202+ nodes := coordinator .getCandidateNodes (nodeID3 , & span1 , startTs )
201203 assert .Equal (t , []string {nodeID2 .String ()}, nodes )
202204 }
203205}
204206
207+ func TestGetCandidateNodesIgnoreResolvedEqCheckpoint (t * testing.T ) {
208+ coordinator := newLogCoordinatorForTest ()
209+
210+ nodeID1 := node .ID ("node-1" )
211+ nodeID2 := node .ID ("node-2" )
212+ coordinator .nodes .m [nodeID1 ] = & node.Info {ID : nodeID1 }
213+ coordinator .nodes .m [nodeID2 ] = & node.Info {ID : nodeID2 }
214+
215+ tableID := int64 (200 )
216+ span := common .TableIDToComparableSpan (common .DefaultKeyspaceID , tableID )
217+ startTs := uint64 (600 )
218+
219+ coordinator .updateEventStoreState (nodeID2 , & logservicepb.EventStoreState {
220+ TableStates : map [int64 ]* logservicepb.TableState {
221+ tableID : {
222+ Subscriptions : []* logservicepb.SubscriptionState {
223+ {
224+ SubID : 1 ,
225+ Span : & span ,
226+ CheckpointTs : startTs - 1 ,
227+ ResolvedTs : startTs - 1 ,
228+ },
229+ },
230+ },
231+ },
232+ })
233+
234+ nodes := coordinator .getCandidateNodes (nodeID1 , & span , startTs )
235+ require .Empty (t , nodes , "resolvedTs equal to checkpointTs should not be reused" )
236+ }
237+
205238func TestUpdateChangefeedStates (t * testing.T ) {
206239 c := newLogCoordinatorForTest ()
207240
0 commit comments