4982 Commits

Author SHA1 Message Date
antirez
c48355e920 Cluster: verify slaves consistency after resharding. 2015-12-18 11:34:08 +01:00
antirez
99cb476500 Fix CMD_DENYOOM macro name after backporting. 2015-12-18 09:15:47 +01:00
antirez
514ee7135e Cluster: allows abbreviated node IDs with rebalance --weight option. 2015-12-18 09:12:24 +01:00
antirez
025628bd76 Cluster: rebalancing option --simulate, and a fix. 2015-12-18 09:12:20 +01:00
antirez
f501f5f4c9 Cluster: redis-trib rebalance initial implementation. 2015-12-18 09:12:16 +01:00
antirez
a49a57ccd1 Initial implementation of redis-trib info subcommand. 2015-12-18 09:12:11 +01:00
antirez
0bc1993879 fix sprintf and snprintf format string
There are some cases of printing unsigned integer with %d conversion
specificator and vice versa (signed integer with %u specificator).

Patch by Sergey Polovko. Backported to Redis from Disque.
2015-12-18 09:10:51 +01:00
antirez
cb61d003ab Cluster: resharding test now checks AOF consistency.
It's a key invariant that when AOF is enabled, after the cluster
reshards, a crash-recovery event causes all the keys to be still fine
with the expected logical content. Now this is part of unit 04.
2015-12-17 17:53:33 +01:00
antirez
d999f5a68e Fix a race that may lead to the active (slave) client to be freed.
In issue #2948 a crash was reported in processCommand(). Later Oran Agra
(@oranagra) traced the bug (in private chat) in the following sequence
of events:

1. Some maxmemory is set.
2. The slave is the currently active client and is executing PING or
   REPLCONF or whatever a slave can send to its master.
3. freeMemoryIfNeeded() is called since maxmemory is set.
4. flushSlavesOutputBuffers() is called by freeMemoryIfNeeded().
5. During slaves buffers flush, a write error could be encoutered in
   writeToClient() or sendReplyToClient() depending on the version of
   Redis. This will trigger freeClient() against the currently active
   client, so a segmentation fault will likely happen in
   processCommand() immediately after the call to freeMemoryIfNeeded().

There are different possible fixes:

1. Add flags to writeToClient() (recent versions code base) so that
   we can ignore the write errors, and use this flag in
   flushSlavesOutputBuffers(). However this is not simple to do in older
   versions of Redis.
2. Use freeClientAsync() during write errors. This works but changes the
   current behavior of releasing clients ASAP when possible. Normally
   we write to clients during the normal event loop processing, in the
   writable client, where there is no active client, so no care must be
   taken.
3. The fix of this commit: to detect that the current client is no
   longer valid. This fix is a bit "ad-hoc", but works across all the
   versions and has the advantage of not changing the remaining
   behavior. Only alters what happens during this race condition,
   hopefully.
2015-12-17 09:48:44 +01:00
antirez
f1ab834658 Log address causing SIGSEGV. 2015-12-15 18:02:18 +01:00
Sun He
8bb9cb38be lua_struct.c/getnum: throw error if overflow happen
Fix issue #2855
2015-12-14 17:58:55 +01:00
antirez
a5d27d395f Fix 3.0 merge issues with new MIGRATE. 2015-12-13 10:23:04 +01:00
antirez
ea89733833 Cluster: redis-trib: use variadic MIGRATE.
We use the new variadic/pipelined MIGRATE for faster migration.
Testing is not easy because to see the time it takes for a slot to be
migrated requires a very large data set, but even with all the overhead
of migrating multiple slots and to setup them properly, what used to
take 4 seconds (1 million keys, 200 slots migrated) is now 1.6 which is
a good improvement. However the improvement can be a lot larger if:

1. We use large datasets where a single slot has many keys.
2. By moving more than 10 keys per iteration, making this configurable,
   which is planned.

