Commit Graph

357 Commits

Author SHA1 Message Date
antirez
179e54d2a9 Fix for slaves chains. Force resync of slaves (simply disconnecting them) when SLAVEOF turns a master into a slave. 2012-03-29 09:24:02 +02:00
antirez
a7d12cbaf1 Log from signal handlers is now safer. 2012-03-28 13:45:39 +02:00
antirez
1043c8064b Merge branch 'watchdog' into unstable 2012-03-28 13:16:19 +02:00
Premysl Hruby
8af9fe841c declare hashDictType as external too 2012-03-27 18:18:57 +02:00
antirez
39bd025c29 Redis software watchdog. 2012-03-27 11:47:51 +02:00
antirez
c1d01b3c57 New INFO field aof_delayed_fsync introduced.
This new field counts all the times Redis is configured with AOF enabled and
fsync policy 'everysec', but the previous fsync performed by the
background thread was not able to complete within two seconds, forcing
Redis to perform a write against the AOF file while the fsync is still
in progress (likely a blocking operation).
2012-03-25 11:27:35 +02:00
antirez
f3fd419fc9 Support for read-only slaves. Semantical fixes.
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.
2012-03-20 17:32:48 +01:00
antirez
ae22bf1ef6 Reclaim space from the client querybuf if needed. 2012-03-14 15:32:30 +01:00
antirez
e74dca73d9 Client creation time in redisClient structure. New age field in CLIENT LIST output. 2012-03-13 13:05:08 +01:00
antirez
8562798308 Merge conflicts resolved. 2012-03-09 22:07:45 +01:00
antirez
250e7f6908 Instantaneous ops/sec figure in INFO output. 2012-03-08 16:15:37 +01:00
antirez
91d664d6ce run_id added to INFO output.
The Run ID is a field that identifies a single execution of the Redis
server. It can be useful for many purposes as it makes easy to detect if
the instance we are talking about is the same, or if it is a different
one or was rebooted. An application of run_id will be in the partial
synchronization of replication, where a slave may request a partial sync
from a given offset only if it is talking with the same master. Another
application is in failover and monitoring scripts.
2012-03-08 10:13:36 +01:00
antirez
44f508f1a8 clusterGetRandomName() generalized into getRandomHexChars() so that we can use it for the run_id field as well. 2012-03-08 10:08:44 +01:00
antirez
4d3bbf3590 By default Redis refuses writes with an error if the latest BGSAVE failed (and at least one save point is configured). However people having good monitoring systems may prefer a server that continues to work, since they are notified that there are problems by their monitoring systems. This commit implements the ability to turn the feature on or off via redis.conf and CONFIG SET. 2012-03-07 18:02:26 +01:00
antirez
c25e7eafef Refuse writes if can't persist on disk.
Redis now refuses accepting write queries if RDB persistence is
configured, but RDB snapshots can't be generated for some reason.
The status of the latest background save operation is now exposed
in the INFO output as well. This fixes issue #90.
2012-03-07 13:05:53 +01:00
antirez
e31b615e62 Better MONITOR output, now includes client ip:port or the lua string if the command was executed by the scripting engine. 2012-03-07 12:12:15 +01:00
antirez
9494f1f15b TIME command. 2012-03-07 10:38:01 +01:00
antirez
c1db214eeb Better implementation for BRPOP/BLPOP in the non blocking case. 2012-02-29 14:41:57 +01:00
antirez
78d6a22dc3 Better system for additional commands replication.
The new code uses a more generic data structure to describe redis operations.
The new design allows for multiple alsoPropagate() calls within the scope of a
single command, that is useful in different contexts. For instance there
when there are multiple clients doing BRPOPLPUSH against the same list,
and a variadic LPUSH is performed against this list, the blocked clients
will both be served, and we should correctly replicate multiple LPUSH
commands after the replication of the current command.
2012-02-29 00:46:50 +01:00
antirez
eeb34eff52 Added a new API to replicate an additional command after the replication of the currently executed command, in order to propagte the LPUSH originating from RPOPLPUSH and indirectly by BRPOPLPUSH. 2012-02-28 18:03:08 +01:00
antirez
d8b1228bf6 propagate() prototype added to redis.h 2012-02-28 16:20:41 +01:00
antirez
ad08d059d0 Added command propagation API. 2012-02-28 16:17:00 +01:00
antirez
8b7c3455b9 freeMemoryIfNeeded() minor refactoring 2012-02-06 16:56:42 +01:00
antirez
f6b32c14f4 This fixes issue #327, is a very complex fix (unfortunately), details:
1) sendReplyToClient() now no longer stops transferring data to a single
client in the case we are out of memory (maxmemory-wise).

