Commit 1dedf9aa authored by antirez's avatar antirez
Browse files

Cluster: time field removed from cluster messages header.

The new algorithm does not check replies time as checking for the
currentEpoch in the reply ensures that the reply is about the current
election process.
parent 2b93a195
...@@ -1543,14 +1543,11 @@ void clusterRequestFailoverAuth(void) { ...@@ -1543,14 +1543,11 @@ void clusterRequestFailoverAuth(void) {
clusterBuildMessageHdr(hdr,CLUSTERMSG_TYPE_FAILOVER_AUTH_REQUEST); clusterBuildMessageHdr(hdr,CLUSTERMSG_TYPE_FAILOVER_AUTH_REQUEST);
totlen = sizeof(clusterMsg)-sizeof(union clusterMsgData); totlen = sizeof(clusterMsg)-sizeof(union clusterMsgData);
hdr->totlen = htonl(totlen); hdr->totlen = htonl(totlen);
hdr->time = mstime();
clusterBroadcastMessage(buf,totlen); clusterBroadcastMessage(buf,totlen);
} }
/* Send a FAILOVER_AUTH_ACK message to the specified node. /* Send a FAILOVER_AUTH_ACK message to the specified node. */
* Reqtime is the time field from the original failover auth request packet, void clusterSendFailoverAuth(clusterNode *node) {
* so that the receiver is able to check the reply age. */
void clusterSendFailoverAuth(clusterNode *node, uint64_t reqtime) {
unsigned char buf[4096]; unsigned char buf[4096];
clusterMsg *hdr = (clusterMsg*) buf; clusterMsg *hdr = (clusterMsg*) buf;
uint32_t totlen; uint32_t totlen;
...@@ -1559,7 +1556,6 @@ void clusterSendFailoverAuth(clusterNode *node, uint64_t reqtime) { ...@@ -1559,7 +1556,6 @@ void clusterSendFailoverAuth(clusterNode *node, uint64_t reqtime) {
clusterBuildMessageHdr(hdr,CLUSTERMSG_TYPE_FAILOVER_AUTH_ACK); clusterBuildMessageHdr(hdr,CLUSTERMSG_TYPE_FAILOVER_AUTH_ACK);
totlen = sizeof(clusterMsg)-sizeof(union clusterMsgData); totlen = sizeof(clusterMsg)-sizeof(union clusterMsgData);
hdr->totlen = htonl(totlen); hdr->totlen = htonl(totlen);
hdr->time = reqtime;
clusterSendMessage(node->link,buf,totlen); clusterSendMessage(node->link,buf,totlen);
} }
...@@ -1592,7 +1588,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) { ...@@ -1592,7 +1588,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) {
server.cluster_node_timeout * 2) return; server.cluster_node_timeout * 2) return;
/* We can vote for this slave. */ /* We can vote for this slave. */
clusterSendFailoverAuth(node,request->time); clusterSendFailoverAuth(node);
server.cluster->last_vote_epoch = server.cluster->currentEpoch; server.cluster->last_vote_epoch = server.cluster->currentEpoch;
node->slaveof->voted_time = server.unixtime; node->slaveof->voted_time = server.unixtime;
} }
......
...@@ -715,9 +715,6 @@ typedef struct { ...@@ -715,9 +715,6 @@ typedef struct {
uint32_t totlen; /* Total length of this message */ uint32_t totlen; /* Total length of this message */
uint16_t type; /* Message type */ uint16_t type; /* Message type */
uint16_t count; /* Only used for some kind of messages. */ uint16_t count; /* Only used for some kind of messages. */
uint64_t time; /* Time at which this request was sent (in milliseconds),
this field is copied in reply messages so that the
original sender knows how old the reply is. */
uint64_t currentEpoch; /* The epoch accordingly to the sending node. */ uint64_t currentEpoch; /* The epoch accordingly to the sending node. */
uint64_t configEpoch; /* The config epoch if it's a master, or the last epoch uint64_t configEpoch; /* The config epoch if it's a master, or the last epoch
advertised by its master if it is a slave. */ advertised by its master if it is a slave. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment