summaryrefslogtreecommitdiff
path: root/src/cluster.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Two cluster.c comments improved.antirez2015-03-211-2/+3
|
* Cluster: TAKEOVER option for manual failover.antirez2015-03-211-7/+20
|
* Cluster: non-conditional steps of slave failover refactored into a function.antirez2015-03-201-27/+40
|
* Cluster: separate unknown master check from the rest.antirez2015-03-201-2/+5
| | | | | In no case we should try to attempt to failover if myself->slaveof is NULL.
* Cluster: refactoring around configEpoch handling.antirez2015-03-201-124/+157
| | | | | | | | | | | | This commit moves the process of generating a new config epoch without consensus out of the clusterCommand() implementation, in order to make it reusable for other reasons (current target is to have a CLUSTER FAILOVER option forcing the failover when no master majority is reachable). Moreover the commit moves other functions which are similarly related to config epochs in a new logical section of the cluster.c file, just for clarity.
* Cluster: better cluster state transiction handling.antirez2015-03-201-2/+18
| | | | | | | | | | | | | | | | | Before we relied on the global cluster state to make sure all the hash slots are linked to some node, when getNodeByQuery() is called. So finding the hash slot unbound was checked with an assertion. However this is fragile. The cluster state is often updated in the clusterBeforeSleep() function, and not ASAP on state change, so it may happen to process clients with a cluster state that is 'ok' but yet certain hash slots set to NULL. With this commit the condition is also checked in getNodeByQuery() and reported with a identical error code of -CLUSTERDOWN but slightly different error message so that we have more debugging clue in the future. Root cause of issue #2288.
* Cluster: more robust slave check in CLUSTER REPLICATE.antirez2015-03-181-1/+1
| | | | | There are rare conditions where node->slaveof may be NULL even if the node is a slave. To check by flag is much more robust.
* Cluster: fix CLUSTER NODES optimization error in 'j' increment.antirez2015-03-131-1/+1
|
* Cluster: CLUSTER NODES speedup.antirez2015-03-131-16/+32
|
* Add command CLUSTER MYIDMichel Martens2015-03-101-0/+3
|
* Migrate: replace conditional with pre-computed value.antirez2015-02-271-1/+1
|
* Improvements to PR #2425antirez2015-02-261-10/+10
| | | | | | | | 1. Remove useless "cs" initialization. 2. Add a "select" var to capture a condition checked multiple times. 3. Avoid duplication of the same if (!copy) conditional. 4. Don't increment dirty if copy is given (no deletion is performed), otherwise we propagate MIGRATE when not needed.
* Add last_dbid to migrateCachedSocket to avoid redundant SELECTTommy Wang2015-02-261-23/+36
| | | | | Avoid redundant SELECT calls when continuously migrating keys to the same dbid within a target Redis instance.
* Merge pull request #2301 from mattsta/fix/lengthsSalvatore Sanfilippo2015-02-241-1/+1
|\ | | | | Improve type correctness
| * Improve networking type correctnessMatt Stancliff2015-01-191-1/+1
| | | | | | | | | | | | | | | | read() and write() return ssize_t (signed long), not int. For other offsets, we can use the unsigned size_t type instead of a signed offset (since our replication offsets and buffer positions are never negative).
* | Cluster: some bias towwards FAIL/PFAIL nodes in gossip sections.antirez2015-01-301-3/+6
| | | | | | | | | | | | | | | | | | This improves PFAIL -> FAIL switch. Too late at this point in the RC releases to add proper PFAIL/FAIL separate dictionary to do this in a less randomized way. Tested in practice with experiments that this helps. PFAIL -> FAIL average with 20 nodes and node-timeout set to 5 seconds takes 2.5 seconds without this commit, 1 second with this commit.
* | More correct wanted / maxiterations values in clusterSendPing().antirez2015-01-301-2/+6
| |
* | Cluster: magical 10% of nodes explained in comments.antirez2015-01-291-2/+26
| |
* | CLUSTER count-failure-reports command added.antirez2015-01-291-0/+12
| |
* | Cluster: use a number of gossip sections proportional to cluster size.antirez2015-01-291-17/+42
| | | | | | | | | | | | | | | | | | | | | | Otherwise it is impossible to receive the majority of failure reports in the node_timeout*2 window in larger clusters. Still with a 200 nodes cluster, 20 gossip sections are a very reasonable amount of bytes to send. A side effect of this change is also fater cluster nodes joins for large clusters, because the cluster layout makes less time to propagate.
* | Cluster: initialized not used fileds in gossip section.antirez2015-01-241-0/+2
| | | | | | | | | | | | | | | | Otherwise we risk sending not initialized data to other nodes, that may contain anything. This was actually not possible only because the initialization of the buffer where the cluster packets header is created was larger than the 3 gossip sections we use, so the memory was already all filled with zeroes by the memset().
* | Fix cluster migrate memory leakMatt Stancliff2015-01-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes valgrind error: 48 bytes in 1 blocks are definitely lost in loss record 196 of 373 at 0x4910D3: je_malloc (jemalloc.c:944) by 0x42807D: zmalloc (zmalloc.c:125) by 0x41FA0D: dictGetIterator (dict.c:543) by 0x41FA48: dictGetSafeIterator (dict.c:555) by 0x459B73: clusterHandleSlaveMigration (cluster.c:2776) by 0x45BF27: clusterCron (cluster.c:3123) by 0x423344: serverCron (redis.c:1239) by 0x41D6CD: aeProcessEvents (ae.c:311) by 0x41D8EA: aeMain (ae.c:455) by 0x41A84B: main (redis.c:3832)
* | Fix potential invalid read past end of arrayMatt Stancliff2015-01-211-2/+5
| | | | | | | | | | | | | | If array has N elements, we can't read +1 if we are already at N. Also, we need to move elements by their storage size in the array, not just by individual bytes.
* | Fix cluster reset memory leakMatt Stancliff2015-01-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [maybe] Fixes valgrind errors: 32 bytes in 4 blocks are definitely lost in loss record 107 of 228 at 0x80EA447: je_malloc (jemalloc.c:944) by 0x806E59C: zrealloc (zmalloc.c:125) by 0x80A9AFC: clusterSetMaster (cluster.c:801) by 0x80AEDC9: clusterCommand (cluster.c:3994) by 0x80682A5: call (redis.c:2049) by 0x8068A20: processCommand (redis.c:2309) by 0x8076497: processInputBuffer (networking.c:1143) by 0x8073BAF: readQueryFromClient (networking.c:1208) by 0x8060E98: aeProcessEvents (ae.c:412) by 0x806123B: aeMain (ae.c:455) by 0x806C3DB: main (redis.c:3832) 64 bytes in 8 blocks are definitely lost in loss record 143 of 228 at 0x80EA447: je_malloc (jemalloc.c:944) by 0x806E59C: zrealloc (zmalloc.c:125) by 0x80AAB40: clusterProcessPacket (cluster.c:801) by 0x80A847F: clusterReadHandler (cluster.c:1975) by 0x30000FF: ??? 80 bytes in 10 blocks are definitely lost in loss record 148 of 228 at 0x80EA447: je_malloc (jemalloc.c:944) by 0x806E59C: zrealloc (zmalloc.c:125) by 0x80AAB40: clusterProcessPacket (cluster.c:801) by 0x80A847F: clusterReadHandler (cluster.c:1975) by 0x2FFFFFF: ???
* | Fix sending uninitialized bytesMatt Stancliff2015-01-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes valgrind error: Syscall param write(buf) points to uninitialised byte(s) at 0x514C35D: ??? (syscall-template.S:81) by 0x456B81: clusterWriteHandler (cluster.c:1907) by 0x41D596: aeProcessEvents (ae.c:416) by 0x41D8EA: aeMain (ae.c:455) by 0x41A84B: main (redis.c:3832) Address 0x5f268e2 is 2,274 bytes inside a block of size 8,192 alloc'd at 0x4932D1: je_realloc (jemalloc.c:1297) by 0x428185: zrealloc (zmalloc.c:162) by 0x4269E0: sdsMakeRoomFor.part.0 (sds.c:142) by 0x426CD7: sdscatlen (sds.c:251) by 0x4579E7: clusterSendMessage (cluster.c:1995) by 0x45805A: clusterSendPing (cluster.c:2140) by 0x45BB03: clusterCron (cluster.c:2944) by 0x423344: serverCron (redis.c:1239) by 0x41D6CD: aeProcessEvents (ae.c:311) by 0x41D8EA: aeMain (ae.c:455) by 0x41A84B: main (redis.c:3832) Uninitialised value was created by a stack allocation at 0x457810: nodeUpdateAddressIfNeeded (cluster.c:1236)
* | Cluster: node deletion cleanup / centralization.antirez2015-01-211-13/+20
| |
* | Cluster: set the slaves->slaveof filed to NULL when master is freed.antirez2015-01-211-0/+8
|/ | | | Related to issue #2289.
* Cluster: fetch my IP even if msg is not MEET for the first time.antirez2015-01-131-5/+7
| | | | | | | | | | | | In order to avoid that misconfigured cluster nodes at some time may force an IP update on other nodes, it is required that nodes update their own address only on MEET messages. However it does not make sense to do this the first time a node is contacted and yet does not have an IP, we just risk that myself->ip remains not assigned if there are messages lost or cluster creation procedures that don't make sure everybody is targeted by at least one incoming MEET message. Also fix the logging of the IP switch avoiding the :-1 tail.
* Cluster: clusterMsgDataGossip structure, explict padding + minor stuff.antirez2015-01-131-1/+3
| | | | | | | | | | Also explicitly set version to 0, add a protocol version define, improve comments in the gossip structure. Note that the structure layout is the same after the change, we are just making the padding explicit with an additional not used 16 bits field. So this commit is still able to talk with the previous versions of cluster nodes.
* Suppress valgrind error about write sending uninitialized data.antirez2015-01-131-0/+1
| | | | | | | Valgrind checks that the buffers we transfer via syscalls are all composed of bytes actually initialized. This is useful, it makes we able to avoid leaking informations in non initialized parts fo messages transferred to other hosts. This commit fixes one of such issues.
* Cluster: initialize mf_end.antirez2015-01-121-0/+1
| | | | | | | Can't be initialized by resetManualFailover() since it's actual state the function uses, so we need to initialize it at startup time. Not really a bug in practical terms, but showed up into valgrind and is not technically correct anyway.
* Add addReplyBulkSds() functionMatt Stancliff2014-12-231-4/+1
| | | | | Refactor a common pattern into one function so we don't end up with copy/paste programming.
* Cluster: Notify user on accept errorMatt Stancliff2014-12-171-1/+1
| | | | | | | | If we woke up to accept a connection, but we can't accept it, inform the user of the error going on with their networking. (The previous message was the same for success or error!)
* Fix comment in clusterHandleSlaveFailover().antirez2014-12-161-1/+1
|
* Make sure buffer is enough in clusterSendPing().antirez2014-12-151-1/+1
|
* AnetFormatIP(): renamed, commented, now sticks to IP:port format.antirez2014-12-111-1/+1
| | | | | A few code style changes + consistent format: not nice for humans but better for parsers.
* Cleanup all IP formatting codeMatt Stancliff2014-12-111-1/+3
| | | | | Instead of manually checking for strchr(n,':') everywhere, we can use our new centralized IP formatting functions.
* Better read-only behavior for expired keys in slaves.antirez2014-12-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Slaves key expire is orchestrated by the master. Sometimes the master will send the synthesized DEL to expire keys on the slave with a non trivial delay (when the key is not accessed, only the incremental expiry algorithm will expire it in background). During that time, a key is logically expired, but slaves still return the key if you GET (or whatever) it. This is a bad behavior. However we can't simply trust the slave view of the key, since we need the master to be able to send write commands to update the slave data set, and DELs should only happen when the key is expired in the master in order to ensure consistency. However 99.99% of the issues with this behavior is when a client which is not a master sends a read only command. In this case we are safe and can consider the key as non existing. This commit does a few changes in order to make this sane: 1. lookupKeyRead() is modified in order to return NULL if the above conditions are met. 2. Calls to lookupKeyRead() in commands actually writing to the data set are repliaced with calls to lookupKeyWrite(). There are redundand checks, so for example, if in "2" something was overlooked, we should be still safe, since anyway, when the master writes the behavior is to don't care about what expireIfneeded() returns. This commit is related to #1768, #1770, #2131.
* Cluster PUBLISH message: fix totlen count.antirez2014-11-281-2/+3
| | | | | | bulk_data field size was not removed from the count. It is not possible to declare it simply as 'char bulk_data[]' since the structure is nested into another structure.
* Merge pull request #2096 from mattsta/cluster-ipv6Salvatore Sanfilippo2014-10-311-1/+1
|\ | | | | Enable Cluster IPv6 Support
| * Parse cluster state file in IPv6 compatible wayMatt Stancliff2014-10-291-1/+1
| | | | | | | | We need to pick the port based on the _last_ colon, not the first one.
* | Networking: add more outbound IP binding fixesMatt Stancliff2014-10-291-2/+2
|/ | | | | | | | | | | Same as the original bind fixes (we just missed these the first time around). This helps Redis not automatically send connections from the first IP on an interface if we are bound to a specific IP address (e.g. with multiple IP aliases on one interface, you want to send from _your_ IP, not from the first IP on the interface).
* Cluster: process gossip section only for known nodes.antirez2014-10-081-5/+8
| | | | | | With the exception of nodes sending MEET packets: we have to trust them since they can send us MEET packets only when the cluster is initially created or because sysadmin manual action.
* Cluster: fix logic to detect we are among a minority.antirez2014-10-081-9/+8
| | | | | | | In the cluster evaluation function we are supposed to set the cluster state as "fail" if we are among a minority, however the code was not detecting to be into a minority partition if exactly half the masters were reachable, which is a minority.
* Cluster: more chatty slaves when failover is stalled.antirez2014-10-071-4/+84
|
* Clean up text throughout projectMatt Stancliff2014-09-291-13/+13
| | | | | | | | | | - Remove trailing newlines from redis.conf - Fix comment misspelling - Clarifies zipEncodeLength usage and a C API mention (#1243, #1242) - Fix cluster typos (inspired by @papanikge #1507) - Fix rewite -> rewrite in a few places (inspired by #682) Closes #1243, #1242, #1507
* Cluster: claim ping_sent time even if we can't connect.antirez2014-09-171-0/+6
| | | | | | | | | | This fixes a potential bug that was never observed in practice since what happens is that the asynchronous connect returns ok (to fail later, calling the handler) every time, so a ping is queued, and sent_ping happens to always be populated. Howver technically connect(2) with a non blocking socket may return an error synchronously, so before this fix the code was not correct.
* Cluster: new option to work with partial slots coverage.antirez2014-09-171-6/+8
|
* Cluster: Fix segfault if cluster config corruptMatt Stancliff2014-08-251-3/+7
| | | | | | | | | | | This commit adds a size check after initial config line parsing to make sure we have *at least* 8 arguments per line. Also, instead of asserting for cluster->myself, we just test and error out normally (since the error does a hard exit anyway). Closes #1597
* Fix memory leak in cluster config parsingMatt Stancliff2014-08-181-0/+1
| | | | | | The continue stop us from triggering the free after the long line for loop, so add it earlier.