1. 26 6月, 2014 2 次提交
    • M
      Cluster: Add CLUSTER SLOTS command · 237188bf
      Matt Stancliff 提交于
      CLUSTER SLOTS returns a Redis-formatted mapping from
      slot ranges to IP/Port pairs serving that slot range.
      
      The outer return elements group return values by slot ranges.
      
      The first two entires in each result are the min and max slots for the range.
      
      The third entry in each result is guaranteed to be either
      an IP/Port of the master for that slot range - OR - null
      if that slot range, for some reason, has no master
      
      The 4th and higher entries in each result are replica instances
      for the slot range.
      
      Output comparison:
      127.0.0.1:7001> cluster nodes
      f853501ec8ae1618df0e0f0e86fd7abcfca36207 127.0.0.1:7001 myself,master - 0 0 2 connected 4096-8191
      5a2caa782042187277647661ffc5da739b3e0805 127.0.0.1:7005 slave f853501ec8ae1618df0e0f0e86fd7abcfca36207 0 1402622415859 6 connected
      6c70b49813e2ffc9dd4b8ec1e108276566fcf59f 127.0.0.1:7007 slave 26f4729ca0a5a992822667fc16b5220b13368f32 0 1402622415357 8 connected
      2bd5a0e3bb7afb2b56a2120d3fef2f2e4333de1d 127.0.0.1:7006 slave 32adf4b8474fdc938189dba00dc8ed60ce635b0f 0 1402622419373 7 connected
      5a9450e8279df36ff8e6bb1c139ce4d5268d1390 127.0.0.1:7000 master - 0 1402622418872 1 connected 0-4095
      32adf4b8474fdc938189dba00dc8ed60ce635b0f 127.0.0.1:7002 master - 0 1402622419874 3 connected 8192-12287
      5db7d05c245267afdfe48c83e7de899348d2bdb6 127.0.0.1:7004 slave 5a9450e8279df36ff8e6bb1c139ce4d5268d1390 0 1402622417867 5 connected
      26f4729ca0a5a992822667fc16b5220b13368f32 127.0.0.1:7003 master - 0 1402622420877 4 connected 12288-16383
      
      127.0.0.1:7001> cluster slots
      1) 1) (integer) 0
         2) (integer) 4095
         3) 1) "127.0.0.1"
            2) (integer) 7000
         4) 1) "127.0.0.1"
            2) (integer) 7004
      2) 1) (integer) 12288
         2) (integer) 16383
         3) 1) "127.0.0.1"
            2) (integer) 7003
         4) 1) "127.0.0.1"
            2) (integer) 7007
      3) 1) (integer) 4096
         2) (integer) 8191
         3) 1) "127.0.0.1"
            2) (integer) 7001
         4) 1) "127.0.0.1"
            2) (integer) 7005
      4) 1) (integer) 8192
         2) (integer) 12287
         3) 1) "127.0.0.1"
            2) (integer) 7002
         4) 1) "127.0.0.1"
            2) (integer) 7006
      237188bf
    • A
      Cluster: myself->ip autodiscovery. · 8fdc857a
      antirez 提交于
      Instead of having an hardcoded IP address in the node configuration, we
      autodiscover it via MEET messages for automatic update when the node is
      restarted with a different IP address.
      
      This mechanism was discussed in the context of PR #1782.
      8fdc857a
  2. 23 6月, 2014 1 次提交
  3. 21 6月, 2014 7 次提交
  4. 07 6月, 2014 2 次提交
    • A
      Cluster: check that configEpoch never goes back. · 8b059f06
      antirez 提交于
      Since there are ways to alter the configEpoch outside of the failover
      procedure (for exampel CLUSTER SET-CONFIG-EPOCH and via the configEpoch
      collision resolution algorithm), make always sure, before replacing our
      configEpoch with a new one, that it is greater than the current one.
      8b059f06
    • A
      Cluster: SET-CONFIG-EPOCH should update currentEpoch. · 67029323
      antirez 提交于
      SET-CONFIG-EPOCH, used by redis-trib at cluster creation time, failed to
      update the currentEpoch, making it possible after a failover for a
      server to set its configEpoch to a value smaller than the current one
      (since configEpochs are obtained using currentEpoch).
      
      The bug totally break the Redis Cluster algorithms and protocols
      allowing for permanent split brain conditions about the slots
      configuration as shown in issue #1799.
      67029323
  5. 26 5月, 2014 1 次提交
  6. 23 5月, 2014 1 次提交
  7. 20 5月, 2014 10 次提交
    • A
      Cluster: use clusterSetNodeAsMaster() during slave failover. · 8c6e8680
      antirez 提交于
      clusterHandleSlaveFailover() was reimplementing what
      clusterSetNodeAsMaster() without any good reason.
      8c6e8680
    • A
      Cluster: clear todo_before_sleep flags when executing actions. · 41a72416
      antirez 提交于
      Thanks to this change, when there is some code like:
      
          clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE|...);
          ... and later before returning to the event loop ...
          clusterUpdateState();
      
      The clusterUpdateState() function will clar the flag and will not be
      repeated in the clusterBeforeSleep() function. This especially important
      for config save/fsync flags which are slow to execute and not a good
      idea to repeat without a good reason.
      
      This is implemented for all the CLUSTER_TODO flags.
      41a72416
    • A
      Fixed typo in CLUSTER RESET implementation. · 5685d15a
      antirez 提交于
      5685d15a
    • A
      CLUSTER RESET implemented. · 5efa5501
      antirez 提交于
      The new command is able to reset a cluster node so that it starts again
      as a fresh node. By default the command performs a soft reset (the same
      as calling it as CLUSTER RESET SOFT), and the following steps are
      performed:
      
      1) All slots are set as unassigned.
      2) The list of known nodes is flushed.
      3) Node is set as master if it is a slave.
      
      When an hard reset is performed with CLUSTER RESET HARD the following
      additional operations are performed:
      
      4) A new Node ID is created at random.
      5) Epochs are set to 0.
      
      CLUSTER RESET is useful both when the sysadmin wants to reconfigure a
      node with a different role (for example turning a slave into a master)
      and for testing purposes.
      
      It also may play a role in automatically provisioned Redis Clusters,
      since it allows to reset a node back to the initial state in order to be
      reconfigured.
      5efa5501
    • A
      Remove trailing spaces from cluster.c file. · 687f84a3
      antirez 提交于
      687f84a3
    • A
      be159490
    • A
      Cluster: better handling of stolen slots. · b8a71e5a
      antirez 提交于
      The previous code handling a lost slot (by another master with an higher
      configuration for the slot) was defensive, considering it an error and
      putting the cluster in an odd state requiring redis-cli fix.
      
      This was changed, because actually this only happens either in a
      legitimate way, with failovers, or when the admin messed with the config
      in order to reconfigure the cluster. So the new code instead will try to
      make sure that the keys stored match the new slots map, by removing all
      the keys in the slots we lost ownership from.
      
      The function that deletes the keys from the lost slots is called only
      if the node does not lose all its slots (resulting in a reconfiguration
      as a slave of the node that got ownership). This is an optimization
      since the replication code will anyway flush all the instance data in
      a faster way.
      b8a71e5a
    • A
      e10ee072
    • A
      Cluster: forced failover implemented. · e84dcabf
      antirez 提交于
      Using CLUSTER FAILOVER FORCE it is now possible to failover a master in
      a forced way, which means:
      
      1) No check to understand if the master is up is performed.
      2) No data age of the slave is checked. Evan a slave with very old data
         can manually failover a master in this way.
      3) No chat with the master is attempted to reach its replication offset:
         the master can just be down.
      e84dcabf
    • A
      Cluster: bypass data_age check for manual failovers. · b5cdd42b
      antirez 提交于
      Automatic failovers only happen in Redis Cluster if the slave trying to
      be elected was disconnected from its master for no more than 10 times
      the node-timeout value. However there should be no such a check for
      manual failovers, since these are initiated by the sysadmin that, in
      theory, knows what she is doing when a slave is selected to be promoted.
      b5cdd42b
  8. 12 5月, 2014 2 次提交
  9. 09 5月, 2014 2 次提交
  10. 05 5月, 2014 1 次提交
    • A
      CLUSTER SET-CONFIG-EPOCH implemented. · c4c7389f
      antirez 提交于
      Initially Redis Cluster accepted that after cluster creation all the
      nodes were at configEpoch 0, evolving from zero as failovers happen.
      
      However later the semantic was made more strict in order to make sure a
      cluster has always all the master nodes with a different configEpoch,
      which is more robust in some corner case (especially resulting from
      errors by the system administrator).
      
      To assign different configEpochs to different nodes at startup was a
      task performed naturally by the config conflicts resolution algorithm
      (see the Cluster specification). However this works well only for small
      clusters or when there are actually just a few collisions, since it is
      designed for exceptional cases.
      
      When a large cluster is created hundred of nodes can be at epoch 0, so
      the conflict resolution code is slow to provide an unique config to each
      node. For this reason this new command was introduced. It can be called
      only when a node is totally fresh: no other nodes known, and configEpoch
      set to zero, so it is safe even against misuses.
      
      redis-trib will use the new command in order to start the cluster
      already setting an incremental unique config to every node.
      c4c7389f
  11. 29 4月, 2014 2 次提交
    • A
      clusterLoadConfig() REDIS_ERR retval semantics refined. · b008863e
      antirez 提交于
      We should return REDIS_ERR to signal we can't read the configuration
      because there is no config file only after checking errno, othewise
      we risk to rewrite an existing file that was not accessible for some
      other reason.
      b008863e
    • A
      Lock nodes.conf to avoid multiple processes using the same file. · 71d71814
      antirez 提交于
      This was a common source of problems among users.
      The solution adopted is not bullet-proof as if the user deletes the
      nodes.conf file manually, and starts a new instance with the same
      nodes.conf file path, two instances will use the same file. However
      following this reasoning the user may drop a nuclear bomb into the
      datacenter as well.
      71d71814
  12. 23 4月, 2014 1 次提交
  13. 16 4月, 2014 8 次提交