According to unix manuals, "Connecting to the socket object requires
read/write permission." -- mode 755 is useless for anybody
other than the owner.
Fixes#1696
Because of output buffer limits Redis internals had this idea of type of
clients: normal, pubsub, slave. It is possible to set different output
buffer limits for the three kinds of clients.
However all the macros and API were named after output buffer limit
classes, while the idea of a client type is a generic one that can be
reused.
This commit does two things:
1) Rename the API and defines with more general names.
2) Change the class of clients executing the MONITOR command from "slave"
to "normal".
"2" is a good idea because you want to have very special settings for
slaves, that are not a good idea for MONITOR clients that are instead
normal clients even if they are conceptually slave-alike (since it is a
push protocol).
The backward-compatibility breakage resulting from "2" is considered to
be minimal to care, since MONITOR is a debugging command, and because
anyway this change is not going to break the format or the behavior, but
just when a connection is closed on big output buffer issues.
This is safer as by default maxmemory should just set a memory limit
without any key to be deleted, unless the policy is set to something
more relaxed.
In high RPS environments, the default listen backlog is not sufficient, so
giving users the power to configure it is the right approach, especially
since it requires only minor modifications to the code.
IPv6 support is not going to use IPv6 specific options, just it will be
possible to specify all the ipv4 / ipv6 addresses of the interfaces to
bind, otherwise connections will be accepted from all the interfaces in
both IPv4 and IPv6 addresses.
This reverts commit 93570e179e.
This feature allows the user to specify the minimum number of
connected replicas having a lag less or equal than the specified
amount of seconds for writes to be accepted.
Also the logfile option was modified to always have an explicit value
and to log to stdout when an empty string is used as log file.
Previously there was special handling of the string "stdout" that set
the logfile to NULL, this always required some special handling.
When keyspace events are enabled, the overhead is not sever but
noticeable, so this commit introduces the ability to select subclasses
of events in order to avoid to generate events the user is not
interested in.
The events can be selected using redis.conf or CONFIG SET / GET.
REDIS_HZ is the frequency our serverCron() function is called with.
A more frequent call to this function results into less latency when the
server is trying to handle very expansive background operations like
mass expires of a lot of keys at the same time.
Redis 2.4 used to have an HZ of 10. This was good enough with almost
every setup, but the incremental key expiration algorithm was working a
bit better under *extreme* pressure when HZ was set to 100 for Redis
2.6.
However for most users a latency spike of 30 milliseconds when million
of keys are expiring at the same time is acceptable, on the other hand a
default HZ of 100 in Redis 2.6 was causing idle instances to use some
CPU time compared to Redis 2.4. The CPU usage was in the order of 0.3%
for an idle instance, however this is a shame as more energy is consumed
by the server, if not important resources.
This commit introduces HZ as a runtime parameter, that can be queried by
INFO or CONFIG GET, and can be modified with CONFIG SET. At the same
time the default frequency is set back to 10.
In this way we default to a sane value of 10, but allows users to
easily switch to values up to 500 for near real-time applications if
needed and if they are willing to pay this small CPU usage penalty.
Two limits are added:
1) Up to SLOWLOG_ENTRY_MAX_ARGV arguments are logged.
2) Up to SLOWLOG_ENTRY_MAX_STRING bytes per argument are logged.
3) slowlog-max-len is set to 128 by default (was 1024).
The number of remaining arguments / bytes is logged in the entry
so that the user can understand better the nature of the logged command.
This commit introduces support for read only slaves via redis.conf and CONFIG GET/SET commands. Also various semantical fixes are implemented here:
1) MULTI/EXEC with only read commands now work where the server is into a state where writes (or commands increasing memory usage) are not allowed. Before this patch everything inside a transaction would fail in this conditions.
2) Scripts just calling read-only commands will work against read only
slaves, when the server is out of memory, or when persistence is into an
error condition. Before the patch EVAL always failed in this condition.
Added a configuration directive to allow a user to specify the
permissions to be granted to the Unix socket file. I followed
the format Pieter and Salvatore discusses in issue #85 (
https://github.com/antirez/redis/issues/85).
$ make
cc -c -O2 -Wall -W -DSDS_ABORT_ON_OOM -g adlist.c
cc -c -O2 -Wall -W -DSDS_ABORT_ON_OOM -g ae.c
cc -c -O2 -Wall -W -DSDS_ABORT_ON_OOM -g anet.c
cc -c -O2 -Wall -W -DSDS_ABORT_ON_OOM -g dict.c
cc -c -O2 -Wall -W -DSDS_ABORT_ON_OOM -g redis.c
cc -c -O2 -Wall -W -DSDS_ABORT_ON_OOM -g sds.c
cc -c -O2 -Wall -W -DSDS_ABORT_ON_OOM -g zmalloc.c
cc -o redis-server -O2 -Wall -W -DSDS_ABORT_ON_OOM -g adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o
Hint: To run the test-redis.tcl script is a good idea.
Launch the redis server with ./redis-server, then in another
terminal window enter this directory and run 'make test'.
cc -c -O2 -Wall -W -DSDS_ABORT_ON_OOM -g benchmark.c
cc -o redis-benchmark -O2 -Wall -W -DSDS_ABORT_ON_OOM -g ae.o anet.o benchmark.o sds.o adlist.o zmalloc.o
cc -c -O2 -Wall -W -DSDS_ABORT_ON_OOM -g redis-cli.c
cc -o redis-cli -O2 -Wall -W -DSDS_ABORT_ON_OOM -g anet.o sds.o adlist.o redis-cli.o zmalloc.o
$ tail -1 redis.conf
$ ./redis-server redis.conf &
[1] 52494
$ - Server started, Redis version 0.08
- DB loaded from disk
- The server is now ready to accept connections on port 6379
. 0 clients connected (0 slaves), 1932 bytes in use
$ make test
tclsh test-redis.tcl
DEL all keys to start with a clean DB . Accepted 127.0.0.1:54490
PASSED
SET and GET an item PASSED
DEL against a single item PASSED
KEYS with pattern PASSED
KEYS to get all keys PASSED
DBSIZE PASSED
DEL all keys PASSED
Very big payload in GET/SET PASSED
SET 10000 numeric keys and access all them in reverse order . DB 0: 10001 keys in 16384 slots HT.
. 1 clients connected (0 slaves), 4885707 bytes in use
PASSED
DBSIZE should be 10001 now PASSED
INCR against non existing key PASSED
INCR against key created by incr itself PASSED
INCR against key originally set with SET PASSED
SETNX target key missing PASSED
SETNX target key exists PASSED
EXISTS PASSED
Zero length value in key. SET/GET/EXISTS PASSED
Commands pipelining PASSED
Non existing command PASSED
Basic LPUSH, RPUSH, LLENGTH, LINDEX PASSED
DEL a list PASSED
Create a long list and check every single element with LINDEX PASSED
Test elements with LINDEX in random access PASSED
LLEN against non-list value error PASSED
LINDEX against non-list value error PASSED
LPUSH against non-list value error PASSED
RPUSH against non-list value error PASSED
RENAME basic usage PASSED
RENAME source key should no longer exist PASSED
RENAME against already existing key PASSED
RENAMENX basic usage PASSED
RENAMENX against already existing key PASSED
RENAMENX against already existing key (2) PASSED
RENAME against non existing source key PASSED
RENAME where source and dest key is the same PASSED
DEL all keys again (DB 0) PASSED
DEL all keys again (DB 1) PASSED
MOVE basic usage PASSED
MOVE against key existing in the target DB PASSED
SET/GET keys in different DBs PASSED
Basic LPOP/RPOP PASSED
LPOP/RPOP against empty list PASSED
LPOP against non list value PASSED
Mass LPUSH/LPOP PASSED
LRANGE basics PASSED
LRANGE inverted indexes PASSED
LRANGE out of range indexes including the full list PASSED
LRANGE against non existing key PASSED
LTRIM basics PASSED
LSET PASSED
LSET out of range index PASSED
LSET against non existing key PASSED
LSET against non list value PASSED
SADD, SCARD, SISMEMBER, SMEMBERS basics PASSED
SADD adding the same element multiple times PASSED
SADD against non set PASSED
SREM basics PASSED
Mass SADD and SINTER with two sets PASSED
SINTERSTORE with two sets PASSED
SINTER against three sets PASSED
SINTERSTORE with three sets PASSED
SAVE - make sure there are all the types as values - DB saved on disk
PASSED
Create a random list . DB 0: 6057 keys in 16384 slots HT.
. DB 1: 3 keys in 16 slots HT.
. 1 clients connected (0 slaves), 1045147 bytes in use
PASSED
SORT with BY against the newly created list PASSED
SORT direct, numeric, against the newly created list PASSED
SORT decreasing sort PASSED
SORT speed, sorting 10000 elements list using BY, 100 times
Average time to sort: 5.28 milliseconds PASSED
SORT speed, sorting 10000 elements list directly, 100 times
Average time to sort: 1.53 milliseconds PASSED
SORT speed, pseudo-sorting 10000 elements list, BY <const>, 100 times
Average time to sort: 0.47 milliseconds PASSED
SORT regression for issue #19, sorting floats - DB saved on disk
PASSED
LREM, remove all the occurrences - DB saved on disk
PASSED
LREM, remove the first occurrence PASSED
LREM, remove non existing element PASSED
LREM, starting from tail with negative count - DB saved on disk
PASSED
LREM, starting from tail with negative count (2) PASSED
MGET - DB saved on disk
PASSED
MGET against non existing key PASSED
MGET against non-string key PASSED
FLUSHALL - DB saved on disk
PASSED
79 tests, 79 passed, 0 failed
. Client closed connection
. 0 clients connected (0 slaves), 1347660 bytes in use
$ kill -15 %1
[1]+ Terminated ./redis-server redis.conf
$ vim redis.conf
$ tail -1 redis.conf
requirepass foobared
$ ./redis-server redis.conf &
[1] 52518
$ - Server started, Redis version 0.08
- DB loaded from disk
- The server is now ready to accept connections on port 6379
. 0 clients connected (0 slaves), 1945 bytes in use
$ make test
tclsh test-redis.tcl
. Accepted 127.0.0.1:54492
DEL all keys to start with a clean DB
ERR operation not permitted
while executing
"::redis::redis_read_reply $fd"
(procedure "::redis::__dispatch__" line 13)
invoked from within
"$r keys *"
("uplevel" body line 2)
invoked from within
"uplevel 1 $code"
(procedure "test" line 4)
invoked from within
"test {DEL all keys to start with a clean DB} {
foreach key [$r keys *] {$r del $key}
$r dbsize
} {0}"
(procedure "main" line 13)
invoked from within
"main 127.0.0.1 6379"
invoked from within
"if {[llength $argv] == 0} {
main 127.0.0.1 6379
} elseif {[llength $argv] == 1 && [lindex $argv 0] eq {stress}} {
stress
} else {
main [li..."
(file "test-redis.tcl" line 630)
. Client closed connection
make: *** [test] Error 1
. 0 clients connected (0 slaves), 2041 bytes in use
. 0 clients connected (0 slaves), 2041 bytes in use
$ kill -15 %1
[1]+ Terminated ./redis-server redis.conf
$ vim test-redis.tcl
$ git diff test-redis.tcl