586 Commits

Author SHA1 Message Date
MOON_CLJ
f22a9c0f78 pfcount support multi keys 2015-07-17 10:56:28 +02:00
Tom Kiemes
ad0082fde4 Fix: aof_delayed_fsync is not reset
aof_delayed_fsync was not set to 0 when calling CONFIG RESETSTAT
2015-07-17 10:39:30 +02:00
antirez
b029ff11b6 Client timeout handling improved.
The previos attempt to process each client at least once every ten
seconds was not a good idea, because:

1. Usually because of the past min iterations set to 50, you get much
better processing period most of the times.

2. However when there are many clients and a normal setting for
server.hz, the edge case is triggered, and waiting 10 seconds for a
BLPOP that asked for 1 second is not ok.

3. Moreover, because of the high min-itereations limit of 50, when HZ
was set to an high value, the actual behavior was to process a lot of
clients per second.

Also the function checking for timeouts called gettimeofday() at each
iteration which can be costly.

The new implementation will try to process each client once per second,
gets the current time as argument, and does not attempt to process more
than 5 clients per iteration if not needed.

So now:

1. The CPU usage of an idle Redis process is the same or better.
2. The CPU usage of a busy Redis process is the same or better.
3. However a non trivial amount of work may be performed per iteration
when there are many many clients. In this particular case the user may
want to raise the "HZ" value if needed.

Btw with 4000 clients it was still not possible to noticy any actual
latency created by processing 400 clients per second, since the work
performed for each client is pretty small.
2015-07-16 11:03:40 +02:00
antirez
5dcba26b31 Clarify a comment in clientsCron(). 2015-07-16 11:03:40 +02:00
antirez
7ae1d4d6f5 EXISTS is now variadic.
The new return value is the number of keys existing, among the ones
specified in the command line, counting the same key multiple times if
given multiple times (and if it exists).

See PR #2667.
2015-07-13 18:23:18 +02:00
antirez
3468cd3664 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 16:16:44 +01:00
antirez
c2717911db Cluster: fix Lua scripts replication to slave nodes. 2015-03-22 22:24:05 +01:00
antirez
2d34ec60bf Fix typo in beforeSleep() comment. 2015-03-21 09:19:51 +01:00
antirez
62893f5b9f 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 10:06:11 +01:00
antirez
585f68ac35 Cluster: move clusterBeforeSleep() call before unblocked clients processing.
Related to issue #2288.
2015-03-20 10:06:07 +01:00
antirez
085ef2087b Net: better Unix socket error. Issue #2449. 2015-03-18 11:29:32 +01:00
antirez
967590de6e Separate latency monitoring of eviction loop and eviction DELs. 2015-02-11 11:01:46 +01:00
antirez
eaae581b55 Remove optional single-key path from evictionPoolPopulate(). 2015-02-11 11:01:46 +01:00
antirez
05a398389f dict.c: add dictGetSomeKeys(), specialized for eviction. 2015-02-11 11:01:46 +01:00
antirez
1e8f1577c5 INFO loading stats: three fixes.
1. Server unxtime may remain not updated while loading AOF, so ETA is
not updated correctly.

2. Number of processed byte was not initialized.

