475 Commits

Author SHA1 Message Date
Allan
f1be75e5d0 fixed bug issue of #1213 2013-07-24 21:34:55 +08:00
antirez
aa32f92338 Introduction of a new string encoding: EMBSTR
Previously two string encodings were used for string objects:

1) REDIS_ENCODING_RAW: a string object with obj->ptr pointing to an sds
stirng.

2) REDIS_ENCODING_INT: a string object where the obj->ptr void pointer
is casted to a long.

This commit introduces a experimental new encoding called
REDIS_ENCODING_EMBSTR that implements an object represented by an sds
string that is not modifiable but allocated in the same memory chunk as
the robj structure itself.

The chunk looks like the following:

+--------------+-----------+------------+--------+----+
| robj data... | robj->ptr | sds header | string | \0 |
+--------------+-----+-----+------------+--------+----+
                     |                       ^
                     +-----------------------+

The robj->ptr points to the contiguous sds string data, so the object
can be manipulated with the same functions used to manipulate plan
string objects, however we need just on malloc and one free in order to
allocate or release this kind of objects. Moreover it has better cache
locality.

This new allocation strategy should benefit both the memory usage and
the performances. A performance gain between 60 and 70% was observed
during micro-benchmarks, however there is more work to do to evaluate
the performance impact and the memory usage behavior.
2013-07-22 10:31:38 +02:00
yoav
dddfb15bc0 Chunked loading of RDB to prevent redis from stalling reading very large keys. 2013-07-16 15:41:24 +02:00
antirez
912470cd00 Use the environment locale for strcoll() collation. 2013-07-12 13:38:43 +02:00
antirez
e4d2e6fc9d All IP string repr buffers are now REDIS_IP_STR_LEN bytes. 2013-07-09 11:32:52 +02:00
antirez
ef8ca93920 IPv6: bind IPv4 and IPv6 interfaces by default. 2013-07-09 10:47:17 +02:00
antirez
2fa66d5e76 Fix old anetPeerToString() API call in replication.c 2013-07-08 16:11:52 +02:00
Geoff Garside
d61f125b1b Cleanup main() and BACKTRACE mistaken pulled while rebasing. 2013-07-08 16:07:26 +02:00
Geoff Garside
f0eb97325c Fix calls to anetPeerToString() missing buffer size. 2013-07-08 16:07:26 +02:00
Geoff Garside
dc7e8ec27f Update calls to anetPeerToString to include ip_len. 2013-07-08 15:57:22 +02:00
antirez
d3cde09645 Binding multiple IPs done properly with multiple sockets. 2013-07-05 11:47:20 +02:00
antirez
bd9b1251ac Ability to bind multiple addresses. 2013-07-04 18:50:15 +02:00
antirez
f57a871de0 getAbsolutePath() moved into utils.c 2013-07-02 11:56:52 +02:00
antirez
f4805fa45a CONFIG SET maxclients. 2013-06-28 17:08:03 +02:00
antirez
e94b5b9359 Allow SHUTDOWN in loading state. 2013-06-27 12:18:29 +02:00
Salvatore Sanfilippo
a59318f0a4 Merge pull request #1111 from yamt/netbsd3
netbsd support
2013-06-26 06:17:02 -07:00
antirez
8338e50127 Move Replication Script Cache initialization in safer place.
It should be called just one time at startup and not every time the Lua
scripting engine is re-initialized, otherwise memory is leaked.
2013-06-24 19:27:49 +02:00
antirez
eaebabe564 Use the RSC to replicate EVALSHA unmodified.
This commit uses the Replication Script Cache in order to avoid
translating EVALSHA into EVAL whenever possible for both the AOF and
slaves.
2013-06-24 18:57:31 +02:00
antirez
a9e1c46f40 Replication of scripts as EVALSHA: sha1 caching implemented.
This code is only responsible to take an LRU-evicted fixed length cache
of SHA1 that we are sure all the slaves received.

