From cc226f841e2e244c48246ebfcfd5a50396b59710 Mon Sep 17 00:00:00 2001 From: chenyang8094 Date: Fri, 3 Sep 2021 09:56:59 +0800 Subject: [PATCH] Fix target db select bug (#370) --- src/redis-shake/dbSync/syncIncrease.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/redis-shake/dbSync/syncIncrease.go b/src/redis-shake/dbSync/syncIncrease.go index ac217a2..de51dec 100644 --- a/src/redis-shake/dbSync/syncIncrease.go +++ b/src/redis-shake/dbSync/syncIncrease.go @@ -149,6 +149,7 @@ func (ds *DbSyncer) receiveTargetReply(c redigo.Conn) { func (ds *DbSyncer) parseSourceCommand(reader *bufio.Reader) { var ( lastDb = -1 + selectDB = -1 bypass = false isSelect = false sCmd string @@ -198,7 +199,7 @@ func (ds *DbSyncer) parseSourceCommand(reader *bufio.Reader) { } bypass = filter.FilterDB(n) isSelect = true - lastDb = n + selectDB = n } else if filter.FilterCommands(sCmd) { ignoreCmd = true } else if strings.EqualFold(sCmd, "publish") && strings.EqualFold(string(argv[0]), "__sentinel__:hello") { @@ -239,7 +240,7 @@ func (ds *DbSyncer) parseSourceCommand(reader *bufio.Reader) { metric.GetMetric(ds.id).AddBypassCmdCount(ds.id, 1) } continue - } else if tdb, ok := conf.Options.TargetDBMap[int(lastDb)]; ok { + } else if tdb, ok := conf.Options.TargetDBMap[int(selectDB)]; ok { if tdb != lastDb { lastDb = tdb /* send select command. */