3. Possible division by zero condition (likely cause of issue #1932).
2014-12-23 14:54:31 +01:00
antirez
9cb99f547d Fix adjustOpenFilesLimit() logging to match real state.
Fixes issue #2225.
2014-12-19 10:05:07 +01:00
antirez
722faed62a Don't log admin commands in MONITOR.
Otherwise there are security risks, especially when providing Redis as a
service, the user may "sniff" for admin commands renamed to an
unguessable string via rename-command in redis.conf.
2014-12-13 08:58:34 +01:00
antirez
cc7b9171ca List of commands flagged as admin commands modified.
The old list did not made much sense... and the flag is currently not
used at all, so no side effects.
2014-12-13 08:58:34 +01:00
antirez
e7d6f51dcb Check that tcp-backlog is matched by /proc/sys/net/core/somaxconn. 2014-12-04 11:07:52 +01:00
antirez
8a67e5d456 Network bandwidth tracking + refactoring.
Track bandwidth used by clients and replication (but diskless
replication is not tracked since the actual transfer happens in the
child process).

This includes a refactoring that makes tracking new instantaneous
metrics simpler.
2014-12-03 12:17:15 +01:00
antirez
8fb0d455d4 Don't show the ASCII logo if syslog is enabled.
Closes issue #1935.
2014-12-03 10:52:07 +01:00
antirez
69efb59ac7 Mark PFCOUNT as read-only, even if not true.
PFCOUNT is technically speaking a write command, since the cached value
of the HLL is exposed in the data structure (design error, mea culpa), and
can be modified by PFCOUNT.

However if we flag PFCOUNT as "w", read only slaves can't execute the
command, which is a problem since there are environments where slaves
are used to scale PFCOUNT reads.

Nor it is possible to just prevent PFCOUNT to modify the data structure
in slaves, since without the cache we lose too much efficiency.

So while this commit allows slaves to create a temporary inconsistency
(the strings representing the HLLs in the master and slave can be
different in certain moments) it is actually harmless.

In the long run this should be probably fixed by turning the HLL into a
more opaque representation, for example by storing the cached value in
the part of the string which is not exposed (this should be possible
with SDS strings).
2014-12-02 17:01:53 +01:00
antirez
868f40c165 Check THP support at startup and warn about it. 2014-11-12 11:17:44 +01:00
antirez
6bbeb8c535 Diskless sync delay is now configurable. 2014-10-29 14:26:48 +01:00
antirez
1472c68212 Diskless replication: redis.conf and CONFIG SET/GET support. 2014-10-29 14:26:47 +01:00
antirez
4d5f4684c1 Diskless replication flag renamed repl_diskless -> repl_diskless_sync. 2014-10-29 14:26:47 +01:00
antirez
30231ea005 Diskless replication: RDB -> slaves transfer draft implementation. 2014-10-29 14:26:47 +01:00
antirez
052da718ad Define different types of RDB childs.
We need to remember what is the saving strategy of the current RDB child
process, since the configuration may be modified at runtime via CONFIG
SET and still we'll need to understand, when the child exists, what to
do and for what goal the process was initiated: to create an RDB file
on disk or to write stuff directly to slave's sockets.
2014-10-29 14:26:47 +01:00
T.J. Schuck
f30136f206 Fix typo radis -> redis
Closes #1938
2014-10-06 10:07:02 +02:00
Juarez Bochi
84846beaae Fix typo
Closes #1682
2014-10-06 10:06:43 +02:00
antirez
d4c3c1248f Cluster: new option to work with partial slots coverage. 2014-09-19 14:22:00 +02:00
antirez
ef61ab6347 Don't propagate SAVE.
This is a general fix (check that dirty delta is positive) but actually
should have as the only effect fixing the SAVE propagation to
AOF and slaves.
2014-09-17 10:01:01 +02:00
antirez
ea1de5cdf9 AOF ability to load truncated files. 2014-09-08 10:57:03 +02:00
Matt Stancliff
601e06da8a Deny CLIENT command in scripts
We don't want scripts doing CLIENT SETNAME
or CLIENT KILL or CLIENT LIST or CLIENT PAUSE.

Originally reported by Chris Wj then proper
action inspired by Itamar Haber.

Reference: https://groups.google.com/forum/#!topic/redis-db/09B2EYwyVgk
2014-08-26 10:41:03 +02:00
Matt Stancliff
21fb95b91e Sentinel: Reject config from STDIN
Sentinel needs to die with a more accurate error message
when attempted to open a config from STDIN.

See: https://groups.google.com/forum/#!topic/redis-db/sYx7VNMWaNM
2014-08-26 10:41:03 +02:00
Matt Stancliff
7df0636514 Remove unused global variable
It has an important name, but nothing uses it...
2014-08-26 10:41:03 +02:00
David Palm
55672e06fd Extend range of bytesToHuman to TB and PB
Also adds a fallthrough case for when given
large values (like overflow numbers of 2^64 by mistake).

Closes #858
2014-08-26 10:41:03 +02:00
antirez
d34fade2da Remove warnings and improve integer sign correctness. 2014-08-26 10:41:02 +02:00
cubicdaiya
d1bf997d1c Use 'void' for zero-argument functions
According to the C standard,
it is desirable to give the type 'void'
to functions have no argument.

Closes #1631
2014-08-26 10:41:02 +02:00
Kashif Rasul
54e054fff3 Fix issues raised by clang analyzer
Modified by @antirez since the original fix to genInfoString() looked
weak. Probably the clang analyzer complained about `section` being
possibly NULL, and strcasecmp() called with a NULL pointer. In the
practice this can never happen, still for the sake of correctness
the right fix is not to modify only the first call, but to set `section`
to the value of "default" if it happens to be NULL.

Closes #1660
2014-08-26 10:41:02 +02:00
antirez
59c084860d Force quit when receiving a second SIGINT.
Also quit ASAP when we are still loading a DB, since care is not needed
in this special condition, especially for a SIGINT.
2014-08-26 10:41:01 +02:00
Matt Stancliff
5bc57330cd Add graceful exit when Ctrl-C is received 2014-08-26 10:41:01 +02:00
Matt Robenolt
9d30ffa405 Fix spelling of "stand alone" in ascii art
Also unified the logic to match `genRedisInfoString`
2014-07-28 14:55:10 +02:00
antirez
29e1c431bd PING: backward compatible error for wrong number of args. 2014-07-18 12:20:56 +02:00
antirez
2264b9816c Variadic PING with support for Pub/Sub.
PING can now be called with an additional arugment, behaving exactly
like the ECHO command. PING can now also be called in Pub/Sub mode (with
one more more subscriptions to channels / patterns) in order to trigger
the delivery of an asynchronous pong message with the optional payload.

This fixes issue #420.
2014-07-18 12:20:56 +02:00
antirez
23c1408963 PubSub clients refactoring and new PUBSUB flag.
The code tested many times if a client had active Pub/Sub subscriptions
by checking the length of a list and dictionary where the patterns and
channels are stored. This was substituted with a client flag called
REDIS_PUBSUB that is simpler to test for. Moreover in order to manage
this flag some code was refactored.

This commit is believed to have no effects in the behavior of the
server.
2014-07-18 12:20:56 +02:00
michael-grunder
d75fc09354 Fix OBJECT arity
Previously, the command definition for the OBJECT command specified
a minimum of two args (and that it was variadic), which meant that
if you sent this:

OBJECT foo

When cluster was enabled, it would result in an assertion/SEGFAULT
when Redis was attempting to extract keys.

It appears that OBJECT is not variadic, and only ever takes 3 args.

https://gist.github.com/michael-grunder/25960ce1508396d0d36a
2014-07-18 12:20:56 +02:00
antirez
a117fd2a44 LATENCY DOCTOR first implementation complete. 2014-07-18 12:20:56 +02:00
antirez
2b5a0e8066 Latency monitor: more hooks around the code. 2014-07-18 12:20:55 +02:00
antirez
485a5908c0 Latency monitor: command duration is in useconds. Convert. 2014-07-18 12:20:55 +02:00