Skip to content

Info command not parsable by Redis libraries in multi-master mode #231

@yegors

Description

@yegors

Describe the bug

Calling the info() method in various Redis libraries (tested with phpredis and predis) returns badly formatted data in the Replication block, pertaining to the states of the masters. The returned json object has same key names for all the masters, so the data is not consistent.

Example info data

IPs have been redacted

# Replication
role:active-replica
master_global_link_status:up
Master 0:
master_host:1.1.1.1
master_port:46379
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_repl_offset:75888348
Master 1:
master_host:2.2.2.2
master_port:46379
master_link_status:up
master_last_io_seconds_ago:7
master_sync_in_progress:0
slave_repl_offset:129232593
slave_priority:100
slave_read_only:0
connected_slaves:2
slave0:ip=1.1.1.1,port=46379,state=online,offset=136111194,lag=0
slave1:ip=2.2.2.2,port=46379,state=online,offset=136111194,lag=1
master_replid:e896a40eb36cac81946155542433b30456a2d778
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:136111194
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:268435456
repl_backlog_first_byte_offset:1

Parsed info data

{
  "role": "active-replica",
  "master_global_link_status": "up",
  "Master 0": " ",
  "master_host": "2.2.2.2",
  "master_port": "46379",
  "master_link_status": "up",
  "master_last_io_seconds_ago": "5",
  "master_sync_in_progress": "0",
  "slave_repl_offset": "129247755",
  "Master 1": " ",
  "slave_priority": "100",
  "slave_read_only": "0",
  "connected_slaves": "2",
  "slave0": "ip=1.1.1.1,port=46379,state=online,offset=136183546,lag=0",
  "slave1": "ip=2.2.2.2,port=46379,state=online,offset=136183546,lag=1",
  "master_replid": "e896a40eb36cac81946155542433b30456a2d778",
  "master_replid2": "0000000000000000000000000000000000000000",
  "master_repl_offset": "136183546",
  "second_repl_offset": "-1",
  "repl_backlog_active": "1",
  "repl_backlog_size": "268435456",
  "repl_backlog_first_byte_offset": "1",
  "repl_backlog_histlen": "136183546"
}

Notice the master_host, master_port, master_link_status, etc fields show the value of the last master in the list, which overwrites the values of those keys, because they are not namespaced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions