387 Commits

Author SHA1 Message Date
antirez
9e258a4438 Extended SET command implemented (issue #931). 2013-03-28 15:40:19 +01:00
antirez
b9e31495c4 DEBUG set-active-expire added.
We need the ability to disable the activeExpireCycle() (active
expired key collection) call for testing purposes.
2013-03-27 17:55:02 +01:00
antirez
50ebef7662 Allow SELECT while loading the DB.
Fixes issue #1024.
2013-03-26 13:51:17 +01:00
antirez
e4dd64c3ae Flag PUBLISH as read-only in the command table. 2013-03-26 11:09:22 +01:00
antirez
dab342a215 Replication: master_link_down_since_seconds initial value should be huge.
server.repl_down_since used to be initialized to the current time at
startup. This is wrong since the replication never started. Clients
testing this filed to check if data is uptodate should never believe
data is recent if we never ever connected to our master.
2013-03-13 12:54:48 +01:00
Salvatore Sanfilippo
1e1afe05ed Merge pull request #1001 from djanowski/fatal-errors-rdb-load
Abort when opening the RDB file results in an error other than ENOENT.
2013-03-12 11:40:36 -07:00
Damian Janowski
cce75561a0 Abort when opening the RDB file results in an error other than ENOENT.
This fixes cases where the RDB file does exist but can't be accessed for
any reason. For instance, when the Redis process doesn't have enough
permissions on the file.
2013-03-12 14:37:50 -03:00
antirez
3ff21be010 Set default for stop_writes_on_bgsave_err in initServerConfig().
It was placed for error in initServer() that's called after the
configuation is already loaded, causing issue #1000.
2013-03-12 18:34:08 +01:00
antirez
87ff41b306 activeExpireCycle() smarter with many DBs and under expire pressure.
activeExpireCycle() tries to test just a few DBs per iteration so that
it scales if there are many configured DBs in the Redis instance.
However this commit makes it a bit smarter when one a few of those DBs
are under expiration pressure and there are many many keys to expire.

What we do is to remember if in the last iteration had to return because
we ran out of time. In that case the next iteration we'll test all the
configured DBs so that we are sure we'll test again the DB under
pressure.

Before of this commit after some mass-expire in a given DB the function
tested just a few of the next DBs, possibly empty, a few per iteration,
so it took a long time for the function to reach again the DB under
pressure. This resulted in a lot of memory being used by already expired
keys and never accessed by clients.
2013-03-11 11:10:33 +01:00
antirez
667aaa6469 In databasesCron() never test more DBs than we have. 2013-03-11 10:51:03 +01:00
antirez
289f6d5d2b Make comment name match var name in activeExpireCycle(). 2013-03-11 10:42:14 +01:00
antirez
05f0492a03 Optimize inner loop of activeExpireCycle() for no-expires case. 2013-03-09 11:48:54 +01:00
antirez
dc1e158648 REDIS_DBCRON_DBS_PER_SEC -> REDIS_DBCRON_DBS_PER_CALL 2013-03-09 11:44:20 +01:00
antirez
af9463ceaf activeExpireCycle(): process only a small number of DBs per iteration.
This small number of DBs is set to 16 so actually in the default
configuraiton Redis should behave exactly like in the past.
However the difference is that when the user configures a very large
number of DBs we don't do an O(N) operation, consuming a non trivial
amount of CPU per serverCron() iteration.
2013-03-08 17:48:58 +01:00
antirez
c77e24aab9 Use unsigned integers for DB ids, for defined wrap-to-zero. 2013-03-08 17:41:20 +01:00
antirez
51c65e01ea Only resize/rehash a few databases per cron iteration.
This is the first step to lower the CPU usage when many databases are
configured. The other is to also process a limited number of DBs per
call in the active expire cycle.
2013-03-08 14:01:12 +01:00
antirez
3f75c20dac Actually call databasesCron() inside serverCron(). 2013-03-08 13:59:50 +01:00
antirez
3bd3c5303e Move Redis databases background processing to databasesCron(). 2013-03-08 12:34:05 +01:00
antirez
9076bf9d4b API to lookup commands with their original name.
A new server.orig_commands table was added to the server structure, this
contains a copy of the commant table unaffected by rename-command
statements in redis.conf.

A new API lookupCommandOrOriginal() was added that checks both tables,
new first, old later, so that rewriteClientCommandVector() and friends
can lookup commands with their new or original name in order to fix the
client->cmd pointer when the argument vector is renamed.

This fixes the segfault of issue #986, but does not fix a wider range of
problems resulting from renaming commands that actually operate on data
and are registered into the AOF file or propagated to slaves... That is
command renaming should be handled with care.
2013-03-06 16:28:26 +01:00
antirez
dfab43fbbf Allow AUTH while loading the DB in memory.
While Redis is loading the AOF or RDB file in memory only a subset of
commands are allowed. This commit adds AUTH to this subset.
2013-03-06 11:50:38 +01:00
antirez
61885aa646 Cluster: don't check keys hash slots when the source is our master.
Usually we redirect clients to the right hash slot, however we don't
want to do that with our master, we want just to mirror it.
2013-03-05 13:02:44 +01:00
antirez
cabbb64d80 Remove warning when printing redisBuildId(). 2013-02-27 12:33:27 +01:00
antirez
646785ae48 Use GCC printf format attribute for redisLog().
This commit also fixes redisLog() statements producing warnings.
2013-02-27 12:27:15 +01:00
antirez
3fe686b697 Better panic message for failed time event creation. 2013-02-27 12:00:11 +01:00
Stam He
df3489aeb7 add a check for aeCreateTimeEvent
1) Add a check for aeCreateTimeEvent in function initServer.
2013-02-27 11:57:35 +01:00
Stam He
2fabb412ca Set proctitle: avoid the use of __attribute__((constructor)).
This cased a segfault in some Linux system and was GCC-specific.

