@@ -43,7 +43,8 @@ type Coordinator struct {
43
43
// list of workers
44
44
workers []* Worker
45
45
46
- // The low water mark. This is the sequence number of the last job that has been committed.
46
+ // The low water mark. We maintain that all transactions with
47
+ // sequence number <= lowWaterMark have been completed.
47
48
lowWaterMark int64
48
49
49
50
// This is a map of completed jobs by their sequence numbers.
@@ -194,6 +195,7 @@ func (w *Worker) ProcessEvents() error {
194
195
if len (dmlEvents ) == cap (dmlEvents ) {
195
196
if err := w .applyDMLEvents (dmlEvents ); err != nil {
196
197
w .coordinator .migrationContext .Log .Errore (err )
198
+ // TODO do something with the err
197
199
}
198
200
dmlEvents = dmlEvents [:0 ]
199
201
}
@@ -479,10 +481,6 @@ func (c *Coordinator) WaitForTransaction(lastCommitted int64) chan struct{} {
479
481
return nil
480
482
}
481
483
482
- if _ , ok := c .completedJobs [lastCommitted ]; ok {
483
- return nil
484
- }
485
-
486
484
waitChannel := make (chan struct {})
487
485
c .waitingJobs [lastCommitted ] = append (c .waitingJobs [lastCommitted ], waitChannel )
488
486
@@ -503,8 +501,6 @@ func (c *Coordinator) MarkTransactionCompleted(sequenceNumber, logPos, eventSize
503
501
c .mu .Lock ()
504
502
defer c .mu .Unlock ()
505
503
506
- //c.migrationContext.Log.Infof("Coordinator: Marking job as completed: %d\n", sequenceNumber)
507
-
508
504
// Mark the job as completed
509
505
c .completedJobs [sequenceNumber ] = & mysql.BinlogCoordinates {LogPos : logPos , EventSize : eventSize }
510
506
@@ -522,7 +518,7 @@ func (c *Coordinator) MarkTransactionCompleted(sequenceNumber, logPos, eventSize
522
518
523
519
// Schedule any jobs that were waiting for this job to complete or for the low watermark
524
520
for waitingForSequenceNumber , channels := range c .waitingJobs {
525
- if waitingForSequenceNumber <= c .lowWaterMark || waitingForSequenceNumber == sequenceNumber {
521
+ if waitingForSequenceNumber <= c .lowWaterMark {
526
522
channelsToNotify = append (channelsToNotify , channels ... )
527
523
delete (c .waitingJobs , waitingForSequenceNumber )
528
524
}
0 commit comments