From 2d6ac6382b20989c22eb70130c78a1dd036cee66 Mon Sep 17 00:00:00 2001 From: vinllen Date: Wed, 6 May 2020 11:06:20 +0800 Subject: [PATCH] fix bug of isn't work in cascade replication scenario, see #277 --- ChangeLog | 4 ++++ src/redis-shake/dbSync/syncIncrease.go | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 74647183..9ed3559d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-05-06 Alibaba Cloud. + * VERSION: 2.0.2 + * BUGFIX: fix bug of `target.db` isn't work in cascade replication + scenario. see #277. 2020-05-02 Alibaba Cloud. * VERSION: 2.0.1 * IMPROVE: rebase v1.6.28. diff --git a/src/redis-shake/dbSync/syncIncrease.go b/src/redis-shake/dbSync/syncIncrease.go index e0138b60..67106c66 100644 --- a/src/redis-shake/dbSync/syncIncrease.go +++ b/src/redis-shake/dbSync/syncIncrease.go @@ -158,9 +158,19 @@ func (ds *DbSyncer) parseSourceCommand(reader *bufio.Reader) { // sendMarkId atomic2.Int64 // sendMarkId is also used as mark the sendId in sender routine ) - // if the start db id != 0, send dbid to the target at first + // if enable target.db + if conf.Options.TargetDB != -1 { + ds.startDbId = conf.Options.TargetDB + } + + /* + * if the start db id != 0, send dbid to the target at first. + * there're two cases that the statDbId != 0: + * 1. enable target.db. see #277. + * 2. start from resume-from-break-point + */ if ds.startDbId != 0 { - log.Infof("last dbid[%v] != 0, send 'select' first", ds.startDbId) + log.Infof("start dbid[%v] != 0, send 'select' first", ds.startDbId) dbS := fmt.Sprintf("%d", ds.startDbId) ds.sendBuf <- cmdDetail{ Cmd: "select",