469 Commits

Author SHA1 Message Date
Salvatore Sanfilippo
bfe127ac88 Merge pull request #3222 from oranagra/more_minir_fixes
minor fixes - mainly signalModifiedKey, and GEORADIUS
2016-05-18 07:50:53 -07:00
antirez
8ff424c77f Modules: command <-> core interface modified to get flags & keys. 2016-05-10 06:40:09 +02:00
antirez
83fe739fb6 Modules: first preview 31 March 2016. 2016-05-10 06:40:05 +02:00
oranagra
26e236b2a6 minor fixes - mainly signalModifiedKey, and GEORADIUS 2016-05-09 12:05:33 +03:00
antirez
f36bf76a15 Revert "Fix commandCommand arity"
This reverts commit 1189a4eae6d009fc0da8d50fd542ba1391542165.

Actually this is wrong, the command can be called without args at all.
2016-05-05 17:36:05 +02:00
Ruben Bridgewater
4ce1125d32 Fix commandCommand arity 2016-05-05 17:20:14 +02:00
antirez
f292056f5d Cluster: make getNodeByQuery() responsible of -CLUSTERDOWN errors.
This fixes a bug introduced by bb51ad0, and makes the code consistent
with the logic of always allowing, while the cluster is down, commands
that don't target any key.

As a side effect the code is also simpler now.
2016-05-05 11:33:43 +02:00
antirez
a17f4ca56c Bind both IPv4 and IPv6 or exit with an error by default.
Thanks to @tushar2708 for the PR. I applied a slightly different fix.
Thanks to @cespare for reporting.

Close #3024
Close #3020
2016-05-05 10:02:42 +02:00
Chris Thunes
bb51ad0e97 Ensure slots are rechecked on EXEC.
Fixes #2515.
2016-05-05 09:35:20 +02:00
Salvatore Sanfilippo
3cf68cb168 Merge pull request #3188 from therealbill/unstable
maxmemory_policy fix for #3187
2016-05-05 09:02:25 +02:00
antirez
dd8a3b013e Allow CONFIG GET during loading.
Thanks to @oranagra for the idea of allowing CONFIG GET during loading.
2016-05-04 15:45:45 +02:00
antirez
99a6bcda1b Command "r" flag removed from commands not accessing the key space.
Thanks to @oranagra for the hint about misplaced 'r' flags.
2016-05-04 15:42:33 +02:00
antirez
aa206616b9 DEBUG command self documentation. 2016-05-04 12:45:55 +02:00
therealbill
85e3d50559 fix for #3187
I've renamed maxmemoryToString to evictPolicyToString since that is
more accurate (and easier to mentally connect with the correct data), as
well as updated the function to user server.maxmemory_policy rather than
server.maxmemory. Now with a default config it is actually returning
the correct policy rather than volatile-lru.
2016-04-22 10:43:48 -05:00
antirez
6d82a27995 Fix INFO commandstats reporting when argv is rewritten.
We want to report the original command in the stats, for example GEOADD,
even when what is actually executed is the ZADD implementation.
2016-03-02 08:56:50 +01:00
antirez
5b3ab9d132 BITFIELD command initial implementation.
The new bitfield command is an extension to the Redis bit operations,
where not just single bit operations are performed, but the array of
bits composing a string, can be addressed at random, not aligned
offsets, with any width unsigned and signed integers like u8, s5, u10
(up to 64 bit signed integers and 63 bit unsigned integers).

The BITFIELD command supports subcommands that can SET, GET, or INCRBY
those arbitrary bit counters, with multiple overflow semantics.

Trivial and credits:

A similar command was imagined a few times in the past, but for
some reason looked a bit far fetched or not well specified.
Finally the command was proposed again in a clear form by
Yoav Steinberg from Redis Labs, that proposed a set of commands on
arbitrary sized integers stored at bit offsets.

Starting from this proposal I wrote an initial specification of a single
command with sub-commands similar to what Yoav envisioned, using short
names for types definitions, and adding control on the overflow.

This commit is the resulting implementation.

Examples:

    BITFIELD mykey OVERFLOW wrap INCRBY i2 10 -1 GET i2 10
2016-02-26 15:00:19 +01:00
antirez
416adf1a9c New options for GEORADIUS: STORE and STOREDIST.
Related to issue #3019.
2016-02-18 10:24:16 +01:00
Itamar Haber
7bfe0f41c8 Fixes a typo 2016-02-03 11:04:09 -08:00
antirez
51a16c9ca0 Cluster announce ip / port initial implementation. 2016-01-29 09:06:37 +01:00
antirez
d398ce34e6 Cluster announce ip / port configuration handling. 2016-01-29 09:06:37 +01:00
antirez
5a0c8ac3be Use a smoother running average for avg_ttl in INFO.
Reported here:
https://www.reddit.com/r/redis/comments/42r0i0/avg_ttl_varies_a_lot/
2016-01-26 15:29:30 +01:00
antirez
d609d9942d New security feature: Redis protected mode.
An exposed Redis instance on the internet can be cause of serious
issues. Since Redis, by default, binds to all the interfaces, it is easy
to forget an instance without any protection layer, for error.

