RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix Redis INFO memory reporting for Tair-compatible services (#19905)
Sourav Rajvi9e53ae49afd3
diff --git a/internal/engine/kvrocks/redis.go b/internal/engine/kvrocks/redis.goindex 5fad9219d3..673417edcf 100644--- a/internal/engine/kvrocks/redis.go+++ b/internal/engine/kvrocks/redis.go@@ -218,7 +218,7 @@ func (r *Client) Info(ctx context.Context) map[string]interface{} {"redis_version": info["redis_version"],"server_mode": getServerMode(info),"used_memory": info["used_memory_human"],- "total_system_memory": info["total_system_memory_human"],+ "total_system_memory": totalSystemMemoryHuman(info),"mem_fragmentation_ratio": info["mem_fragmentation_ratio"],"connected_clients": parseInt(info["connected_clients"]),"blocked_clients": parseInt(info["blocked_clients"]),@@ -235,6 +235,19 @@ func getServerMode(info map[string]string) string {return info["redis_mode"]}+// totalSystemMemoryHuman returns host RAM from INFO MEMORY when present.+// Managed Redis-compatible services (e.g. Alibaba Cloud Tair) may omit+// total_system_memory_human; fall back to maxmemory_human when configured.+func totalSystemMemoryHuman(info map[string]string) string {+ if v, ok := info["total_system_memory_human"]; ok && v != "" {+ return v+ }+ if v, ok := info["maxmemory_human"]; ok && v != "" {+ return v+ }+ return ""+}+func splitLines(s string) []string {var lines []stringstart := 0diff --git a/internal/engine/kvrocks/redis_test.go b/internal/engine/kvrocks/redis_test.goindex 77e9941ec4..28cbccdea5 100644--- a/internal/engine/kvrocks/redis_test.go+++ b/internal/engine/kvrocks/redis_test.go@@ -47,6 +47,45 @@ func newStrictTestClient(t *testing.T) (*Client, *miniredis.Miniredis) {}, mr}+func TestTotalSystemMemoryHuman(t *testing.T) {+ t.Parallel()+ cases := []struct {+ name string+ info map[string]string+ want string+ }{+ {+ name: "prefers total_system_memory_human",+ info: map[string]string{+ "total_system_memory_human": "16.00G",+ "maxmemory_human": "4.00G",+ },+ want: "16.00G",+ },+ {+ name: "falls back to maxmemory_human",+ info: map[string]string{+ "maxmemory_human": "4.00G",+ },+ want: "4.00G",+ },+ {+ name: "empty when neither field present",+ info: map[string]string{+ "used_memory_human": "128.00M",+ },+ want: "",+ },+ }+ for _, tc := range cases {+ t.Run(tc.name, func(t *testing.T) {+ if got := totalSystemMemoryHuman(tc.info); got != tc.want {+ t.Fatalf("totalSystemMemoryHuman() = %q, want %q", got, tc.want)+ }+ })+ }+}+// TestEvalTokenBucketStrict_AllowedThenDenied walks the bucket through// capacity=2, rate=0.1 (slow refill). Two calls should be allowed; the// third should be denied. This is the happy-path security gate.