Commit Graph

143 Commits

Author SHA1 Message Date
b998ebe904 REPLCONF internal command introduced.
The REPLCONF command is an internal command (not designed to be directly
used by normal clients) that allows a slave to set some replication
related state in the master before issuing SYNC to start the
replication.

The initial motivation for this command, and the only reason currently
it is used by the implementation, is to let the slave instance
communicate its listening port to the slave, so that the master can
show all the slaves with their listening ports in the "replication"
section of the INFO output.

This allows clients to auto discover and query all the slaves attached
into a master.

Currently only a single option of the REPLCONF command is supported, and
it is called "listening-port", so the slave now starts the replication
process with something like the following chat:

    REPLCONF listening-prot 6380
    SYNC

Note that this works even if the master is an older version of Redis and
does not understand REPLCONF, because the slave ignores the REPLCONF
error.

In the future REPLCONF can be used for partial replication and other
replication related features where there is the need to exchange
information between master and slave.

NOTE: This commit also fixes a bug: the INFO outout already carried
information about slaves, but the port was broken, and was obtained
with getpeername(2), so it was actually just the ephemeral port used
by the slave to connect to the master as a client.
2012-07-09 11:59:42 +02:00
9419eb0ffd More incremental active expired keys collection process.
If a large amonut of keys are all expiring about at the same time, the
"active" expired keys collection cycle used to block as far as the
percentage of already expired keys was >= 25% of the total population of
keys with an expire set.

This could block the server even for many seconds in order to reclaim
memory ASAP. The new algorithm uses at max a small amount of
milliseconds per cycle, even if this means reclaiming the memory less
promptly it also means a more responsive server.
2012-05-12 09:33:47 +02:00
df10c797e0 Limit memory used by big SLOWLOG entries.
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.
2012-04-21 21:50:25 +02:00
3c38b0876e Merge pull request #417 from josephjang/e95ca1db21b2dbe82f39a3f7f6390cb5f58dafae
a memory leak with replication on two or more dbs including >= db10
2012-03-30 01:28:58 -07:00
e95ca1db21 Fixed a memory leak with replication
occurs when two or more dbs are replicated and at least one of them is >db10
2012-03-30 02:17:21 +09:00
6938960b66 Fix for slaves chains. Force resync of slaves (simply disconnecting them) when SLAVEOF turns a master into a slave. 2012-03-29 09:31:39 +02:00
b3a86b8209 Fixed a few broken stuff introduced while merging issue #327 related code in 2.4 2012-02-15 15:30:29 +01:00
35a4761f1d freeMemoryIfNeeded() minor refactoring 2012-02-15 15:22:57 +01:00
c63e1b83c4 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-15 15:20:20 +01:00
05755f5c40 Initial version of c->reply_bytes implementation backported from unstable to 2.4, in order to apply issue 327 patches. 2012-02-15 15:20:05 +01:00
f373061563 Added a server.arch_bits field instead of computing it at runtime for INFO. 2012-02-02 10:02:40 +01:00
fbfe656236 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:16:23 +01:00
e7b85b3315 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. 2012-01-07 12:50:44 +01:00
a5045d552c Fixed replication when multiple slaves are attaching at the same time. The output buffer was not copied correctly between slaves. This fixes issue #141. 2012-01-07 12:48:10 +01:00
8a82ee0f3c better bug report info on crash (backported from unstable) 2011-11-24 15:53:35 +01:00
f4e2abfcd4 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:47:55 +01:00
3852e2a831 last executed command in CLIENT LIST output. 2011-11-24 14:56:43 +01:00
a6e4627438 Close client connection and log the event when the client input buffer reaches 1GB. 2011-11-21 18:37:17 +01:00
b1b98c64cc Max log message length set to 4k to avoid truncated INFO output in logs on Redis crash. This is just a workaround and it is handled better in the unstable branch. 2011-11-21 18:32:08 +01:00
beb4bacce6 I/O buffer length enlarged 2011-11-11 17:19:57 +01:00
3fac86ff1d set default client timeout to zero inside redis.h as well 2011-11-11 17:16:03 +01:00
1fe4cd5de9 fixed source indenting 2011-10-18 19:03:18 -02:00
7c6da7327f Added repl_ping_slave_period and repl_timeout options support 2011-10-18 18:56:10 -02:00
09cefcfbb3 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 22:08:11 +02:00
79b9ec53d1 fixed flushAppendOnlyFile() function prototype to reflect the new implementation, fixing compilation. 2011-09-19 17:43:56 +02:00
4c2d5f0980 postpone the AOF fsync if policy is everysec and there is a background fsync already going. 2011-09-19 17:43:49 +02:00
3a4afb0473 Manual merge after cherry-pick 2011-07-12 10:03:22 +02:00
63aed54a27 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-12 10:00:12 +02:00
19453556d4 dataspace change hook functions backported to 2.4. They are just wrappers at this point but this makes simpler to cherry-pick between branches. 2011-07-12 09:56:41 +02:00
30b345ddbb more slow log merge, I forgot to resolve a conflict. 2011-07-02 00:27:10 +02:00
99509ab257 slow log merged into 2.4 2011-07-02 00:24:11 +02:00
5d5fe340e0 new INFO filed master_link_down_since_seconds 2011-06-17 16:13:22 +02:00
307868e149 DB API refactoring. The changes were designed together with Pieter Noordhuis. 2011-06-14 16:59:45 +02:00
61751a4dc4 AOF auto rewrite backported to 2.4 2011-06-10 18:31:27 +02:00
27c8f84c66 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-06-08 23:20:11 +02:00
4f8cf6a23c use the new rewriteClientCommandVector() function for SPOP -> SREM replication translation as well. 2011-05-31 12:15:55 +02:00
afc151d3ba Make replication faster (biggest gain for small number of slaves) 2011-05-29 17:55:13 -07:00
ecfc0583da Configurable synchronous I/O timeout 2011-05-22 12:57:56 +02:00
ff8d85885e Minor changes in non-blocking repl. connect 2011-05-22 12:48:10 +02:00
78c05caf5e Non-blocking connect with master 2011-05-19 18:53:31 +02:00
deff2338fa Merge remote branch 'pietern/2.4-misc' into 2.4 2011-05-05 16:50:28 +02:00
20dad91bdf Tests for string2ll; move isObject* to object.c 2011-04-27 13:26:33 +02:00
91867a5ea2 CLIENT LIST implemented 2011-04-21 17:09:46 +02:00
1c30cad1ab peak mem in INFO backported from unstable branch 2011-04-21 16:55:27 +02:00
760dec3a6c VM/direct-saving fixes 2011-04-20 17:48:46 +02:00
1f84b0648b yet more manual backporting from unstable 2011-04-20 15:57:35 +02:00
c92283770d added new RDB codes for ziplist encoded lists and intset encodeed sets 2011-04-20 15:41:13 +02:00
3dffb8e21e save zipmap encoded hashes as blobs. Work in progress. 2011-04-20 15:41:13 +02:00
dfeb899b2d Merge branch '2.2' into 2.2-zset
Conflicts:
	src/object.c
2011-04-06 15:46:33 +02:00
93db956e06 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:38:08 +02:00