gregoriusxu / booksleeve

Automatically exported from code.google.com/p/booksleeve
Other
0 stars 0 forks source link

Redis INFO command results output has changed (comments and empty lines added in 2.6 unstable) #15

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Redis INFO command output has changed (in 2.6: not every result line is data, 
comments and spaces have been added). 

At connect time Booksleeve checks for redis_version and therefore executes 
redis INFO command that is parsed using ParseInfo.

Solution:
In BookSleeve.RedisConnectionBase in ParseInfo() at around line 238 we have to 
check that we have real INFO data and not comment or empty line.. Every useful 
result has ":" in it.

change from:
  int idx = line.IndexOf(':');
  data.Add(line.Substring(0, idx), line.Substring(idx + 1));

to:
  int idx = line.IndexOf(':');
  if (idx > 0)    //added, since redis 2.6 has commented INFO with groups that start with hash for example: # Clients,... #Stats...
  {
      data.Add(line.Substring(0, idx), line.Substring(idx + 1));
  }

Details of problem (analysis of INFO output format changes):

#OLD REDIS INFO FORMAT (used in 2.4)
redis 127.0.0.1:6379> info
redis_version:2.4.6
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.3
process_id:1995
uptime_in_seconds:116813
uptime_in_days:1
lru_clock:810806
used_cpu_sys:13.16
used_cpu_user:8.88
used_cpu_sys_children:0.12
used_cpu_user_children:0.28
connected_clients:9
connected_slaves:0
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
used_memory:807784
used_memory_human:788.85K
used_memory_rss:1159168
used_memory_peak:807888
used_memory_peak_human:788.95K
mem_fragmentation_ratio:1.43
mem_allocator:jemalloc-2.2.5
loading:0
aof_enabled:0
changes_since_last_save:12
bgsave_in_progress:0
last_save_time:1329313804
bgrewriteaof_in_progress:0
total_connections_received:11693
total_commands_processed:65180
expired_keys:0
evicted_keys:0
keyspace_hits:53487
keyspace_misses:5
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:263
vm_enabled:0
role:master
db0:keys=4,expires=0
db4:keys=1,expires=0

#NEW REDIS INFO FORMAT (used in 2.6)
redis 127.0.0.1:6379> info
# Server
redis_version:2.9.3
redis_git_sha1:5e985e79
redis_git_dirty:0
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.3
process_id:14853
tcp_port:6379
uptime_in_seconds:9416
uptime_in_days:0
lru_clock:810811

# Clients
connected_clients:14
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:1395536
used_memory_human:1.33M
used_memory_rss:2412544
used_memory_peak:1415832
used_memory_peak_human:1.35M
used_memory_lua:24576
mem_fragmentation_ratio:1.73
mem_allocator:jemalloc-2.2.5

# Persistence
loading:0
aof_enabled:0
changes_since_last_save:0
bgsave_in_progress:0
last_save_time:1329313812
bgrewriteaof_in_progress:0

# Stats
total_connections_received:2767
total_commands_processed:32715
rejected_connections:0
expired_keys:0
evicted_keys:0
keyspace_hits:244
keyspace_misses:544
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:244

# Replication
role:slave
master_host:192.168.1.52
master_port:6379
master_link_status:up
master_last_io_seconds_ago:1
master_sync_in_progress:0
connected_slaves:0

# CPU
used_cpu_sys:0.76
used_cpu_user:0.95
used_cpu_sys_children:0.00
used_cpu_user_children:0.31

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=236,expires=0

---------------------------------------------

Original issue reported on code.google.com by mark.v...@gmail.com on 15 Feb 2012 at 2:16

GoogleCodeExporter commented 8 years ago
I have a fix for this in my repo.
I've attached patch

Original comment by johanalk...@gmail.com on 2 Apr 2012 at 7:08

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks. I'm away for a few days - will look at patch when Iget back. Much 
obliged.

Original comment by marc.gravell on 2 Apr 2012 at 8:15

GoogleCodeExporter commented 8 years ago
Committed now, thanks

Original comment by marc.gravell on 12 Apr 2012 at 1:19