2) in processCommand() the idea of we being out of memory is no longer
the naive zmalloc_used_memory() > server.maxmemory. To say if we can
accept or not write queries is up to the return value of
freeMemoryIfNeeded(), that has full control about that.

3) freeMemoryIfNeeded() now does its math without considering output
buffers size. But at the same time it can't let the output buffers to
put us too much outside the max memory limit, so at the same time it
makes sure there is enough effort into delivering the output buffers to
the slaves, calling the write handler directly.

This three changes are the result of many tests, I found (partially
empirically) that is the best way to address the problem, but maybe
we'll find better solutions in the future.
2012-02-04 14:05:54 +01:00
antirez
355f859134 Use less memory when emitting the protocol, by using more shared objects for commonly emitted parts of the protocol. 2012-02-04 08:58:37 +01:00
antirez
ce8b772be7 Now Lua scripts dispatch Redis commands properly calling the call() function. In order to make this possible call() was improved with a new flags argument that controls how the Redis command is executed. 2012-02-02 16:30:52 +01:00
antirez
75eaac5c74 Added a server.arch_bits field instead of computing it at runtime for INFO. 2012-02-02 10:23:31 +01:00
antirez
2c861050c1 SORT is now more deterministic: does not accept to compare by score items that have scores not representing a valid double. Also items with the same score are compared lexycographically. At the same time the scripting side introduced the ability to sort the output of SORT when sort uses the BY <constant> optimization, resulting in no specific ordering. Since in this case the user may use GET, and the result of GET can be null, converted into false as Lua data type, this commit also introduces the ability to sort Lua tables containining false, only if the first (faster) attempt at using just table.sort with a single argument fails. 2012-02-01 15:22:28 +01:00
antirez
548efd91e5 Order output of commands returning random arrays using table.sort when called from Lua, partially fixing issue #165. The issue is yet not completely fixed since we can't add the REDIS_CMD_SORT_FOR_SCRIPT flag in SORT currently, both because it may contain NULLs and because it is not cool to re-sort everything at every call when instead this should be sorted only if BY <constant> is used. 2012-01-31 16:09:21 +01:00
antirez
3c08fdae71 64 bit instances are no longer limited to have at max 2^32-1 elements in lists. 2012-01-31 10:35:52 +01:00
antirez
7fe8d49a70 Client output buffer limits: configuration of parameters for the different classes of clients implemented. 2012-01-24 10:43:30 +01:00
antirez
06b3dced99 asyncCloseClientOnOutputBufferLimitReached() now ignores clients with REDIS_CLOSE_ASAP flag already set. Return value of the function changed from int to void since it is not used. Fixed logging of the client scheduled to be closed. 2012-01-24 09:32:39 +01:00
antirez
7eac2a75a4 Implementation of the internals that make possible to terminate clients overcoming configured output buffer (soft and hard) limits. 2012-01-23 16:12:37 +01:00
antirez
890da62eea Merge branch 'unstable' into limits 2012-01-23 10:36:07 +01:00
antirez
eea8c7a4f8 added support to dump registers on crash on Linux x64 2012-01-20 12:54:15 +01:00
antirez
d4d208595c all the stack trace related functions are now in debug.c. Now Redis dumps registers and stack content on crash. Currently osx supported, adding Linux right now. 2012-01-20 12:20:45 +01:00
antirez
498dc5557c Introduced three client limit classes: normal, slave, pubsub 2012-01-17 12:43:01 +01:00
antirez
3853c16839 Track the length of the client pending output buffers (still to transfer) in a new field in the client structure. 2012-01-17 12:23:25 +01:00
antirez
00010fa96f On crash print information about the current client (if any), command vector, and object associated to first argument assuming it is a key. 2012-01-12 16:02:57 +01:00
Pieter Noordhuis
ebd85e9a45 Encode small hashes with a ziplist 2012-01-02 22:14:10 -08:00
antirez
11e0c4c55b Protections against protocol desyncs, leading to infinite query buffer growing, due to nul-terms in specific bytes of the request or indefinitely long multi bulk or bulk count strings without newlines. This bug is related to Issue #141 as well. 2011-12-31 16:09:46 +01:00
antirez
f42e2f1bd7 Protocol and I/O related defines moved into a separated section of redis.h 2011-12-31 15:37:33 +01:00
antirez
35c6032cfa A few no longer used defines removed from redis.h 2011-12-31 15:34:02 +01:00
antirez
1824e3a3a3 Fixed replication when multiple slaves are attaching at the same time. The output buffer was not copied correctly between slaves. This fixes issue #141. 2011-12-30 19:40:43 +01:00
antirez
1844f9900f server.replstate -> server.repl_state 2011-12-21 12:23:18 +01:00
antirez
f48cd4b90c some RDB server struct fields renamed. 2011-12-21 12:22:13 +01:00
antirez
ff2145adac more AOF server struct fields renamed. 2011-12-21 12:17:02 +01:00
antirez
2c915bcf6d AOF fileds in the global server state, and define names, renamed with more consistent names. More work to do. 2011-12-21 11:58:42 +01:00
antirez
e394114d95 AOF refactoring, now with three states: ON, OFF, WAIT_REWRITE. 2011-12-21 10:31:34 +01:00
antirez
c6ac7d0302 server.appendonly -> server.aof_state, and many comments added in the server global state structure in the process. 2011-12-21 10:05:32 +01:00
antirez
e7a2e7c1f7 AOF fixes in the context of replicaiton (when AOF is used by slave) and CONFIG SET appendonly yes/no. 2011-12-15 16:07:49 +01:00
antirez
5b25009656 Lists AOF rewrite using variadic RPUSH (work in progress) 2011-12-13 11:10:21 +01:00
antirez
67c6f0f630 Support for command line configuration options for redis-server. 2011-12-01 13:44:53 +01:00
antirez
fa5af017d9 better bug report info on crash 2011-11-24 15:47:26 +01:00
antirez
45e7a1ce00 minor refactoring to networking.c adding a separated function to get a string representing the current state of all the connected clients. 2011-11-24 15:04:42 +01:00
antirez
2c74a9f948 last executed command in CLIENT LIST output. 2011-11-24 14:56:34 +01:00
antirez
3c95e7212e new counter in INFO output: rejected_connections with number of dropped connections because of maxclients limit reached. 2011-11-23 18:38:12 +01:00
antirez
becf5fdb0c Close client connection and log the event when the client input buffer reaches 1GB. 2011-11-21 16:17:51 +01:00
antirez
4ab8695d53 New script timeout semantics and SCRIPT KILL implemented. SHUTDOWN NOSAVE and SHUTDOWN SAVE implemented. 2011-11-18 14:10:48 +01:00
antirez
68bfe993c8 HINCRBYFLOAT implemented 2011-11-15 15:09:39 +01:00
antirez
d4a3cfed9c Merge branch 'unstable' into incrbyfloat 2011-11-14 15:59:56 +01:00
antirez
5574b53eae INCRBYFLOAT implementation 2011-11-12 19:27:35 +01:00
antirez
3570629f90 set default client timeout to zero inside redis.h as well 2011-11-11 17:18:35 +01:00
antirez
12d293ca6e high resolution expires API modified to use separated commands. AOF transation to PEXPIREAT of all the expire-style commands fixed. 2011-11-10 17:52:02 +01:00
antirez
7dcc10b65e Initial support for key expire times with millisecond resolution. RDB version is now 3, new opcoded added for high resolution times. Redis is still able to correctly load RDB version 2. Tests passing but still a work in progress. API to specify milliseconds expires still missing, but the precision of normal expires is now already improved and working. 2011-11-09 16:51:19 +01:00
antirez
2c2b208537 added mstime() to get UNIX time in milliseconds. 2011-11-09 00:03:03 +01:00
antirez
65330badb9 hiredis/redis changes for speed with big payloads: read buffer size set
to 16k, request buffer size is no longer destroyed when emtpy and large
(better fix needed). Redis clients static output buffer set to 16k as
well.
2011-11-08 10:59:59 +01:00
antirez
94d490b9f6 Added a define to set the size threshold to enable the multi bulk parsing big objects optimization. 2011-11-04 11:16:11 +01:00
antirez
dd5fbedf7b I/O buffer length enlarged 2011-11-02 16:51:33 +01:00
antirez
d569f39a77 removed the vmpointer structure that is no longer user in Redis >= 2.5.x 2011-10-31 15:47:12 +01:00
antirez
aeecbdfae3 1fe4cd5 2011-10-31 11:14:24 +01:00
antirez
8996bf7720 7c6da73 2011-10-31 11:13:28 +01:00
antirez
58732c23d5 maxclients configuration is now implemented dealing with the actual process rlimits. Setting maxclients to 0 no longer makes sense and is now invalid, the new default is 10000.
See issue #162 for more information.
2011-10-31 10:49:27 +01:00
antirez
115e3ff39e If a Lua script executes for more time than the max time specified in the configuration Redis will log a warning, and will start accepting queries (re-entering the event loop), returning -SLOWSCRIPT error for all the commands but SHUTDOWN that remains callable. 2011-10-27 14:49:10 +02:00
antirez
8cb8d417b1 Lau scripts default max execution time set to 5 seconds. 2011-10-25 12:10:15 +02:00
antirez
070e39454d SCRIPT command for introspection and control of the scripting environment. 2011-10-24 22:47:00 +02:00
antirez
6856c7b4d6 First implementation of the ASKING command. Semantics still to verify. 2011-10-17 17:35:23 +02:00
Nathan Florea
8523876503 Added a config directive for a Unix socket mask
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).
2011-10-10 11:21:15 -07:00
antirez
d38ef52085 Redis Cluster: process node to node CLUSTERMSG_TYPE_PUBLISH messages and send it to the local clients. 2011-10-07 16:34:16 +02:00
antirez
c563ce463b propagate PUBLISH messages using the redis cluster nodes bus. Still need to process the incoming packets of that type. Work in progress. 2011-10-07 15:37:34 +02:00
antirez
bab205f787 redisAssertWithClientInfo() is now redisAssertWithInfo() that is also able to report an optional object. The client is also optional. Specifying NULL will prevent dumping the not available information (either client or object). 2011-10-04 18:05:26 +02:00
antirez
e3e6993510 Introduced a redisAssert() variant that is able to show information about the client in the context where the failed assertion was detected. 2011-10-04 17:22:29 +02:00
antirez
9f772cc237 Return errors if a write command is called inside a Lua script after a random command was called. See https://github.com/antirez/redis/issues/95 for more information. 2011-09-27 15:30:31 +02:00
antirez
b60ed6e812 added the NOSCRIPT and RANDOM command flags 2011-09-27 13:45:46 +02:00
antirez
5d02b00f56 command table refactoring to make it simpler adding new flags 2011-09-26 15:40:39 +02:00
antirez
f9c6f39b2b merge conflicts resolved 2011-09-22 15:15:26 +02:00
antirez
a3fcd6bc21 fixed flushAppendOnlyFile() function prototype to reflect the new implementation, fixing compilation. 2011-09-16 12:36:17 +02:00
antirez
db3c2a4fb4 postpone the AOF fsync if policy is everysec and there is a background fsync already going. 2011-09-16 12:35:12 +02:00
antirez
f67e338d5c Removed no longer useful fields in the redis server structure 2011-09-13 16:17:45 +02:00
antirez
4dd444bb4a Replicate EVALSHA as EVAL taking a dictionary of sha1 -> script source code. 2011-07-13 15:38:03 +02:00
antirez
0681c5ad84 master branch merged into scripting. 2011-07-12 12:39:16 +02:00
antirez
09e2d9eeba Take a pointer to the relevant entry of the command table in the client structure. This is generally a more sounding design, simplifies a few functions prototype, and as a side effect fixes a bug related to the conversion of EXPIRE -1 to DEL: before of this fix Redis tried to convert it into an EXPIREAT in the AOF code, regardless of our rewrite of the command. 2011-07-08 12:59:30 +02:00
antirez
2cb6828480 Added an unique ID field to every slow log entry. 2011-06-30 17:36:15 +02:00
antirez
35a6044140 slow log configuration implemented 2011-06-30 15:47:15 +02:00
antirez
daa70b1798 First implementation of the slow log feature 2011-06-30 13:27:32 +02:00
antirez
994ed2bc55 unstable merge conflicts resolved 2011-06-25 12:29:24 +02:00
antirez
c9d0c3623a diskstore removed 2011-06-25 12:22:03 +02:00
antirez
c1c9d551da Fix for bug 561 and other related problems 2011-06-20 17:19:36 +02:00
antirez
f85cd526c1 DB API refactoring. The changes were designed together with Pieter Noordhuis. 2011-06-20 16:42:16 +02:00
antirez
07486df6fe new INFO filed master_link_down_since_seconds 2011-06-17 16:16:46 +02:00
antirez
0d1650f8a9 Updated to unstable 2011-06-14 18:06:39 +02:00
antirez
b333e23997 automatic AOF rewrite first implementation. Still to be tested. 2011-06-10 12:39:23 +02:00
Pieter Noordhuis
632e4c09ac Make replication faster (biggest gain for small number of slaves) 2011-05-30 12:45:07 +02:00
antirez
615e414c5d INFO now contains the time (in usecs) needed to fork() in order to persist. The info is available in the stats section of INFO. 2011-05-29 15:17:29 +02:00
antirez
288f811fea All commands exported by Redis to Lua scripts are now inside the redis table. Implemented redis.log() function. 2011-05-25 12:32:50 +02:00
antirez
7229d60d03 EVALSHA implemented 2011-05-25 12:32:49 +02:00
antirez
eeffcf380f Lua scripts max execution time 2011-05-25 12:32:48 +02:00
antirez
7156f43c04 Correctly glue the reply buffer. For now returned as it is to Lua, but will be converted into Lua native type later. 2011-05-25 12:32:44 +02:00
antirez
0f1d64ca57 Lua call of Redis command work in progress: sorry I have to go to the cinema to watch the Source Code movie 2011-05-25 12:32:44 +02:00
antirez
7585836e6e Lua function creation on EVAL, basic Lua return type to Redis protocol convertion done. 2011-05-25 12:32:43 +02:00
Pieter Noordhuis
890a2ed989 Configurable synchronous I/O timeout 2011-05-22 12:58:18 +02:00
Pieter Noordhuis
b075621fb7 Minor changes in non-blocking repl. connect 2011-05-22 12:51:09 +02:00
Pieter Noordhuis
a330913999 Non-blocking connect with master 2011-05-19 18:54:57 +02:00
Pieter Noordhuis
7271198cf0 Use rio.h functions in aof.c 2011-05-14 12:36:22 +02:00
Pieter Noordhuis
221782ccc6 Move rdbLoad* to top; update comments 2011-05-13 23:24:19 +02:00
Pieter Noordhuis
f1d8e4968e Make RDB types/opcodes explicit; load/save object type 2011-05-13 22:14:39 +02:00
Pieter Noordhuis
2e4b0e7727 Abstract file/buffer I/O to support in-memory serialization 2011-05-13 17:31:00 +02:00
Pieter Noordhuis
5d08193126 Tests for string2ll; move isObject* to object.c 2011-05-05 16:26:50 +02:00
antirez
eda827f8b7 cluster import/export of hash slots implemented in the query redirection engine 2011-05-05 11:13:21 +02:00
antirez
484354ff95 CLUSTER GETKEYSINSLOT implemented 2011-04-29 16:17:58 +02:00
antirez
c772d9c6e7 take a hashslot -> keys index, will be used for cluster rehasing 2011-04-28 19:00:33 +02:00
antirez
3cd12b5687 CLIENT LIST implemented 2011-04-21 15:38:02 +02:00
antirez
17b24ff30d save peak memory usage as statistic and show it in INFO. Also a new INFO field was added showing the fragmentation ratio using the peak memory info. 2011-04-21 10:49:52 +02:00
antirez
7c0e1b53c4 Merge remote branch 'pietern/unstable-zset' into unstable 2011-04-14 13:31:14 +02:00
antirez
996d503d1a ASCII ART FTW 2011-04-13 10:58:21 +02:00
Pieter Noordhuis
7d8c555e92 Merge branch 'unstable' into unstable-zset
Conflicts:
	src/object.c
