Commit Graph

5269 Commits

Author SHA1 Message Date
Salvatore Sanfilippo
827d07f005 Merge pull request #2551 from charsyam/feature/sentinel-memory-leak-1
fix sentinel memory leak
2015-05-04 12:17:41 +02:00
antirez
7af420e78d Merge branch 'unstable' of github.com:/antirez/redis into unstable 2015-04-29 10:34:08 +02:00
antirez
9e7f39d29d Add header guard for ziplist.h
As suggested in #2543.
2015-04-29 10:33:21 +02:00
Salvatore Sanfilippo
fe0d71d52f Merge pull request #2550 from badboy/readme-fixes
Fix spelling and grammatical errors in readme
2015-04-29 10:06:46 +02:00
antirez
c806dd799b Fix Sentinel memory leak (hiredis bug)
This fixes issue #2535, that was actually an hiredis library bug (I
submitted an issue and fix to the redis/hiredis repo as well).

When an asynchronous hiredis connection subscribes to a Pub/Sub channel
and gets an error, and in other related conditions, the function
redisProcessCallbacks() enters a code path where the link is
disconnected, however the function returns before freeing the allocated
reply object. This causes a memory leak. The memory leak was trivial to
trigger in Redis Sentinel, which uses hiredis, every time we tried to
subscribe to an instance that required a password, in case the Sentinel
was configured either with the wrong password or without password at
all. In this case, the -AUTH error caused the leaking code path to be
executed.

It was verified with Valgrind that after this change the leak no longer
happens in Sentinel with a misconfigured authentication password.
2015-04-28 22:10:23 +02:00
clark.kang
eff212ea95 fix sentinel memory leak 2015-04-29 00:05:26 +09:00
Jan-Erik Rediger
fb53288110 One more small fix 2015-04-28 15:21:11 +02:00
Jan-Erik Rediger
3ff49afff1 Fix spelling and grammatical errors in readme
Closes #2549
2015-04-28 11:07:21 +02:00
antirez
1b25757f41 sha1.c: use standard uint32_t. 2015-04-27 12:07:49 +02:00
antirez
1d6eb701d8 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2015-04-27 12:05:32 +02:00
antirez
1a93501f8b Example redis.conf doc about pidfile fixed.
An user changed the behavior via a PR without upgrading the doc.
2015-04-26 19:23:27 +02:00
Yossi Gottlieb
49c1b60bd8 Fix Redis server crash when Lua command exceeds client output buffer
limit.
2015-04-26 12:04:16 +03:00
Salvatore Sanfilippo
b100fee900 Merge pull request #2539 from itamarhaber/patch-4
Added reference to IANA ticket for port 6379
2015-04-24 09:05:14 +02:00
Itamar Haber
066d7a29eb Added reference to IANA ticket for port 6379
Just so it's extra official 😄
2015-04-24 01:33:41 +03:00
Itamar Haber
921ca063f7 update copyright year 2015-04-21 18:54:49 +03:00
FuGangqiang
26a1a08fc7 sdsfree x and y 2015-04-20 23:03:34 +08:00
FuGangqiang
239494db64 fix doc example 2015-04-20 21:46:48 +08:00
FuGangqiang
42b36c5ce9 fix typo 2015-04-19 23:42:27 +08:00
Glenn Nethercutt
626b4f6907 uphold the smove contract to return 0 when the element is not a member of the source set, even if source=dest 2015-04-17 09:27:54 -04:00
antirez
6c60526db9 Net: improve prepareClientToWrite() error handling and comments.
When we fail to setup the write handler it does not make sense to take
the client around, it is missing writes: whatever is a client or a slave
anyway the connection should terminated ASAP.

Moreover what the function does exactly with its return value, and in
which case the write handler is installed on the socket, was not clear,
so the functions comment are improved to make the goals of the function
more obvious.

Also related to #2485.
2015-04-01 10:07:45 +02:00
Salvatore Sanfilippo
d5a35c3946 Merge pull request #2485 from oranagra/diskless-repl-fixes
fixes to diskless replication.
2015-04-01 09:43:34 +02:00
antirez
386804246f Test: be more patient waiting for servers to exit.
This should likely fix a false positive when running with the --valgrind
option.
2015-03-31 23:43:38 +02:00
Oran Agra
159875b5a3 fixes to diskless replication.
master was closing the connection if the RDB transfer took long time.
and also sent PINGs to the slave before it got the initial ACK, in which case the slave wouldn't be able to find the EOF marker.
2015-03-31 23:42:08 +03:00
antirez
66f9393ee4 Fix setTypeNext call assuming NULL can be passed.
Segfault introduced during a refactoring / warning suppression a few
commits away. This particular call assumed that it is safe to pass NULL
to the object pointer argument when we are sure the set has a given
encoding. This can't be assumed and is now guaranteed to segfault
because of the new API of setTypeNext().
2015-03-31 15:26:35 +02:00
antirez
65090401b7 Sentinel / Cluster test: exit with non-zero error code on failures. 2015-03-30 14:29:01 +02:00
antirez
7f330b16f9 Set: setType*() API more defensive initializing both values.
This change fixes several warnings compiling at -O3 level with GCC
4.8.2, and at the same time, in case of misuse of the API, we have the
pointer initialize to NULL or the integer initialized to the value
-123456789 which is easy to spot by naked eye.
2015-03-30 12:24:57 +02:00
antirez
34460dd6ee Check bio.c job type at thread startup.
Another one just to avoid a warning. Slightly more defensive code
anyway.
2015-03-30 12:17:46 +02:00
antirez
221d2932b5 Ensure array index is in range in addReplyLongLongWithPrefix().
Change done in order to remove a warning and improve code robustness. No
actual bug here.
2015-03-30 11:54:49 +02:00
antirez
37260bc3be Test: regression for issue #2473. 2015-03-27 12:10:46 +01:00
antirez
068d3c9737 dict.c: convert types to unsigned long where appropriate.
No semantical changes since to make dict.c truly able to scale over the
32 bit table size limit, the hash function shoulds and other internals
related to hash function output should be 64 bit ready.
2015-03-27 10:14:52 +01:00
antirez
9cd8333ed2 dict.c: add casting to avoid compilation warning.
rehashidx is always positive in the two code paths, since the only
negative value it could have is -1 when there is no rehashing in
progress, and the condition is explicitly checked.
2015-03-27 10:12:25 +01:00
antirez
c3ad70901f Replication: disconnect blocked clients when switching to slave role.
Bug as old as Redis and blocking operations. It's hard to trigger since
only happens on instance role switch, but the results are quite bad
since an inconsistency between master and slave is created.