Commit modified by @antirez:

1) Stripped away the part to set the proc title via config for now.
2) Handle initialization of setproctitle only when the replacement
   is used.
3) Don't require GCC now that the attribute constructor is no
   longer used.
2013-02-27 11:50:35 +01:00
antirez
6386d8ffc3 Set process name in ps output to make operations safer.
This commit allows Redis to set a process name that includes the binding
address and the port number in order to make operations simpler.

Redis children processes doing AOF rewrites or RDB saving change the
name into redis-aof-rewrite and redis-rdb-bgsave respectively.

This in general makes harder to kill the wrong process because of an
error and makes simpler to identify saving children.

This feature was suggested by Arnaud GRANAL in the Redis Google Group,
Arnaud also pointed me to the setproctitle.c implementation includeed in
this commit.

This feature should work on all the Linux, OSX, and all the three major
BSD systems.
2013-02-26 11:52:12 +01:00
antirez
1acb543576 A comment in main() clarified. 2013-02-25 11:40:21 +01:00
antirez
0b86a5e2d1 Cluster: added stub for verifyClusterConfigWithData().
See the top-comment for the function in this commit for details about
what the function is supposed to do.
2013-02-25 11:20:17 +01:00
antirez
a9624604ed Cluster: new command flag forcing implicit ASKING.
Also using this new flag the RESTORE-ASKING command was implemented that
will be used by MIGRATE.
2013-02-20 17:28:35 +01:00
antirez
cf24a53850 Cluster: specific error code for cluster down condition. 2013-02-15 16:53:24 +01:00
antirez
2531fea2a5 Cluster: the cluster state structure is now heap allocated. 2013-02-14 13:20:56 +01:00
antirez
cb6ff7f5d1 Return a specific NOAUTH error if authentication is required. 2013-02-12 16:25:41 +01:00
antirez
12a3bf6245 Replication: added new stats counting full and partial resynchronizations. 2013-02-12 15:33:54 +01:00
antirez
75512d94d9 PSYNC: work in progress, preview #2, rebased to unstable. 2013-02-12 12:52:21 +01:00
antirez
4860dda15d Use the new unified protocol to send SELECT to slaves.
SELECT was still transmitted to slaves using the inline protocol, that
is conceived mostly for humans to type into telnet sessions, and is
notably not understood by redis-cli --slave.

