fix: Redis集群SCAN遍历所有master节点 + 查询结果布局调整\n\n1. ScanAllKeys(): 集群模式用ForEachMaster遍历所有master节点SCAN合并去重\n2. RedisScanKeys/KEYS命令均改用ScanAllKeys,确保集群不遗漏key\n3. QueriesPage布局: sidebar独立左侧,查询结果只在编辑器下方不被sidebar占据宽度

This commit is contained in:
logan committed 2026-05-30 15:28:38 +08:00
1 parent 430a667455
commit 4e6f9eb8fd
3 files changed
+97 -61

No files matched your search

+8 -18
View File
@@ -749,7 +749,7 @@ func executeRedisQuery(instance *model.Instance, dbSelect string, command string
args = append(args, p)
}
// For KEYS command, use SCAN with pagination (auto-append * if no wildcard)
// For KEYS command, use ScanAllKeys (cluster-aware) with pagination
if cmd == "KEYS" {
pattern := "*"
if len(parts) > 1 {
@@ -759,27 +759,17 @@ func executeRedisQuery(instance *model.Instance, dbSelect string, command string
if !strings.Contains(pattern, "*") && !strings.Contains(pattern, "?") && !strings.Contains(pattern, "[") {
pattern = pattern + "*"
}
var allKeys []string
cursor := uint64(0)
maxScan := offset + limit
for {
keys, nextCursor, err := client.Scan(ctx, cursor, pattern, int64(maxScan-len(allKeys))).Result()
if err != nil {
return nil, fmt.Errorf("SCAN failed: %v", err)
}
allKeys = append(allKeys, keys...)
cursor = nextCursor
if cursor == 0 || len(allKeys) >= maxScan {
break
}
allKeys, err := client.ScanAllKeys(ctx, pattern, limit+offset)
if err != nil {
return nil, fmt.Errorf("SCAN failed: %v", err)
}
total := len(allKeys)
end := offset + limit
if end > len(allKeys) {
end = len(allKeys)
if end > total {
end = total
}
if offset > len(allKeys) {
offset = len(allKeys)
if offset > total {
offset = total
}
pagedKeys := allKeys[offset:end]
rows := make([]interface{}, len(pagedKeys))