4996 Commits

Author SHA1 Message Date
antirez
8ef716d19a Cluster: CLUSTER BUMPEPOCH introduced to help redis-trib fix.
Sometimes during "fixes" we have to setup a new configuration and assign
slots to nodes. With BUMPEPOCH we can make sure the new configuration of
the node will win if there are conflicting configurations (for example
another node is *also* claiming the same slot because the cluster is
totally messed up).
2016-01-25 15:21:17 +01:00
antirez
5da1e640ad Cluster: don't allow CLUSTER SETSLOT with slaves. 2016-01-25 15:21:13 +01:00
antirez
53edd42a4e Cluster: check packets length before accessing far fields. 2016-01-19 13:18:08 +01:00
antirez
e50b9a0757 Scripting: handle trailing comments.
This fix, provided by Paul Kulchenko (@pkulchenko), allows the Lua
scripting engine to evaluate statements with a trailing comment like the
following one:

    EVAL "print() --comment" 0

Lua can't parse the above if the string does not end with a newline, so
now a final newline is always added automatically. This does not change
the SHA1 of scripts since the SHA1 is computed on the body we pass to
EVAL, without the other code we add to register the function.

Close #2951.
2016-01-08 15:45:18 +01:00
antirez
e9abc94483 Allow MIGRATE to always be called on local keys for open slots.
Extend the MIGRATE extra freedom to be able to be called in the context
of the local slot, anytime there is a slot open in one or the other
direction (importing or migrating). This is useful for redis-trib to fix
the cluster when it has in an odd state.

Thix fix allows "redis-trib fix" to make its work in certain cases where
previously an error was reported.
2016-01-08 15:36:37 +01:00
antirez
583194c8f4 Fix typos & grammar in clusterBumpConfigEpochWithoutConsensus() comment. 2016-01-08 15:35:44 +01:00
antirez
319a4c04c7 Cluster: don't send -ASK to MIGRATE.
For non existing keys, we don't want to send -ASK redirections to
MIGRATE, since when moving slots from the migrating node to the
importing node, we want just to ignore keys that are no longer there.
They may be expired or deleted between the GETKEYSINSLOT call and the
MIGRATE call. Otherwise this causes an error during migrations with
redis-trib (or equivalent cluster management tools).
2016-01-06 12:24:13 +01:00
antirez
a8c2aa0f44 Cluster test: do leaks detection with OSX leaks utility. 2016-01-02 13:25:27 +01:00
antirez
f9c971ff87 redis-trib: Remove duplicated key in hash initialization. 2016-01-02 13:25:27 +01:00
antirez
3d61cb0cb1 Suppress harmless warnings. 3.0.6 2015-12-18 16:19:47 +01:00
antirez
ddc4d7f8c7 Changelog typo fixed. 2015-12-18 16:14:55 +01:00
antirez
d51fdfda42 Redis 3.0.6 2015-12-18 16:10:43 +01:00
antirez
7ce7387202 Cluster: rebalance now supports --threshold option. 2015-12-18 15:52:22 +01:00
antirez
b4b7c57cb0 Cluster: redis-trib reshard / rebalance --pipeline support. 2015-12-18 15:52:22 +01:00
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