How to trigger the bug is a good description of the bug itself.

1. Client does "BLPOP mylist 0" in master.
2. Master is turned into slave, that replicates from New-Master.
3. Client does "LPUSH mylist foo" in New-Master.
4. New-Master propagates write to slave.
5. Slave receives the LPUSH, the blocked client get served.

Now Master "mylist" key has "foo", Slave "mylist" key is empty.

Highlights:

* At step "2" above, the client remains attached, basically escaping any
  check performed during command dispatch: read only slave, in that case.
* At step "5" the slave (that was the master), serves the blocked client
  consuming a list element, which is not consumed on the master side.

This scenario is technically likely to happen during failovers, however
since Redis Sentinel already disconnects clients using the CLIENT
command when changing the role of the instance, the bug is avoided in
Sentinel deployments.

Closes #2473.
2015-03-24 16:00:09 +01:00
antirez
9b7f8b1c9b Cluster: redirection refactoring + handling of blocked clients.
There was a bug in Redis Cluster caused by clients blocked in a blocking
list pop operation, for keys no longer handled by the instance, or
in a condition where the cluster became down after the client blocked.

A typical situation is:

1) BLPOP <somekey> 0
2) <somekey> hash slot is resharded to another master.

The client will block forever int this case.

A symmentrical non-cluster-specific bug happens when an instance is
turned from master to slave. In that case it is more serious since this
will desynchronize data between slaves and masters. This other bug was
discovered as a side effect of thinking about the bug explained and
fixed in this commit, but will be fixed in a separated commit.
2015-03-24 11:56:24 +01:00
Salvatore Sanfilippo
eff68bd656 Merge pull request #2470 from superlogical/unstable
create-cluster fix for stop and watch commands
2015-03-24 09:07:22 +01:00
superlogical
761fc16b4a create-cluster fix for stop and watch commands 2015-03-24 09:44:52 +13:00
antirez
9b0bcf25e1 Cluster: unit 10 modified to leave cluster in proper state. 2015-03-22 22:58:53 +01:00
antirez
f300680408 Cluster: CLUSTER FAILOVER TAKEOVER tests. 2015-03-22 22:44:23 +01:00
antirez
631538cfe0 Cluster: more tests for manual failover + FORCE. 2015-03-22 22:44:02 +01:00
antirez
3b4de6aa18 Cluster: new tests1 for manual failover and scripts replication. 2015-03-22 22:25:05 +01:00
antirez
2f4240b9d9 Cluster: fix Lua scripts replication to slave nodes. 2015-03-22 22:24:08 +01:00
antirez
94030fa4d7 Two cluster.c comments improved. 2015-03-21 12:12:23 +01:00
antirez
2950824ab6 Cluster: TAKEOVER option for manual failover. 2015-03-21 11:54:32 +01:00
antirez
d544600aa5 Fix typo in beforeSleep() comment. 2015-03-21 09:19:08 +01:00
antirez
2b278a3394 Net: processUnblockedClients() and clientsArePaused() minor changes.
1. No need to set btype in processUnblockedClients(), since clients
   flagged REDIS_UNBLOCKED should have it already cleared.
2. When putting clients in the unblocked clients list, clientsArePaused()
   should flag them with REDIS_UNBLOCKED. Not strictly needed with the
   current code but is more coherent.
2015-03-21 09:13:29 +01:00
antirez
5fe4a23131 Net: clientsArePaused() should not touch blocked clients.
When the list of unblocked clients were processed, btype was set to
blocking type none, but the client remained flagged with REDIS_BLOCKED.
When timeout is reached (or when the client disconnects), unblocking it
will trigger an assertion.

There is no need to process pending requests from blocked clients, so
now clientsArePaused() just avoid touching blocked clients.

Close #2467.
2015-03-21 09:04:38 +01:00
antirez
a7010ae208 Cluster: non-conditional steps of slave failover refactored into a function. 2015-03-20 17:56:21 +01:00
antirez
230d141420 Cluster: separate unknown master check from the rest.
In no case we should try to attempt to failover if myself->slaveof is
NULL.
2015-03-20 16:56:59 +01:00
antirez
4f2555aa17 Cluster: refactoring around configEpoch handling.
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.
2015-03-20 16:42:52 +01:00
antirez
25c0f5ac63 Cluster: better cluster state transiction handling.
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.
2015-03-20 09:59:28 +01:00
antirez
2ecb5edf34 Cluster: move clusterBeforeSleep() call before unblocked clients processing.
Related to issue #2288.
2015-03-20 09:47:54 +01:00