Protected mode try to address this feature in a soft way, providing a
layer of protection, but giving clues to Redis users about why the
server is not accepting connections.

When protected mode is enabeld (the default), and if there are no
minumum hints about the fact the server is properly configured (no
"bind" directive is used in order to restrict the server to certain
interfaces, nor a password is set), clients connecting from external
intefaces are refused with an error explaining what to do in order to
fix the issue.

Clients connecting from the IPv4 and IPv6 lookback interfaces are still
accepted normally, similarly Unix domain socket connections are not
restricted in any way.
2016-01-07 13:00:14 +01:00
antirez
694cc141d5 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:39:43 +01:00
antirez
3f563bf30c Fix processCommand() comment about return value. 2015-12-17 09:22:16 +01:00
antirez
47cb5c697b MIGRATE: Fix key extraction for new form. 2015-12-11 18:09:01 +01:00
antirez
e3c11c1198 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:11:05 +01:00
antirez
76fd26e778 Lua debugger: call wait3() if there are pending forked debugging sessions. 2015-11-17 15:43:23 +01:00
antirez
5c05038252 Lua debugger: handle forked sessions children during shutdown. 2015-11-17 15:43:22 +01:00
antirez
063bbc8074 Lua debugger: foundations implemented. 2015-11-17 15:43:20 +01:00
antirez
6adc1fe86a 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:43:13 +01:00
antirez
aa2785936f 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:33:09 +01:00
antirez
b56cc1b939 call() deserves a good top-comment. 2015-11-10 13:31:25 +01:00
antirez
dd9955a080 Best effort flush of slave buffers before SHUTDOWN. 2015-11-09 17:26:58 +01:00
antirez
f741c4871e Fix error reply in subscribed Pub/Sub mode.
PING is now a valid command to issue in this context.
2015-11-09 11:10:53 +01:00
antirez
e8eb45509e Initialize all Lua scripting related things into scripting.c 2015-11-05 11:37:39 +01:00
antirez
169e86f9b1 Scripting: ability to turn on Lua commands style replication globally.
Currently this feature is only accessible via DEBUG for testing, since
otherwise depending on the instance configuration a given script works
or is broken, which is against the Redis philosophy.
2015-10-30 12:06:09 +01:00
antirez
721f612918 Fix call() FORCE_REPL/AOF flags setting.
This commit also inverts two stanzas of the code just becuase they are
more logical like that, not because currently it makes any difference.
2015-10-30 12:06:08 +01:00
antirez
7d05c2d795 Lua script selective replication fixes. 2015-10-30 12:06:08 +01:00
antirez
24103bafd0 Scripting: single commands replication mode implemented.
By calling redis.replicate_commands(), the scripting engine of Redis
switches to commands replication instead of replicating whole scripts.
This is useful when the script execution is costly but only results in a
few writes performed to the dataset.

Morover, in this mode, it is possible to call functions with side
effects freely, since the script execution does not need to be
deterministic: anyway we'll capture the outcome from the point of view
of changes to the dataset.

In this mode math.random() returns different sequences at every call.

If redis.replicate_commnads() is not called before any other write, the
command returns false and sticks to whole scripts replication instead.
2015-10-30 12:06:08 +01:00
antirez
52b4464ed6 call(): selective ability to prevent propagation on AOF / slaves. 2015-10-30 12:06:08 +01:00
antirez
78d342ec30 call(): don't inherit CLIENT_PREVENT_PROP + minor refactoring. 2015-10-30 12:06:08 +01:00
antirez
9fc48ed151 DEBUG RESTART/CRASH-AND-RECOVER [delay] implemented. 2015-10-13 11:12:25 +02:00
antirez
5b7bd883e6 Server: restartServer() API.
This new function is able to restart the server "in place". The current
Redis process executes the same executable it was executed with, using
the same arguments and configuration file.
2015-10-13 11:02:35 +02:00
antirez
27ec5105eb Lazyfree: cond vars to enabled/disable it based on DEL context. 2015-10-02 15:27:57 +02:00
antirez
93da3c7874 FLUSHDB and FLUSHALL ASYNC option implemented. 2015-10-01 13:02:26 +02:00
antirez
da103b45ed Lazyfree: pending objects count in INFO output. 2015-10-01 13:02:26 +02:00
antirez
7babd6e184 Lazyfree: incremental removed, only threaded survived. 2015-10-01 13:02:25 +02:00
antirez
fbc46738f4 Threaded lazyfree WIP #1. 2015-10-01 13:02:25 +02:00
antirez
5eb85d8fe7 Lazyfree: Hash converted to use plain SDS WIP 4. 2015-10-01 13:02:25 +02:00
antirez
5fd01e29d9 Lazyfree: Hash converted to use plain SDS WIP 1. 2015-10-01 13:02:24 +02:00