2011-04-06 16:15:01 +02:00
antirez
0b7f6d0913 make sure that OBJECT ENCODING returns skiplist for sorted sets, and not raw, so that once we will merge specially encoded sorted sets everything will make sense. 2011-04-06 15:36:10 +02:00
antirez
ece74202bb OBJECT command implemented 2011-04-06 12:19:45 +02:00
antirez
626f6b2d64 DUMP implemented, RESTORE and MIGRATE fixed. Use zcalloc() instead of zmalloc()+memset() in sds.c when a new string is created with NULL initialization pointer. 2011-04-01 18:59:28 +02:00
antirez
ef21ab960e centralized cluster config file name. Assigned slots in CLUSTER NODES output and in cluster config file. 2011-03-30 17:41:13 +02:00
antirez
ecc9109434 Cluster branch merged to unstable. 2011-03-29 17:51:15 +02:00
antirez
9791f0f8ce new preloading implemented, still EXEC not handled correctly, everything to test 2011-03-23 18:09:17 +01:00
Pieter Noordhuis
dddf5335f4 Fix DEBUG DIGEST, SORT and AOF rewrite 2011-03-14 13:30:06 +01:00
Pieter Noordhuis
8588bfa370 Make zzl API unaware of the robj where the ziplist is stored 2011-03-11 17:06:07 +01:00
Pieter Noordhuis
df26a0ae0b Encode sorted set after loading from dump 2011-03-10 17:50:13 +01:00
Pieter Noordhuis
d4e07f1714 Add new string to long long function 2011-03-10 16:16:27 +01:00
Pieter Noordhuis
3ea204e103 Configurable thresholds for encoded sorted sets 2011-03-09 14:01:57 +01:00
Pieter Noordhuis
e12b27acf7 Persistence code for encoded sorted sets 2011-03-09 13:16:38 +01:00
Pieter Noordhuis
9e7cee0ed0 Add function to create ziplist-backed sorted set 2011-03-08 16:08:52 +01:00
Pieter Noordhuis
672b0a1b25 Fast conversion of double when representable as long long 2011-03-08 16:08:11 +01:00
Pieter Noordhuis
633a941028 Save RDB on SIGTERM (see issue #471) 2011-03-06 17:49:40 +01:00
antirez
9ad853ccde added new RDB codes for ziplist encoded lists and intset encodeed sets 2011-02-28 17:06:31 +01:00
antirez
2cc993655f save zipmap encoded hashes as blobs. Work in progress. 2011-02-28 09:56:48 +01:00
antirez
419e1cca74 less delays in diskstore when there are many writes. more work to do. 2011-02-25 19:11:25 +01:00
antirez
05600eb8a7 fixed two diskstore issues, a quasi-deadlock creating problems with I/O speed and a race condition among threads 2011-02-11 11:16:15 +01:00
antirez
d7ed7fd2fc INFO commandstats section reset with config resetstat, a new microseconds per call field, and a few other minor things 2011-01-24 10:56:06 +01:00
antirez
0d808ef275 Now INFO outputs the "INFO default" output if no argument is passed. Also added counts of calls for every command, thanks to an idea by Mike Shaver 2011-01-23 22:14:15 +01:00
antirez
d9cb288c9e profiling information in INFO 2011-01-23 11:46:34 +01:00
Pieter Noordhuis
3bcffcbe5b Remove client from list of unblocked clients when it is free'd 2011-01-17 10:04:13 +01:00
antirez
52dc87bb18 lame typo causing bad hashes memory characteristic 2011-01-15 22:24:22 +01:00