Now the new protocol is used instead.
2013-02-12 12:50:28 +01:00
antirez
08d5aa6a20 Emit SELECT to slaves in a centralized way.
Before this commit every Redis slave had its own selected database ID
state. This was not actually useful as the emitted stream of commands
is identical for all the slaves.

Now the the currently selected database is a global state that is set to
-1 when a new slave is attached, in order to force the SELECT command to
be re-emitted for all the slaves.

This change is useful in order to implement replication partial
resynchronization in the future, as makes sure that the stream of
commands received by slaves, including SELECT commands, are exactly the
same for every slave connected, at any time.

In this way we could have a global offset that can identify a specific
piece of the master -> slaves stream of commands.
2013-02-12 12:50:28 +01:00
antirez
96ef42d768 Set SO_KEEPALIVE on client sockets if configured to do so. 2013-02-08 16:40:59 +01:00
antirez
282a4d850e LASTSAVE is a "random" command. 2013-02-07 19:13:00 +01:00
antirez
d698a264d2 TCP_NODELAY after SYNC: changes to the implementation. 2013-02-05 12:04:30 +01:00
charsyam
6c7473623e Turn off TCP_NODELAY on the slave socket after SYNC.
Further details from @antirez:

It was reported by @StopForumSpam on Twitter that the Redis replication
link was strangely using multiple TCP packets for multiple commands.
This wastes a lot of bandwidth and is due to the TCP_NODELAY option we
enable on the socket after accepting a new connection.

However the master -> slave channel is a one-way channel since Redis
replication is asynchronous, so there is no point in trying to reduce
the latency, we should aim to reduce the bandwidth. For this reason this
commit introduces the ability to disable the nagle algorithm on the
socket after a successful SYNC.

This feature is off by default because the delay can be up to 40
milliseconds with normally configured Linux kernels.
2013-02-05 12:04:25 +01:00
Salvatore Sanfilippo
1bb892571f Merge pull request #914 from catwell/unstable
fix comments forgotten in #285 (zipmap -> ziplist)
2013-01-31 03:37:48 -08:00
antirez
f28d386cc5 Keyspace events: it is now possible to select subclasses of events.
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.
2013-01-28 13:15:12 +01:00
antirez
ccef29ae2c Initial test events for the new keyspace notification API. 2013-01-28 13:14:46 +01:00
antirez
766a541a0a Keyspace events notification API. 2013-01-28 13:14:36 +01:00
Pierre Chapuis
d1f1aab148 fix comments forgotten in #285 (zipmap -> ziplist) 2013-01-28 11:07:17 +01:00
antirez
247df4e83b Whitelist SIGUSR1 to avoid auto-triggering errors.
This commit fixes issue #875 that was caused by the following events:

1) There is an active child doing BGSAVE.
2) flushall is called (or any other condition that makes Redis killing
the saving child process).
3) An error is sensed by Redis as the child exited with an error (killed
by a singal), that stops accepting write commands until a BGSAVE happens
to be executed with success.

Whitelisting SIGUSR1 and making sure Redis always uses this signal in
order to kill its own children fixes the issue.
2013-01-19 13:30:38 +01:00
antirez
032d99e191 Clear server.shutdown_asap on failed shutdown.
When a SIGTERM is received Redis schedules a shutdown. However if it
fails to perform the shutdown it must be clear the shutdown_asap flag
otehrwise it will try again and again possibly making the server
unusable.
2013-01-19 13:19:41 +01:00
antirez
31615e9ecf Slowlog: don't log EXEC but just the executed commands.
The Redis Slow Log always used to log the slow commands executed inside
a MULTI/EXEC block. However also EXEC was logged at the end, which is
perfectly useless.

Now EXEC is no longer logged and a test was added to test this behavior.

This fixes issue #759.
2013-01-19 12:53:21 +01:00
guiquanz
df7a5b7157 Fixed many typos. 2013-01-19 10:59:44 +01:00