In this commit only the implementation is provided, but the Redis core
does not use it to actually send EVALSHA to slaves when possible.
2013-06-24 10:26:04 +02:00
antirez
08dff9fb66 New API to force propagation.
The old REDIS_CMD_FORCE_REPLICATION flag was removed from the
implementation of Redis, now there is a new API to force specific
executions of a command to be propagated to AOF / Replication link:

    void forceCommandPropagation(int flags);

The new API is also compatible with Lua scripting, so a script that will
execute commands that are forced to be propagated, will also be
propagated itself accordingly even if no change to data is operated.

As a side effect, this new design fixes the issue with scripts not able
to propagate PUBLISH to slaves (issue #873).
2013-06-21 12:07:53 +02:00
antirez
d337302b90 PUBSUB command implemented.
Currently it implements three subcommands:

PUBSUB CHANNELS [<pattern>]    List channels with non-zero subscribers.
PUBSUB NUMSUB [channel_1 ...]  List number of subscribers for channels.
PUBSUB NUMPAT                  Return number of subscribed patterns.
2013-06-20 15:32:00 +02:00
antirez
57984ee8f2 New INFO field "min_slaves_good_slaves".
When min-slaves-to-write feature is active, this field reports the
number of slaves considered good (online state, lag within the specified
range).
2013-05-30 12:18:31 +02:00
antirez
b6e37a61c4 min-replicas-to-write: only deny write commands.
I guess I needed another coffee...
2013-05-30 11:30:09 +02:00
antirez
cb76f29230 min-slaves-to-write: don't accept writes with less than N replicas.
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.
2013-05-30 11:30:04 +02:00
antirez
564d8c4c0b repl_offset field in INFO replication is now just offset. 2013-05-29 19:56:33 +02:00
antirez
db72ecccc8 Slaves list in INFO output: lag added, format changed.
There is a new 'lag' information in the list of slaves, in the
"replication" section of the INFO output.

Also the format was changed in a backward incompatible way in order to
make it more easy to parse if new fields are added in the future, as the
new format is comma separated but has named fields (no longer positional
fields).
2013-05-29 19:54:44 +02:00
antirez
be6182c26a Accept REPLCONF in any state. 2013-05-28 15:26:20 +02:00
antirez
c9af89d8cd Don't ACK the master after every command.
Sending an ACK is now moved into the replicationSendAck() function.
2013-05-27 11:42:35 +02:00
antirez
84c7d48a80 Replication: send REPLCONF ACK to master. 2013-05-27 11:42:25 +02:00
YAMAMOTO Takashi
2e829fc15d don't assume time_t == long
time_t is always 64bit on recent versions of NetBSD.
2013-05-17 17:22:39 +09:00
antirez
cc475c9fed Added a define for most configuration defaults.
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.
2013-05-15 10:12:29 +02:00
antirez
df802fd3a1 CONFIG REWRITE: support for client-output-buffer-limit. 2013-05-13 18:34:18 +02:00
antirez
d193366479 CONFIG REWRITE: Initial support code and design. 2013-05-13 11:11:12 +02:00
antirez
792459e84a Obtain absoute path of configuration file, expose it in INFO. 2013-05-09 16:57:59 +02:00
antirez
bd638d72ee Config option to turn AOF rewrite incremental fsync on/off. 2013-04-24 10:57:07 +02:00
antirez
98bb3d2a40 More explicit panic message on out of memory. 2013-04-19 15:11:34 +02:00
antirez
0c0db1bc3d Cluster: node timeout is now configurable. 2013-04-04 12:29:10 +02:00
antirez
a9d031c771 Throttle BGSAVE attempt on saving error.
When a BGSAVE fails, Redis used to flood itself trying to BGSAVE at
every next cron call, that is either 10 or 100 times per second
depending on configuration and server version.

This commit does not allow a new automatic BGSAVE attempt to be
performed before a few seconds delay (currently 5).

This avoids both the auto-flood problem and filling the disk with
logs at a serious rate.

The five seconds limit, considering a log entry of 200 bytes, will use
less than 4 MB of disk space per day that is reasonable, the sysadmin
should notice before of catastrofic events especially since by default
Redis will stop serving write queries after the first failed BGSAVE.

This fixes issue #849
2013-04-02 14:05:50 +02:00
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