447 Commits

Author SHA1 Message Date
antirez
62e7179de9 Child -> Parent pipe for COW info transferring. 2016-09-19 13:45:20 +02:00
antirez
6249fdc544 MEMORY DOCTOR initial implementation. 2016-09-16 16:36:53 +02:00
antirez
303d981cab Provide percentage of memory peak used info. 2016-09-16 10:43:19 +02:00
antirez
340c5546a1 MEMORY command: HELP + dataset percentage (like in INFO). 2016-09-15 17:33:16 +02:00
antirez
0edf97bc7e INFO: new memory reporting fields added. 2016-09-15 10:33:23 +02:00
antirez
f705ad52db MEMORY OVERHEAD implemented (using Oran Agra initial implementation).
This code was extracted from @oranagra PR #3223 and modified in order
to provide only certain amounts of information compared to the original
code. It was also moved from DEBUG to the newly introduced MEMORY
command. Thanks to Oran for the implementation and the PR.

It implements detailed memory usage stats that can be useful in both
provisioning and troubleshooting memory usage in Redis.
2016-09-13 17:39:25 +02:00
antirez
cf49be57a5 objectComputeSize(): estimate collections sampling N elements.
For most tasks, we need the memory estimation to be O(1) by default.
This commit also implements an initial MEMORY command.
Note that objectComputeSize() takes the number of samples to check as
argument, so MEMORY should be able to get the sample size as option
to make precision VS CPU tradeoff tunable.

Related to: PR #3223.
2016-09-13 10:28:23 +02:00
antirez
19ba3dbb70 Merge branch 'aofrdb' into unstable 2016-09-09 15:03:21 +02:00
antirez
fdf93daf40 fix the fix for the TCP binding.
This commit attempts to fix a problem with PR #3467.
2016-09-09 14:59:48 +02:00
oranagra
639201a989 fix tcp binding when IPv6 is unsupported 2016-09-09 14:59:21 +02:00
antirez
3d6b2655b9 RDB AOF preamble: WIP 2. 2016-08-09 16:41:40 +02:00
antirez
d44a56fe27 Security: Cross Protocol Scripting protection.
This is an attempt at mitigating problems due to cross protocol
scripting, an attack targeting services using line oriented protocols
like Redis that can accept HTTP requests as valid protocol, by
discarding the invalid parts and accepting the payloads sent, for
example, via a POST request.

For this to be effective, when we detect POST and Host: and terminate
the connection asynchronously, the networking code was modified in order
to never process further input. It was later verified that in a
pipelined request containing a POST command, the successive commands are
not executed.
2016-08-03 11:12:32 +02:00
antirez
435ae67ecb Fix comment over 80 cols. 2016-08-03 10:56:26 +02:00
antirez
43b5a64a8f Ability of slave to announce arbitrary ip/port to master.
This feature is useful, especially in deployments using Sentinel in
order to setup Redis HA, where the slave is executed with NAT or port
forwarding, so that the auto-detected port/ip addresses, as listed in
the "INFO replication" output of the master, or as provided by the
"ROLE" command, don't match the real addresses at which the slave is
reachable for connections.
2016-07-27 17:32:15 +02:00
antirez
276dfeb3d0 Avoid simultaneous RDB and AOF child process.
This patch, written in collaboration with Oran Agra (@oranagra) is a companion
to 03a4432. Together the two patches should avoid that the AOF and RDB saving
processes can be spawned at the same time. Previously conditions that
could lead to two saving processes at the same time were:

1. When AOF is enabled via CONFIG SET and an RDB saving process is
   already active.

2. When the SYNC command decides to start an RDB saving process ASAP in
   order to serve a new slave that cannot partially resynchronize (but
   only if we have a disk target for replication, for diskless
   replication there is not such a problem).

Condition "1" is not very severe but "2" can happen often and is
definitely good at degrading Redis performances in an unexpected way.

The two commits have the effect of always spawning RDB savings for
replication in replicationCron() instead of attempting to start an RDB
save synchronously. Moreover when a BGSAVE or AOF rewrite must be
performed, they are instead just postponed using flags that will try to
perform such operations ASAP.

Finally the BGSAVE command was modified in order to accept a SCHEDULE
option so that if an AOF rewrite is in progress, when this option is
given, the command no longer returns an error, but instead schedules an
RDB rewrite operation for when it will be possible to start it.
2016-07-21 18:35:01 +02:00
antirez
73df375139 LFU: make counter log factor and decay time configurable. 2016-07-20 15:00:35 +02:00
antirez
c28d1285a3 LRU: Make cross-database choices for eviction.
The LRU eviction code used to make local choices: for each DB visited it
selected the best key to evict. This was repeated for each DB. However
this means that there could be DBs with very frequently accessed keys
that are targeted by the LRU algorithm while there were other DBs with
many better candidates to expire.

This commit attempts to fix this problem for the LRU policy. However the
TTL policy is still not fixed by this commit. The TTL policy will be
fixed in a successive commit.

This is an initial (partial because of TTL policy) fix for issue #2647.
2016-07-13 13:12:30 +02:00
antirez
1d39d0cbc4 Move prototype of evictionPoolAlloc() in server.h. 2016-07-12 12:22:35 +02:00
antirez
c50290ee69 Expire and LRU related code moved into different files. 2016-07-06 15:24:06 +02:00
antirez
a89f5d2bdf In Redis RDB check: better error reporting. 2016-07-01 09:36:52 +02:00
antirez
8fbb0fb0c5 In Redis RDB check: initial POC.
So far we used an external program (later executed within Redis) and
parser in order to check RDB files for correctness. This forces, at each
RDB format update, to have two copies of the same format implementation
that are hard to keep in sync. Morover the former RDB checker only
checked the very high-level format of the file, without actually trying
to load things in memory. Certain corruptions can only be handled by
really loading key-value pairs.

This first commit attempts to unify the Redis RDB loadig code with the
task of checking the RDB file for correctness. More work is needed but
it looks like a sounding direction so far.
2016-06-30 23:44:44 +02:00
Yusaku Kaneta
6a8de5c8c2 Fix the firstkey, lastkey, and keystep of moduleCommand 2016-06-29 18:09:16 +09:00
Misha Nasledov
7628ec8512 Fix incorrect comment for checkForSentinelMode function 2016-06-16 16:50:53 -07:00
antirez
eb8575fbf7 TTL and TYPE LRU access fixed. TOUCH implemented. 2016-06-14 15:33:59 +02:00
antirez
4d9a5f901d Merge branch 'unstable' of github.com:/antirez/redis into unstable 2016-06-10 10:12:11 +02:00
antirez
3456130481 Improve timer callback creation comment. 2016-06-08 16:07:32 +02:00
Pierre Chapuis
08a8ae709b make RPUSHX and LPUSHX variadic 2016-06-05 16:50:24 +02:00
Itamar Haber
54ad58ee4d Allow SPOP from Lua scripts
The existing `R` flag appears to be sufficient and there's no apparent reason why the command should be blocked.
2016-05-28 20:01:46 +03:00
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