Skip to content

Commit 292c358

Browse files
author
ffffwh
committed
relay: update BinlogFile/Pos along with Gtid
when full copy done on applier.
1 parent 5283fa2 commit 292c358

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

internal/client/driver/mysql/applier.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ func (a *Applier) executeWriteFuncs() {
451451
a.logger.Printf("mysql.applier: Rows copy complete.number of rows:%d", a.mysqlContext.TotalRowsReplay)
452452
a.mysqlContext.Gtid = a.currentCoordinates.RetrievedGtidSet
453453
a.mysqlContext.BinlogFile = a.currentCoordinates.File
454+
a.mysqlContext.BinlogPos = a.currentCoordinates.Position
454455
break
455456
}
456457
if a.shutdown {
@@ -901,6 +902,9 @@ func (a *Applier) initiateStreaming() error {
901902
a.onError(TaskStateDead, err)
902903
}
903904
a.currentCoordinates.RetrievedGtidSet = dumpData.Gtid
905+
a.currentCoordinates.File = dumpData.LogFile
906+
a.currentCoordinates.Position = dumpData.LogPos
907+
904908
a.mysqlContext.Stage = models.StageSlaveWaitingForWorkersToProcessQueue
905909

906910
for atomic.LoadInt64(&a.nDumpEntry) != 0 {

internal/client/driver/mysql/dumper.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ func NewDumper(db usql.QueryAble, table *config.Table, chunkSize int64,
8181
type dumpStatResult struct {
8282
Gtid string
8383
TotalCount int64
84+
LogFile string
85+
LogPos int64
8486
}
8587

8688
type DumpEntryOrig struct {

internal/client/driver/mysql/extractor.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,12 @@ func (e *Extractor) Run() {
294294
e.onError(TaskStateDead, err)
295295
return
296296
}
297-
dumpMsg, err := Encode(&dumpStatResult{Gtid: e.initialBinlogCoordinates.GtidSet, TotalCount: e.mysqlContext.RowsEstimate})
297+
dumpMsg, err := Encode(&dumpStatResult{
298+
Gtid: e.initialBinlogCoordinates.GtidSet,
299+
LogFile: e.initialBinlogCoordinates.LogFile,
300+
LogPos: e.initialBinlogCoordinates.LogPos,
301+
TotalCount: e.mysqlContext.RowsEstimate,
302+
})
298303
if err != nil {
299304
e.onError(TaskStateDead, err)
300305
}

0 commit comments

Comments
 (0)