From 6e1e84db00add9e1025aeb7249a504f62e1b47c2 Mon Sep 17 00:00:00 2001 From: sjcsjc123 <1401189096@qq.com> Date: Fri, 12 Jan 2024 16:52:47 +0800 Subject: [PATCH 1/2] fix bug with repeat key Signed-off-by: sjcsjc123 <1401189096@qq.com> --- tools/pika_keys_analysis/pika.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/pika_keys_analysis/pika.go b/tools/pika_keys_analysis/pika.go index 47a7cf5eaf..aaec62ceb1 100644 --- a/tools/pika_keys_analysis/pika.go +++ b/tools/pika_keys_analysis/pika.go @@ -57,6 +57,7 @@ func SolveSingleClient(client *redis.Client, ctx context.Context, wg *sync.WaitG defer func() { <-goroutineCh }() + fmt.Println("当前游标:" + fmt.Sprintf("%d", curCursor)) keys, _, err := client.Scan(ctx, uint64(curCursor), "*", int64(ScanSize)).Result() if err != nil { _ = fmt.Errorf("scan error: %s", err) @@ -93,6 +94,7 @@ func SolveSingleClient(client *redis.Client, ctx context.Context, wg *sync.WaitG usedSize += int64(len(v.Member.(string)) + 8) } } + fmt.Println("localHeapMap发生变化,此时的游标为:" + fmt.Sprintf("%d", curCursor)) localHeapMap[dataType].Add(KeyWithMemory{ Key: key, UsedSize: usedSize, @@ -101,6 +103,8 @@ func SolveSingleClient(client *redis.Client, ctx context.Context, wg *sync.WaitG } } }(cursor) + cursor += int64(ScanSize) + start = true keys, _, err := client.Scan(ctx, uint64(cursor), "*", 1).Result() if err != nil { _ = fmt.Errorf("scan error: %s", err) @@ -111,8 +115,6 @@ func SolveSingleClient(client *redis.Client, ctx context.Context, wg *sync.WaitG break } } - cursor += int64(ScanSize) - start = true } fmt.Printf("Current client %s done, waiting for task to finish\n", client) wgClient.Wait() From 73720cb2c1f66b60f6360b93a2cbab2cd2884159 Mon Sep 17 00:00:00 2001 From: sjcsjc123 <1401189096@qq.com> Date: Fri, 12 Jan 2024 16:54:02 +0800 Subject: [PATCH 2/2] fix bug with repeat key Signed-off-by: sjcsjc123 <1401189096@qq.com> --- tools/pika_keys_analysis/pika.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/pika_keys_analysis/pika.go b/tools/pika_keys_analysis/pika.go index aaec62ceb1..72003a53bc 100644 --- a/tools/pika_keys_analysis/pika.go +++ b/tools/pika_keys_analysis/pika.go @@ -57,7 +57,6 @@ func SolveSingleClient(client *redis.Client, ctx context.Context, wg *sync.WaitG defer func() { <-goroutineCh }() - fmt.Println("当前游标:" + fmt.Sprintf("%d", curCursor)) keys, _, err := client.Scan(ctx, uint64(curCursor), "*", int64(ScanSize)).Result() if err != nil { _ = fmt.Errorf("scan error: %s", err) @@ -94,7 +93,6 @@ func SolveSingleClient(client *redis.Client, ctx context.Context, wg *sync.WaitG usedSize += int64(len(v.Member.(string)) + 8) } } - fmt.Println("localHeapMap发生变化,此时的游标为:" + fmt.Sprintf("%d", curCursor)) localHeapMap[dataType].Add(KeyWithMemory{ Key: key, UsedSize: usedSize,