Close #2710
Close #2711
2015-12-13 10:17:44 +01:00
antirez
170adbf2c4 MIGRATE: Fix key extraction for new form. 2015-12-13 10:17:40 +01:00
antirez
8a02f61b27 MIGRATE: test more corner cases. 2015-12-13 10:17:37 +01:00
antirez
32e940c084 MIGRATE: Fix new argument rewriting refcount handling. 2015-12-13 10:17:33 +01:00
antirez
c460458d57 MIGRATE: fix replies processing and argument rewriting.
We need to process replies after errors in order to delete keys
successfully transferred. Also argument rewriting was fixed since
it was broken in several ways. Now a fresh argument vector is created
and set if we are acknowledged of at least one key.
2015-12-13 10:17:26 +01:00
antirez
5912afc9d4 Test: pipelined MIGRATE tests added. 2015-12-13 10:16:46 +01:00
antirez
9276d78776 Pipelined multiple keys MIGRATE. 2015-12-13 10:16:03 +01:00
antirez
3ab63b5cc6 Cluster: redis-trib migrate default timeout set to 60 sec. 2015-12-11 11:00:39 +01:00
Salvatore Sanfilippo
71bf5604c6 Merge pull request #2918 from danmaz74/3.0
redis-trib.rb: --timeout XXXXX option added to fix and reshard
2015-12-11 10:57:05 +01:00
antirez
bf09e58d9d Cluster: replica migration with delay.
We wait a fixed amount of time (5 seconds currently) much greater than
the usual Cluster node to node communication latency, before migrating.
This way when a failover occurs, before detecting the new master as a
target for migration, we give the time to its natural slaves (the slaves
of the failed over master) to announce they switched to the new master,
preventing an useless migration operation.
2015-12-11 09:26:15 +01:00
antirez
5ad4f7e0b1 Cluster: more reliable migration tests.
The old version was modeled with two failovers, however after the first
it is possible that another slave will migrate to the new master, since
for some time the new master is not backed by any slave. Probably there
should be some pause after a failover, before the migration. Anyway the
test is simpler in this way, and depends less on timing.
2015-12-10 13:00:18 +01:00
antirez
711bf140f3 Fix merge of cluster migrate-to flag. 2015-12-10 09:31:28 +01:00
antirez
6007ea3bcb Cluster: more reliable replicas migration test. 2015-12-10 09:30:27 +01:00
antirez
6d5d8d10a9 Remove debugging message left there for error. 2015-12-10 09:30:22 +01:00
antirez
2e43bcffaf Fix replicas migration by adding a new flag.
Some time ago I broken replicas migration (reported in #2924).
The idea was to prevent masters without replicas from getting replicas
because of replica migration, I remember it to create issues with tests,
but there is no clue in the commit message about why it was so
undesirable.

However my patch as a side effect totally ruined the concept of replicas
migration since we want it to work also for instances that, technically,
never had slaves in the past: promoted slaves.

So now instead the ability to be targeted by replicas migration, is a
new flag "migrate-to". It only applies to masters, and is set in the
following two cases:

1. When a master gets a slave, it is set.
2. When a slave turns into a master because of fail over, it is set.

This way replicas migration targets are only masters that used to have
slaves, and slaves of masters (that used to have slaves... obviously)
and are promoted.

The new flag is only internal, and is never exposed in the output nor
persisted in the nodes configuration, since all the information to
handle it are implicit in the cluster configuration we already have.
2015-12-10 09:30:13 +01:00
daniele
47bd2a09b4 redis-trib.rb: --timeout XXXXX option added to fix and reshard commands. Defaults to 15000 milliseconds 2015-12-06 22:47:57 +01:00
antirez
4f7d1e46cf Fix renamed define after merge. 2015-11-27 16:10:34 +01:00
antirez
3626699f1f Handle wait3() errors.
My guess was that wait3() with WNOHANG could never return -1 and an
error. However issue #2897 may possibly indicate that this could happen
under non clear conditions. While we try to understand this better,
better to handle a return value of -1 explicitly, otherwise in the
case a BGREWRITE is in progress but wait3() returns -1, the effect is to
match the first branch of the if/else block since server.rdb_child_pid
is -1, and call backgroundSaveDoneHandler() without a good reason, that
will, in turn, crash the Redis server with an assertion.
2015-11-27 16:09:49 +01:00
antirez
fe71dffbf2 Redis Cluster: hint about validity factor when slave can't failover. 2015-11-27 11:34:30 +01:00
antirez
8e491b1708 Remove "s" flag for MIGRATE in command table.
Maybe there are legitimate use cases for MIGRATE inside Lua scripts, at
least for now. When the command will be executed in an asynchronous
fashion (planned) it is possible we'll no longer be able to permit it
from within Lua scripts.
2015-11-17 15:40:47 +01:00
antirez
3da69a9f22 Update redis-cli help and the script to generate it. 2015-11-17 15:40:18 +01:00
antirez
d4f55990f8 Fix MIGRATE entry in command table.
Thanks to Oran Agra (@oranagra) for reporting. Key extraction would not
work otherwise and it does not make sense to take wrong data in the
command table.
2015-11-17 15:35:47 +01:00
antirez
28fb193ccd Fix error reply in subscribed Pub/Sub mode.
PING is now a valid command to issue in this context.
2015-11-09 11:12:03 +01:00
antirez
c5f9f199df CONTRIBUTING updated. 2015-10-27 12:07:54 +01:00
antirez
c7ec1a367a Redis 3.0.5 3.0.5 2015-10-15 15:44:54 +02:00
David Thomson
ab1f8ea508 Add back blank line 2015-10-15 13:06:31 +02:00
David Thomson
1fa63a78bc Update import command to optionally use copy and replace parameters 2015-10-15 13:06:31 +02:00
antirez
568c83dda7 Cluster: redis-trib fix, coverage for migrating=1 case.
Kinda related to #2770.
2015-10-15 13:06:31 +02:00
antirez
892b1c3c58 Redis.conf example: make clear user must pass its path as argument. 2015-10-15 12:46:17 +02:00
antirez
cbf6614c1a Regression test for issue #2813. 2015-10-15 11:25:19 +02:00
antirez
7cb8481053 Move end-comment of handshake states.
For an error I missed the last handshake state.
Related to issue #2813.
2015-10-15 10:22:13 +02:00
antirez
8242d069f1 Make clear that slave handshake states must be ordered.
Make sure that people from the future will not break this rule.
Related to issue #2813.
2015-10-15 10:22:13 +02:00
antirez
6ef80f4ed2 Minor changes to PR #2813.
* Function to test for slave handshake renamed slaveIsInHandshakeState.
* Function no longer accepts arguments since it always tests the
  same global state.
* Test for state translated to a range test since defines are guaranteed
  to stay in order in the future.
* Use the new function in the ROLE command implementation as well.
2015-10-15 10:22:13 +02:00
Kevin McGehee
dc03e4c51b Fix master timeout during handshake
This change allows a slave to properly time out a dead master during
the extended asynchronous synchronization state machine.  Now, slaves
will record their last interaction with the master and apply the
replication timeout before a response to the PSYNC request is received.
2015-10-15 10:22:13 +02:00
antirez
30978004b3 redis-cli pipe mode: don't stay in the write loop forever.
The code was broken and resulted in redis-cli --pipe to, most of the
times, writing everything received in the standard input to the Redis
connection socket without ever reading back the replies, until all the
content to write was written.

This means that Redis had to accumulate all the output in the output
buffers of the client, consuming a lot of memory.

Fixed thanks to the original report of anomalies in the behavior
provided by Twitter user @fsaintjacques.
2015-09-30 16:27:19 +02:00
antirez
652e662d1a Test: fix false positive in HSTRLEN test.
HINCRBY* tests later used the value "tmp" that was sometimes generated
by the random key generation function. The result was ovewriting what
Tcl expected to be inside Redis with another value, causing the next
HSTRLEN test to fail.
2015-09-15 09:38:26 +02:00
antirez
a0ff29bcf2 Test: MOVE expire test improved.
Related to #2765.
2015-09-14 12:37:13 +02:00
antirez
e2c0d89662 MOVE re-add TTL check fixed.
getExpire() returns -1 when no expire exists.

Related to #2765.
2015-09-14 12:36:34 +02:00