Commit Graph

1530 Commits

Author SHA1 Message Date
antirez
2179c26916 Sentinel: check that instance still exists in reply callbacks.
We can't be sure the instance object still exists when the reply
callback is called.
2012-07-24 16:37:57 +02:00
antirez
d876d6feac Sentinel: more robust failover detection as observer.
Sentinel observers detect failover checking if a slave attached to the
monitored master turns into its replication state from slave to master.
However while this change may in theory only happen after a SLAVEOF NO
ONE command, in practie it is very easy to reboot a slave instance with
a wrong configuration that turns it into a master, especially if it was
a past master before a successfull failover.

This commit changes the detection policy so that if an instance goes
from slave to master, but at the same time the runid has changed, we
sense a reboot, and in that case we don't detect a failover at all.

This commit also introduces the "reboot" sentinel event, that is logged
at "warning" level (so this will trigger an admin notification).

The commit also fixes a problem in the disconnect handler that assumed
that the instance object always existed, that is not the case. Now we
no longer assume that redisAsyncFree() will call the disconnection
handler before returning.
2012-07-24 12:42:40 +02:00
antirez
6b5daa2df2 First implementation of Redis Sentinel.
This commit implements the first, beta quality implementation of Redis
Sentinel, a distributed monitoring system for Redis with notification
and automatic failover capabilities.

More info at http://redis.io/topics/sentinel
2012-07-23 13:14:44 +02:00
antirez
03f412ddef Merge remote-tracking branch 'origin/unstable' into unstable 2012-07-22 17:18:42 +02:00
antirez
5d73073f6e Allow Pub/Sub in contexts where other commands are blocked.
Redis loading data from disk, and a Redis slave disconnected from its
master with serve-stale-data disabled, are two conditions where
commands are normally refused by Redis, returning an error.

However there is no reason to disable Pub/Sub commands as well, given
that this layer does not interact with the dataset. To allow Pub/Sub in
as many contexts as possible is especially interesting now that Redis
Sentinel uses Pub/Sub of a Redis master as a communication channel
between Sentinels.

This commit allows Pub/Sub to be used in the above two contexts where
it was previously denied.
2012-07-22 17:18:16 +02:00
antirez
b62bdf1c64 Don't assume that "char" is signed.
For the C standard char can be either signed or unsigned, it's up to the
compiler, but Redis assumed that it was signed in a few places.

The practical effect of this patch is that now Redis 2.6 will run
correctly in every system where char is unsigned, notably the RaspBerry
PI and other ARM systems with GCC.

Thanks to Georgi Marinov (@eesn on twitter) that reported the problem
and allowed me to use his RaspBerry via SSH to trace and fix the issue!
2012-07-18 12:04:58 +02:00
Saj Goonatilleke
55302e9e28 Truncate short write from the AOF
If Redis only manages to write out a partial buffer, the AOF file won't
load back into Redis the next time it starts up.  It is better to
discard the short write than waste time running redis-check-aof.
2012-07-18 10:35:17 +10:00
Saj Goonatilleke
48553a29e8 New in INFO: aof_last_bgrewrite_status
Behaves like rdb_last_bgsave_status -- even down to reporting 'ok' when
no rewrite has been done yet.  (You might want to check that
aof_last_rewrite_time_sec is not -1.)
2012-07-18 09:54:55 +10:00
Steeve Lennmark
e9828cb6f7 Check that we have connection before enabling pipe mode 2012-07-15 14:35:02 +02:00
Saj Goonatilleke
9edfe63553 Bug fix: slaves being pinged every second
REDIS_REPL_PING_SLAVE_PERIOD controls how often the master should
transmit a heartbeat (PING) to its slaves.  This period, which defaults
to 10, is measured in seconds.

Redis 2.4 masters used to ping their slaves every ten seconds, just like
it says on the tin.

The Redis 2.6 masters I have been experimenting with, on the other hand,
ping their slaves *every second*.  (master_last_io_seconds_ago never
approaches 10.)  I think the ping period was inadvertently slashed to
one-tenth of its nominal value around the time REDIS_HZ was introduced.
This commit reintroduces correct ping schedule behaviour.
2012-07-05 14:29:27 +10:00
jokea
93b0075d33 mark fd as writable when EPOLLERR or EPOLLHUP is returned by epoll_wait. 2012-06-29 12:06:38 +08:00
antirez
36def8fd9a Typo in comment. 2012-06-27 11:26:44 +02:00
antirez
3a32897856 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-06-27 09:43:57 +02:00
antirez
5410168c6e Fixed comment typo into time_independent_strcmp(). 2012-06-21 14:25:53 +02:00
antirez
31a1439bfd Fixed a timing attack on AUTH (Issue #560).
The way we compared the authentication password using strcmp() allowed
an attacker to gain information about the password using a well known
class of attacks called "timing attacks".

The bug appears to be practically not exploitable in most modern systems
running Redis since even using multiple bytes of differences in the
input at a time instead of one the difference in running time in in the
order of 10 nanoseconds, making it hard to exploit even on LAN. However
attacks always get better so we are providing a fix ASAP.

The new implementation uses two fixed length buffers and a constant time
comparison function, with the goal of:

1) Completely avoid leaking information about the content of the
password, since the comparison is always performed between 512
characters and without conditionals.
2) Partially avoid leaking information about the length of the
password.

About "2" we still have a stage in the code where the real password and
the user provided password are copied in the static buffers, we also run
two strlen() operations against the two inputs, so the running time
of the comparison is a fixed amount plus a time proportional to
LENGTH(A)+LENGTH(B). This means that the absolute time of the operation
performed is still related to the length of the password in some way,
but there is no way to change the input in order to get a difference in
the execution time in the comparison that is not just proportional to
the string provided by the user (because the password length is fixed).

Thus in practical terms the user should try to discover LENGTH(PASSWORD)
looking at the whole execution time of the AUTH command and trying to
guess a proportionality between the whole execution time and the
password length: this appears to be mostly unfeasible in the real world.

Also protecting from this attack is not very useful in the case of Redis
as a brute force attack is anyway feasible if the password is too short,
while with a long password makes it not an issue that the attacker knows
the length.
2012-06-21 11:50:01 +02:00
antirez
5b63ccce6c Fix c->reply_bytes computation in setDeferredMultiBulkLength()
In order to implement reply buffer limits introduced in 2.6 and useful
to close the connection under user-selected circumastances of big output
buffers (for instance slow consumers in pub/sub, a blocked slave, and so
forth) Redis takes a counter with the amount of used memory in objects
inside the output list stored into c->reply.

The computation was broken in the function setDeferredMultiBulkLength(),
in the case the object was glued with the next one. This caused the
c->reply_bytes field to go out of sync, be subtracted more than needed,
and wrap back near to ULONG_MAX values.

This commit fixes this bug and adds an assertion that is able to trap
this class of problems.

This problem was discovered looking at the INFO output of an unrelated
issue (issue #547).
2012-06-15 10:03:25 +02:00
antirez
ba779119b8 ziplistFind(): don't assume that entries are comparable by encoding.
Because Redis 2.6 introduced new integer encodings it is no longer true
that if two entries have a different encoding they are not equal.

An old ziplist can be loaded from an RDB file generated with Redis 2.4,
in this case for instance a small unsigned integers is encoded with a
16 bit encoding, while in Redis 2.6 a more specific 8 bit encoding
format is used.

Because of this bug hashes ended with duplicated values or fields lookup
failed, causing many bad behaviors.
This in turn caused a crash while converting the ziplist encoded hash into
a real hash table because an assertion was raised on duplicated elements.

This commit fixes issue #547.

Many thanks to Pinterest's Marty Weiner and colleagues for discovering
the problem and helping us in the debugging process.
2012-06-14 16:01:27 +02:00
Ted Nyman
d665dd0865 Standardize punctuation in redis-cli help.
Right there is a mix of help entries ending with periods or
without periods. This standardizes the end of command as without
periods, which seems to be the general custom in most unix tools,
at least.
2012-06-12 22:35:00 -07:00
antirez
ee789e157c Dump ziplist hex value on failed assertion.
The ziplist -> hashtable conversion code is triggered every time an hash
value must be promoted to a full hash table because the number or size of
elements reached the threshold.

If a problem in the ziplist causes the same field to be present
multiple times, the assertion of successful addition of the element
inside the hash table will fail, crashing server with a failed
assertion, but providing little information about the problem.

This code adds a new logging function to perform the hex dump of binary
data, and makes sure that the ziplist -> hashtable conversion code uses
this new logging facility to dump the content of the ziplist when the
assertion fails.

This change was originally made in order to investigate issue #547.
2012-06-12 00:41:48 +02:00
Alex Mitrofanov
51857c7e5c Fixed RESTORE hash failure (Issue #532)
(additional commit notes by antirez@gmail.com):

The rdbIsObjectType() macro was not updated when the new RDB object type
of ziplist encoded hashes was added.

As a result RESTORE, that uses rdbLoadObjectType(), failed when a
ziplist encoded hash was loaded.
This does not affected normal RDB loading because in that case we use
the lower-level function rdbLoadType().

The commit also adds a regression test.
2012-06-02 10:24:27 +02:00
antirez
c7a25200e2 RDB type loading functions clarified in comments.
Improved comments to make clear that rdbLoadType() just loads a
general TYPE in the context of RDB that can be an object type or an
expire type, end-of-file, and so forth.

While rdbLoadObjectType() enforces that the type is a valid Object Type
otherwise it returns -1.
2012-06-02 10:21:57 +02:00
antirez
1419406e8d BITOP bug when called against non existing keys fixed.
In the issue #529 an user reported a bug that can be triggered with the
following code:

flushdb
set a
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
bitop or x a b

The bug was introduced with the speed optimization in commit 8bbc076
that specializes every BITOP operation loop up to the minimum length of
the input strings.

However the computation of the minimum length contained an error when a
non existing key was present in the input, after a key that was non zero
length.

This commit fixes the bug and adds a regression test for it.
2012-05-31 21:52:47 +02:00
antirez
33e1db36fa Four new persistence fields in INFO. A few renamed.
The 'persistence' section of INFO output now contains additional four
fields related to RDB and AOF persistence:

 rdb_last_bgsave_time_sec       Duration of latest BGSAVE in sec.
 rdb_current_bgsave_time_sec    Duration of current BGSAVE in sec.
 aof_last_rewrite_time_sec      Duration of latest AOF rewrite in sec.
 aof_current_rewrite_time_sec   Duration of current AOF rewrite in sec.

The 'current' fields are set to -1 if a BGSAVE / AOF rewrite is not in
progress. The 'last' fileds are set to -1 if no previous BGSAVE / AOF
rewrites were performed.

Additionally a few fields in the persistence section were renamed for
consistency:

 changes_since_last_save -> rdb_changes_since_last_save
 bgsave_in_progress -> rdb_bgsave_in_progress
 last_save_time -> rdb_last_save_time
 last_bgsave_status -> rdb_last_bgsave_status
 bgrewriteaof_in_progress -> aof_rewrite_in_progress
 bgrewriteaof_scheduled -> aof_rewrite_scheduled

After the renaming, fields in the persistence section start with rdb_ or
aof_ prefix depending on the persistence method they describe.
The field 'loading' and related fields are not prefixed because they are
unique for both the persistence methods.
2012-05-25 12:11:30 +02:00
antirez
d866803818 BITOP command 10x speed improvement.
This commit adds a fast-path to the BITOP that can be used for all the
bytes from 0 to the minimal length of the string, and if there are
at max 16 input keys.

Often the intersected bitmaps are roughly the same size, so this
optimization can provide a 10x speed boost to most real world usages
of the command.

Bytes are processed four full words at a time, in loops specialized
for the specific BITOP sub-command, without the need to check for
length issues with the inputs (since we run this algorithm only as far
as there is data from all the keys at the same time).

The remaining part of the string is intersected in the usual way using
the slow but generic algorith.

It is possible to do better than this with inputs that are not roughly
the same size, sorting the input keys by length, by initializing the
result string in a smarter way, and noticing that the final part of the
output string composed of only data from the longest string does not
need any proecessing since AND, OR and XOR against an empty string does
not alter the output (zero in the first case, and the original string in
the other two cases).

More implementations will be implemented later likely, but this should
be enough to release Redis 2.6-RC4 with bitops merged in.

Note: this commit also adds better testing for BITOP NOT command, that
is currently the faster and hard to optimize further since it just
flips the bits of a single input string.
2012-05-24 15:20:20 +02:00
antirez
fa4a5d5922 BITOP: handle integer encoded objects correctly.
A bug in the implementation caused BITOP to crash the server if at least
one one of the source objects was integer encoded.

The new implementation takes an additional array of Redis objects
pointers and calls getDecodedObject() to get a reference to a string
encoded object, and then uses decrRefCount() to release the object.

Tests modified to cover the regression and improve coverage.
2012-05-24 15:20:16 +02:00
antirez
7c34643f15 BITCOUNT performance improved.
At Redis's default optimization level the command is now much faster,
always using a constant-time bit manipualtion technique to count bits
instead of GCC builtin popcount, and unrolling the loop.

The current implementation performance is 1.5GB/s in a MBA 11" (1.8 Ghz
i7) compiled with both GCC and clang.

The algorithm used is described here:

http://graphics.stanford.edu/~seander/bithacks.html
2012-05-24 15:20:11 +02:00
antirez
80f8028e3c bitop.c renamed bitops.c
bitop.c contains the "Bit related string operations" so it seems more
logical to call it bitops instead of bitop.
This also makes it matching the name of the test (unit/bitops.tcl).
2012-05-24 15:20:06 +02:00
antirez
343d3bd287 popcount() optimization for speed.
We run the array by 32 bit words instead of processing it byte per byte.
If the code is compiled using GCC __builtin_popcount() builtin function
is used instead.
2012-05-24 15:19:58 +02:00
antirez
dbbbe49ef5 BITCOUNT refactoring.
The low level popualtion counting function is now separated from the
BITCOUNT command implementation, so that the low level function can be
further optimized and eventually used in other contexts if needed.
2012-05-24 15:19:55 +02:00
antirez
760e776526 Bit-related string operations moved to bitop.c
All the general string operations are implemented in t_string.c, however
the bit operations, while targeting the string type, are better served
in a specific file where we have the implementations of the following
four commands and helper functions:

    GETBIT
    SETBIT
    BITOP
    BITCOUNT

In the future this file will probably contain more code related to
making the BITOP and BITCOUNT operations faster.
2012-05-24 15:19:51 +02:00
antirez
0bd6d68e34 New commands: BITOP and BITCOUNT.
The motivation for this new commands is to be search in the usage of
Redis for real time statistics. See the article "Fast real time metrics
using Redis".

http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/

In general Redis strings when used as bitmaps using the SETBIT/GETBIT
command provide a very space-efficient and fast way to store statistics.
For instance in a web application with users, every user can be
associated with a key that shows every day in which the user visited the
web service. This information can be really valuable to extract user
behaviour information.

With Redis bitmaps doing this is very simple just saying that a given
day is 0 (the data the service was put online) and all the next days are
1, 2, 3, and so forth. So with SETBIT it is possible to set the bit
corresponding to the current day every time the user visits the site.

It is possible to take the count of the bit sets on the run, this is
extremely easy using a Lua script. However a fast bit count native
operation can be useful, especially if it can operate on ranges, or when
the string is small like in the case of days (even if you consider many
years it is still extremely little data).

For this reason BITOP was introduced. The command counts the number of
bits set to 1 in a string, with optional range:

BITCOUNT key [start end]

The start/end parameters are similar to GETRANGE. If omitted the whole
string is tested.

Population counting is more useful when bit-level operations like AND,
OR and XOR are avaialble. For instance I can test multiple users to see
the number of days three users visited the site at the same time. To do
this we can take the AND of all the bitmaps, and then count the set bits.

For this reason the BITOP command was introduced:

BITOP [AND|OR|XOR|NOT] dest_key src_key1 src_key2 src_key3 ... src_keyN

In the special case of NOT (that inverts the bits) only one source key
can be passed.

The judicious use of BITCOUNT and BITOP combined can lead to interesting
use cases with very space efficient representation of data.

The implementation provided is still not tested and optimized for speed,
next commits will introduce unit tests. Later the implementation will be
profiled to see if it is possible to gain an important amount of speed
without making the code much more complex.
2012-05-24 15:19:43 +02:00
antirez
6f05a65336 Add aof_rewrite_buffer_length INFO field.
The INFO output, persistence section, already contained the field
describing the size of the current AOF buffer to flush on disk. However
the other AOF buffer, used to accumulate changes during an AOF rewrite,
was not mentioned in the INFO output.

This commit introduces a new field called aof_rewrite_buffer_length with
the length of the rewrite buffer.
2012-05-24 15:19:18 +02:00
antirez
47ca4b6e28 Allow an AOF rewrite buffer > 2GB (Fix for issue #504).
During the AOF rewrite process, the parent process needs to accumulate
the new writes in an in-memory buffer: when the child will terminate the
AOF rewriting process this buffer (that ist the difference between the
dataset when the rewrite was started, and the current dataset) is
flushed to the new AOF file.

We used to implement this buffer using an sds.c string, but sds.c has a
2GB limit. Sometimes the dataset can be big enough, the amount of writes
so high, and the rewrite process slow enough that we overflow the 2GB
limit, causing a crash, documented on github by issue #504.

In order to prevent this from happening, this commit introduces a new
system to accumulate writes, implemented by a linked list of blocks of
10 MB each, so that we also avoid paying the reallocation cost.

Note that theoretically modern operating systems may implement realloc()
simply as a remaping of the old pages, thus with very good performances,
see for instance the mremap() syscall on Linux. However this is not
always true, and jemalloc by default avoids doing this because there are
issues with the current implementation of mremap().

For this reason we are using a linked list of blocks instead of a single
block that gets reallocated again and again.

The changes in this commit lacks testing, that will be performed before
merging into the unstable branch. This fix will not enter 2.4 because it
is too invasive. However 2.4 will log a warning when the AOF rewrite
buffer is near to the 2GB limit.
2012-05-24 15:19:15 +02:00
antirez
ef37997608 Dead code removed from replication.c.
The user @jokea noticed that the following line of code into
replication.c made little sense:

    addReplySds(slave,sdsempty());

Investigating a bit I found that this was introduced by commit 6208b3a7
three years ago in the early stages of Redis. The code apparently is not
useful at all, so I'm removing it.

This change will not be backported into 2.4 so that in the rare case
this should introduce a bug, we'll have a chance to detect it into the
development branch. However following the code path it seems like the
code is not useful at all, so the risk is truly small.
2012-05-24 11:35:21 +02:00
jokea
e150ce3ce6 Set fd to writable when poll(2) detects POLLERR or POLLHUP event. 2012-05-23 11:33:32 +02:00
antirez
348ee1a40a Fixed issue #516 (ZINTERSTORE mixing sets and zsets).
Weeks ago trying to fix an harmless GCC warning I introduced a bug in
the ziplist-encoded implementations of sorted sets.

The bug completely broke zuiNext() iterator, that is used in the
ZINTERSTORE and ZUNIONSTORE implementation, so those two commands are no
longer reliable starting from Redis version 2.4.12 and latest 2.6.0-RC
releases.

This commit fixes the problem and adds a regression test.
2012-05-23 11:12:43 +02:00
antirez
5a55999304 Use comments to split aof.c into sections.
This makes the code more readable, it is still not the case to split the
file itself into three different files, but the logical separation
improves the readability especially since new commits are going to
introduce an additional section.
2012-05-21 16:50:05 +02:00
antirez
ad4c0b4117 Jemalloc updated to 3.0.0.
Full changelog here:

http://www.canonware.com/cgi-bin/gitweb.cgi?p=jemalloc.git;a=blob_plain;f=ChangeLog;hb=master

Notable improvements from the point of view of Redis:

1) Bugfixing.
2) Support for Valgrind.
3) Support for OSX Lion, FreeBSD.
2012-05-16 11:09:45 +02:00
Pieter Noordhuis
3c72c94aae Whitespace 2012-05-15 11:19:01 +02:00
Dave Pacheco
6d31277048 use port_getn instead of port_get 2012-05-15 11:18:58 +02:00
Dave Pacheco
05da63da0c first cut at event port support 2012-05-15 11:18:54 +02:00
antirez
e9f0419c99 Added time.h include in redis-cli.
redis-cli.c uses the time() function to seed the PRNG, but time.h was
not included. This was not noticed since sys/time.h is included and was
enough in most systems (but not correct). With Ubuntu 12.04 GCC
generates a warning that made us aware of the issue.
2012-05-14 17:35:51 +02:00
antirez
b3624f5a16 activeExpireCycle(): better precision in max time used.
activeExpireCycle() can consume no more than a few milliseconds per
iteration. This commit improves the precision of the check for the time
elapsed in two ways:

1) We check every 16 iterations instead of the main loop instead of 256.
2) We reset iterations at the start of the function and not every time
   we switch to the next database, so the check is correctly performed
   every 16 iterations.
2012-05-14 16:04:41 +02:00
antirez
61daf8914d Impovements for: Redis timer, hashes rehashing, keys collection.
A previous commit introduced REDIS_HZ define that changes the frequency
of calls to the serverCron() Redis function. This commit improves
different related things:

1) Software watchdog: now the minimal period can be set according to
REDIS_HZ. The minimal period is two times the timer period, that is:

    (1000/REDIS_HZ)*2 milliseconds

2) The incremental rehashing is now performed in the expires dictionary
as well.

3) The activeExpireCycle() function was improved in different ways:

- Now it checks if it already used too much time using microseconds
  instead of milliseconds for better precision.
- The time limit is now calculated correctly, in the previous version
  the division was performed before of the multiplication resulting in
  a timelimit of 0 if HZ was big enough.
- Databases with less than 1% of buckets fill in the hash table are
  skipped, because getting random keys is too expensive in this
  condition.

4) tryResizeHashTables() is now called at every timer call, we need to
   match the number of calls we do to the expired keys colleciton cycle.

5) REDIS_HZ was raised to 100.
2012-05-13 21:52:35 +02:00
antirez
9434349236 Redis timer interrupt frequency configurable as REDIS_HZ.
Redis uses a function called serverCron() that is very similar to the
timer interrupt of an operating system. This function is used to handle
a number of asynchronous things, like active expired keys collection,
clients timeouts, update of statistics, things related to the cluster
and replication, triggering of BGSAVE and AOF rewrite process, and so
forth.

In the past the timer was called 1 time per second. At some point it was
raised to 10 times per second, but it still was fixed and could not be
changed even at compile time, because different functions called from
serverCron() assumed a given fixed frequency.

This commmit makes the frequency configurable, so that it is simpler to
pick a good tradeoff between overhead of this function (that is usually
very small) and the responsiveness of Redis during a few critical
circumstances where a lot of work is done inside the timer.

An example of such a critical condition is mass-expire of a lot of keys
in the same second. Up to a given percentage of CPU time is used to
perform expired keys collection per expire cylce. Now changing the
REDIS_HZ macro it is possible to do less work but more times per second
in order to block the server for less time.

If this patch will work well in our tests it will enter Redis 2.6-final.
2012-05-13 16:40:29 +02:00
antirez
f333788fbc Comment improved so that the code goal is more clear. Thx to @agladysh. 2012-05-11 22:33:28 +02:00
antirez
1dcc95d081 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-11 19:17:31 +02:00
antirez
ea66be6080 redis-cli pipe mode: handle EINTR properly as well so that SIGSTOP/SIGCONT are handled correctly. 2012-05-11 16:08:57 +02:00
antirez
f6bd9122c0 redis-cli pipe mode: handle EAGAIN while writing to socket. 2012-05-11 10:45:12 +02:00
antirez
8c6301462b Fix PREFIX typo in Makefile. 2012-05-09 20:45:19 +02:00
antirez
b26808a532 Allow PREFIX to be overrided in Makefile. 2012-05-09 10:34:52 +02:00
antirez
088c508abc redis-cli --pipe for mass import. 2012-05-07 16:37:18 +02:00
Pieter Noordhuis
bf21941686 Compare integers in ziplist regardless of encoding
Because of the introduction of new integer encoding types for ziplists
in the 2.6 tree, the same integer value may have a different encoding in
different versions of the ziplist implementation. This means that the
encoding can NOT be used as a fast path in comparing integers.
2012-05-06 10:06:21 +02:00
antirez
af3853c3bf syncio.c read / write functions reworked for correctness and performance.
The new implementation start reading / writing before blocking with
aeWait(), likely the descriptor can accept writes or has buffered data
inside and we can go faster, otherwise we get an error and wait.

This change has effects on speed but also on correctness: on socket
errors when we perform non blocking connect(2) write is performed ASAP
and the error is returned ASAP before waiting.

So the practical effect is that now a Redis slave is more available if it
can not connect to the master, previously the slave continued to block on
syncWrite() trying to send SYNC, and serving commands very slowly.
2012-05-02 22:41:50 +02:00
antirez
299290d3a4 Remove useless trailing space in SYNC command sent to master. 2012-05-02 21:47:53 +02:00
antirez
ae62d29d1d Use specific error if master is down and slave-serve-stale-data is set to no.
We used to reply -ERR ... message ..., now the reply is
instead -MASTERDOWN ... message ... so that it can be distinguished
easily by the other error conditions.
2012-05-02 20:57:55 +02:00
Pieter Noordhuis
cc4f65fea4 Use safe dictionary iterator from KEYS
Every matched key in a KEYS call is checked for expiration. When the key
is set to expire, the call to `getExpire` will assert that the key also
exists in the main dictionary. This in turn causes a rehashing step to
be executed. Rehashing a dictionary when there is an iterator active may
result in the iterator emitting duplicate entries, or not emitting some
entries at all. By using a safe iterator, the rehash step is omitted.
2012-05-01 10:52:03 +02:00
antirez
ffe003dcbe memtest.c fixed to actually use v1 and v2 in memtest_fill_value(). 2012-04-27 16:29:44 +02:00
antirez
841048f2c8 redis-cli commands description in help.h updated. 2012-04-27 15:57:27 +02:00
antirez
0ad10db220 Set LUA_MASKCOUNT hook more selectively. Fixes issue #480.
An user reported a crash with Redis scripting (see issue #480 on
github), inspection of the kindly provided strack trace showed that
server.lua_caller was probably set to NULL. The stack trace also slowed
that the call to the hook was originating from a point where we just
used to set/get a few global variables in the Lua state.

What was happening is that we did not set the timeout hook selectively
only when the user script was called. Now we set it more selectively,
specifically only in the context of the lua_pcall() call, and make sure
to remove the hook when the call returns. Otherwise the hook can get
called in random contexts every time we do something with the Lua
state.
2012-04-27 11:41:25 +02:00
antirez
a3eb7ac87d Re-introduce -g -rdynamic -ggdb when linking, fixing strack traces.
A previous commit removed -g -rdynamic -ggdb as LDFLAGS, not allowing
Redis to produce a stack trace wth symbol names on crash.
This commit fixes the issue.
2012-04-26 16:53:11 +02:00
antirez
11bd247d2b Produce the stack trace in an async safe way. 2012-04-26 16:28:54 +02:00
antirez
3ada43e732 Don't use an alternative stack for SIGSEGV & co.
This commit reverts most of c575766202, in
order to use back main stack for signal handling.

The main reason is that otherwise it is completely pointless that we do
a lot of efforts to print the stack trace on crash, and the content of
the stack and registers as well. Using an alternate stack broken this
feature completely.
2012-04-26 16:21:19 +02:00
David Tran
31788f50b7 Spelling: s/synchrnonization/synchronization 2012-04-25 12:21:56 -07:00
antirez
29c8cf0116 redis-check-dump now is RDB version 6 ready. 2012-04-24 19:05:27 +02:00
antirez
7dbc514de7 Spurious debugging printf removed. 2012-04-24 17:15:21 +02:00
antirez
a76b9063d0 Added two new encodings to ziplist.c
1) One integer "immediate" encoding that can encode from 0 to 12 in the
encoding byte itself.
2) One 8 bit signed integer encoding that can encode 8 bit signed small
integers in a single byte.

The idea is to exploit all the not used bits we have around in a
backward compatible way.
2012-04-24 17:04:00 +02:00
antirez
053d56a1fa rdbLoad() should check REDIS_RDB_VERSION instead of hardcoded number. 2012-04-24 12:53:30 +02:00
antirez
f22cff43a6 ziplist.c: added comments about the new 24 bit encoding. 2012-04-24 12:52:36 +02:00
Grisha Trubetskoy
5a86ab4799 Add a 24bit integer to ziplists to save one byte for ints that can
fit in 24 bits (thanks to antirez for catching and solving the two's compliment
bug).

Increment REDIS_RDB_VERSION to 6
2012-04-24 12:02:19 +02:00
antirez
21661d7acc Fixed a bug in propagation of PUBLISH via the cluster bus.
This bug was spotted by clang on FreeBSD.
2012-04-24 11:28:10 +02:00
antirez
e54fe9a79f A few compiler warnings suppressed. 2012-04-24 11:11:55 +02:00
antirez
a66a496349 Fix and refactoring of code used to get registers on crash.
This fixes compilation on FreeBSD (and possibly other systems) by
not using ucontext_t at all if HAVE_BACKTRACE is not defined.
Also the ifdefs to get the registers are modified to explicitly test for the
operating system in the first level, and the arch in the second level
of nesting.
2012-04-24 11:11:35 +02:00
Salvatore Sanfilippo
d344228734 Merge pull request #421 from ErikDubbelboer/sds-const
Added consts keyword where possible
2012-04-23 02:34:19 -07:00
antirez
a3f990818d Remove loadfile() access from the scripting engine. 2012-04-23 10:43:24 +02:00
antirez
eb6e7eb94d Even inside #if 0 comments are comments. 2012-04-21 21:49:21 +02:00
antirez
92cc20ecfe Merge remote-tracking branch 'origin/unstable' into unstable 2012-04-21 20:35:51 +02:00
antirez
d3701d2714 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 20:34:45 +02:00
Salvatore Sanfilippo
7d3ee4172f Merge pull request #440 from ErikDubbelboer/spelling
Fixed some spelling errors in comments
2012-04-21 03:31:06 -07:00
antirez
e3923a3508 SHUTDOWN NOSAVE now can stop a non returning script. Issue #466. 2012-04-19 23:35:15 +02:00
antirez
1e35ae7486 Currenly not used code in dict.c commented out. 2012-04-18 23:56:07 +02:00
antirez
5386f72d00 redis-cli --bigkeys output modified to be simpler to read.. 2012-04-18 20:53:37 +02:00
antirez
f26761aa10 redis-cli --bigkeys 2012-04-18 20:33:02 +02:00
antirez
5ba79bda7f Document mostly dead code in RPOPLPUSH implementation. 2012-04-18 17:38:02 +02:00
Salvatore Sanfilippo
d162f9eb64 Merge pull request #456 from pietern/unstable-mkopts
Persist Makefile flags (unstable)
2012-04-18 07:25:59 -07:00
antirez
acf41c96cb Marginally cleaner lookupKeyByPattern() implementation.
just fieldobj itself as sentinel of the fact a field object is used or
not, instead of using the filed length, that may be confusing both for
people and for the compiler emitting a warning.
2012-04-18 11:37:14 +02:00
antirez
a5f8341245 Two small fixes to maxclients handling.
1) Don't accept maxclients set to < 0
2) Allow maxclients < 1024, it is useful for testing.
2012-04-18 11:31:24 +02:00
antirez
3c25c4a691 lookupKeyByPattern() used by SORT GET/BY rewritten. Fixes issue #460.
lookupKeyByPattern() was implemented with a trick to speedup the lookup
process allocating two fake Redis obejcts on the stack. However now that
we propagate expires to the slave as DEL operations the lookup of the
key may result into a call to expireIfNeeded() having the stack
allocated object as argument, that may in turn use it to create the
protocol to send to the slave. But since this fake obejcts are
inherently read-only this is a problem.

As a side effect of this fix there are no longer size limits in the
pattern to be used with GET/BY option of SORT.

See https://github.com/antirez/redis/issues/460 for bug details.
2012-04-17 13:05:09 +02:00
Pieter Noordhuis
7e7b69fee1 Persist make settings and trigger rebuild if anything changes 2012-04-13 17:52:33 -07:00
Pieter Noordhuis
34c943b395 Don't set flags recursively 2012-04-13 17:52:33 -07:00
Pieter Noordhuis
620357fc8f Remove unused LIBS variable 2012-04-13 17:52:33 -07:00
Pieter Noordhuis
caba585121 First set defaults, then do composition 2012-04-13 17:52:33 -07:00
Pieter Noordhuis
c04278ba3b Question mark assignment is not needed 2012-04-13 17:52:33 -07:00
Pieter Noordhuis
166cf8a3b8 Ignore gcov/lcov artifacts 2012-04-13 17:52:33 -07:00
Pieter Noordhuis
0342dd7647 The lcov target shouldn't clean
This is not needed because every change in compiler/linker flags
triggers a cleanup.
2012-04-13 17:52:30 -07:00
Pieter Noordhuis
631539a5f2 Rename ADD_*FLAGS -> REDIS_*FLAGS, REDIS_*FLAGS -> FINAL_*FLAGS
This reflects that REDIS_*FLAGS will only be used for compilation of
Redis and not for its dependencies. Similarly, that FINAL_*FLAGS are
composed of other variables and holds the options that are finally
passed to the compiler and linker.
2012-04-13 17:34:31 -07:00
antirez
93a74949d7 Merge branch 'strict.lua' into unstable 2012-04-13 16:16:13 +02:00
antirez
c18405c909 A few var names fixed in Makefile.
I modified it for error in a previous commit doing search & replace.
2012-04-13 16:13:56 +02:00
antirez
6f659f34cf EVAL errors are more clear now. 2012-04-13 15:12:16 +02:00
antirez
3a02140415 Use Lua tostring() before concatenation. 2012-04-13 14:54:49 +02:00
antirez
d86c4a7bf0 mt.declared is no longer needed.
Lua global protection can now be simpified becuase we no longer have the
global() function. It's useless to occupy memory with this table, it is
also not faster because the metamethods we use are only called when a
global object does not exist or we are trying to create it from a
script.
2012-04-13 13:36:08 +02:00
antirez
6663653f51 Stop access to global vars. Not configurable.
After considering the interaction between ability to delcare globals in
scripts using the 'global' function, and the complexities related to
hanlding replication and AOF in a sane way with globals AND ability to
turn protection On and Off, we reconsidered the design. The new design
makes clear that there is only one good way to write Redis scripts, that
is not using globals. In the rare cases state must be retained across
calls a Redis key can be used.
2012-04-13 13:26:59 +02:00
antirez
c9edd1b28a Globals protection global() function modified for speed and correctness. 2012-04-13 12:13:02 +02:00
antirez
37b29ef2fa Scripting: globals protection can now be switched on/off. 2012-04-13 11:23:45 +02:00
antirez
6e05f333a2 Print arch bits with redis-server -v 2012-04-12 11:50:18 +02:00
antirez
4c442e9d88 memtest.c: integer overflow fixed. 2012-04-12 11:49:52 +02:00
antirez
91e56965a3 Make gcov fixed. 2012-04-12 11:51:58 +02:00
antirez
9c83aec955 Makefile now introduces Redis-specific CFLAGS / LDFLAGS. Gcov target fixed. Added comments to describe how it works. 2012-04-12 11:09:38 +02:00
Salvatore Sanfilippo
0d83011a11 Merge pull request #449 from ErikDubbelboer/unstable
added explanation for the magic 511 backlog number
2012-04-11 09:25:44 -07:00
Erik Dubbelboer
815c06f2f7 added explanation for the magic 511 backlog number 2012-04-11 17:04:31 +02:00
antirez
ced068955d Makefile.dep updated. 2012-04-11 12:12:30 +02:00
antirez
a470689d2e make dep: redirect output to Makefile.dep. 2012-04-11 12:12:05 +02:00
antirez
c44ab51da1 Make inline functions rioRead/Write/Tell static. This fixes issue #447. 2012-04-11 11:58:32 +02:00
antirez
d98b03b791 Macros ULONG_ONEZERO / ULONG_ZEROONE were inverted in #ifdef to test 32/64 bit arch. 2012-04-11 11:32:22 +02:00
Pieter Noordhuis
0a08d2b0e5 Clean up Makefiles
Remove unused variables. Instead of overriding non-standard variables
such as ARCH and PROF, use standard variables CFLAGS and LDFLAGS to
override Makefile settings. Move dependencies generated by `make dep` to
a separate file.
2012-04-11 11:24:17 +02:00
Pieter Noordhuis
3f7438ef9b Everything x86 is little endian 2012-04-11 11:03:30 +02:00
antirez
f2f2ba1b3a Comment typo fixed. Clusetr -> Cluster. 2012-04-11 10:57:02 +02:00
antirez
0b913c650d Check write(2) return value to avoid warnings, because in this context failing write is not critical. 2012-04-10 16:48:28 +02:00
antirez
a3fb7fd4f6 Minor MIGRATE implementation simplification about ttl handling. 2012-04-10 16:46:29 +02:00
antirez
0882715710 Version 2.9.7. 2012-04-10 16:34:33 +02:00
antirez
84bcd3aa24 It is now possible to enable/disable RDB checksum computation from redis.conf or via CONFIG SET/GET. Also CONFIG SET support added for rdbcompression as well. 2012-04-10 15:47:10 +02:00
antirez
82e32055d8 RDB files now embed a crc64 checksum. Version of RDB bumped to 5. 2012-04-09 22:40:41 +02:00
antirez
8491f1d9fd Fixed compilation of new rio.c changes (typos and so forth.) 2012-04-09 12:36:44 +02:00
antirez
46738646d4 dump/restore fixed to use the new crc64 API. 2012-04-09 12:33:57 +02:00
antirez
736b7c3f04 Add checksum computation to rio.c 2012-04-09 12:33:09 +02:00
antirez
88c1d9550d crc64.c modified for incremental computation. 2012-04-09 12:20:47 +02:00
antirez
5a181d43cb rio.c file somewhat documented so that the casual reader can understand what's going on without reading the code. 2012-04-09 11:11:00 +02:00
Erik Dubbelboer
e1d9857b12 Update src/rdb.c 2012-04-07 15:48:30 +03:00
Erik Dubbelboer
8d16e7a3c6 Update src/dict.c 2012-04-07 15:45:53 +03:00
Erik Dubbelboer
65fd32ab0a Fixed some spelling errors in the comments 2012-04-07 14:40:29 +02:00
antirez
2cbdab903f For coverage testing use exit() instead of _exit() when termiating saving children. 2012-04-07 12:11:23 +02:00
antirez
09f66a0be8 New client info field added to CLIENT LIST output: multi, containing the length of the current pipeline. Test modified accordingly. 2012-04-07 11:14:52 +02:00
antirez
4cb8bb2952 Never used function stringObjectEqualsMs() removed. 2012-04-07 02:10:48 +02:00
antirez
f02aa7bb79 Removed dead code: function rdbSaveTime() is no longer used since RDB now saves expires in milliseconds. 2012-04-07 02:03:29 +02:00
antirez
618a922957 New INFO field in persistence section: bgrewriteaof_scheduled. 2012-04-06 21:12:50 +02:00
antirez
321a724da5 version bumped to 2.9.6 2012-04-06 12:27:17 +02:00
jokea
3e1e1ac27d implement aeWait using poll(2). Fixes issue #267. 2012-04-06 11:47:17 +02:00
antirez
70381bbf82 expireGenericCommand(): better variable names and a top-comment that describes the function's behavior. 2012-04-05 15:52:08 +02:00
Premysl Hruby
c6bf4a0034 for (p)expireat use absolute time, without double recomputation 2012-04-05 15:46:21 +02:00
Premysl Hruby
d48d1309c6 fix mstime() ommited while comparing if key is already expired 2012-04-05 15:46:15 +02:00
Premysl Hruby
c35b4e845b add support for generation of lcov coverage reports 2012-04-05 12:23:35 +02:00
Salvatore Sanfilippo
d84f776e87 Merge pull request #426 from anydot/fix-rm-vm-comments
remove mentions of VM in comments
2012-04-05 01:54:09 -07:00
Salvatore Sanfilippo
0d5f4ba7cd Merge pull request #431 from anydot/f-signal
allocate alternate signal stack, change of sigaction flags for sigterm
2012-04-05 01:52:40 -07:00
Premysl Hruby
ebba7b3c92 future-proof version comparison 2012-04-05 10:41:28 +02:00
antirez
4b8c966140 Structure field controlling the INFO field master_link_down_since_seconds initialized correctly to avoid strange INFO output at startup when a slave has yet to connect to its master. 2012-04-04 18:32:22 +02:00
antirez
5ad1faa090 New "os" field in INFO output providing information about the operating system. 2012-04-04 15:38:13 +02:00
antirez
bb0fbc840d SLAVEOF is not a write command. 2012-04-04 15:11:30 +02:00
antirez
9a322ab730 Print milliseconds of the current second in log lines timestamps. Sometimes precise timing is very important for debugging. 2012-04-04 15:11:17 +02:00
Premysl Hruby
c575766202 allocate alternate signal stack, change of sigaction flags for sigterm 2012-04-03 17:40:31 +02:00
antirez
1ad4d50805 redis-cli help.h updated. Script to generate it updated as well. 2012-04-03 15:30:33 +02:00
antirez
12e91892a0 Another fix for MIGRATE. 2012-04-03 15:10:42 +02:00
antirez
84e5684bca Two fixed for MIGRATE: fix TTL propagation and fix transferring of data bigger than 64k. 2012-04-03 12:17:40 +02:00
antirez
e7957ca628 When the user-provided 'maxclients' value is too big for the max number of files we can open, at least try to search the max the OS is allowing (in steps of 256 filedes). 2012-04-03 11:53:45 +02:00
antirez
31f2ecf436 MIGRATE now let the client distinguish I/O errors and timeouts from other erros. 2012-04-02 16:38:24 +02:00
antirez
f8ea19e539 DUMP/RESTORE now use CRC64 instead of truncated SHA1. 2012-04-02 13:10:39 +02:00
antirez
9510d65dc8 CRC64 implementation added to Redis code base. 2012-04-02 12:31:44 +02:00
Premysl Hruby
8918de9202 remove mentions of VM in comments 2012-04-02 11:56:03 +02:00
antirez
70d848e1fa RESTORE ability to set a TTL fixed, bug introduced with millisecond expires. 2012-04-02 11:14:47 +02:00
antirez
a149ce6875 Prettify source code of create/verify DUMP payload. 2012-04-02 10:52:39 +02:00
antirez
bd04465931 DUMP / RESTORE: store RDB version in little endian. 2012-04-02 10:46:24 +02:00
antirez
4de6c9a055 New DUMP format includes RDB version and truncated SHA1 checksum. 2012-04-01 12:51:40 +02:00
antirez
d0ace5a314 Write RDB magic using a REDIS_RDB_VERSION define that is defined inside rdb.h 2012-03-31 17:08:40 +02:00
antirez
609ea08445 redis-trib: fix the MIGRATE call that now has milliseconds timeout (were seconds before). 2012-03-31 11:28:37 +02:00
antirez
9157549fad syncio.c calls in replication.c fixed for the new millisecond timeout API. 2012-03-31 11:23:30 +02:00
antirez
04d360fdcd Better syncio.c with millisecond resolution. 2012-03-31 11:21:45 +02:00
Erik Dubbelboer
0a2ff52eae Added consts keyword where possible 2012-03-30 21:19:51 +02:00
antirez
c2672a06cd Purely aesthetic code change. 2012-03-30 10:39:34 +02:00
Joseph Jang
f892797e1b 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 10:34:29 +02:00
antirez
0cdecca141 Protect globals access in Lua scripting. 2012-03-29 12:02:28 +02:00
antirez
4cba71e898 Fixed typo in comment: "te" -> "the". 2012-03-29 09:33:29 +02:00
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
Nathan Fritz
52ae8af807 added redis.sha1hex(string) as lua scripting function.
(The original implementation was modified by @antirez to conform Redis
coding standards.)
2012-03-28 20:37:40 +02:00
antirez
5471b8babd Fixes for redisLogFromHandler(). 2012-03-28 13:51:23 +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
Salvatore Sanfilippo
e4669c045d Merge pull request #389 from huangz1990/patch-1
fix typo
2012-03-27 14:00:08 -07:00
Premysl Hruby
b57dbdbba3 remove disk-store related comments 2012-03-27 18:46:51 +02:00
Premysl Hruby
8af9fe841c declare hashDictType as external too 2012-03-27 18:18:57 +02:00
Premysl Hruby
d194905449 use server.unixtime instead of time(NULL) where possible (cluster.c not checked though) 2012-03-27 17:39:58 +02:00
Premysl Hruby
024f213b12 fix time() instead of mstime() in expireIfNeeded 2012-03-27 17:31:21 +02:00
antirez
d174eed5d7 define zlibc_free() in a way that is not shadowed by jemalloc. 2012-03-27 16:54:53 +02:00
antirez
23c0cdd2ad Produce the watchlog warning log in a way that is safer from a signal handler. Fix a memory leak in the backtrace generation function. 2012-03-27 15:24:33 +02:00
antirez
aa96122d96 Mask SIGALRM everything but in the main thread.
This is required to ensure that the signal will be delivered to the main
thread when the watchdog timer expires.
2012-03-27 13:48:57 +02:00
antirez
a354da9acd Correctly set the SIGARLM timer for the software watchdog. 2012-03-27 12:11:37 +02:00
antirez
39bd025c29 Redis software watchdog. 2012-03-27 11:47:51 +02:00
antirez
a323870450 SIGSEGV handler refactored so that we can reuse stack trace and current client logging functionalities in other contexts. 2012-03-27 10:40:07 +02:00
antirez
ca09ad4d64 CONFIG RESETSTAT resets two more fields. 2012-03-25 11:43:19 +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
1b247d1333 Add used allocator in redis-server -v output. 2012-03-24 11:53:03 +01:00
antirez
58e34e6cb1 Fixed memory leak in hash loading. 2012-03-23 20:24:34 +01:00
antirez
bd376d13f8 Big endian fix. The bug was introduced because of a typo. 2012-03-23 12:42:20 +01:00
antirez
6f0e77ca19 Replicate HINCRBYFLOAT as HSET. 2012-03-23 10:22:58 +01:00
antirez
7b558b1d64 Code style hack. 2012-03-22 18:17:09 +01:00
antirez
1f6146df0c Result of INCRBYFLOAT and HINCRBYFLOAT should never be in exponential form, and also should never contain trailing zeroes. This is not possible with vanilla printf() format specifiers, so we alter the output. 2012-03-22 18:17:05 +01:00
antirez
b22eab8faf Correctly create shared.oomerr as an sds string. 2012-03-21 12:11:07 +01:00
antirez
7dcdd281f5 DEBUG should not be flagged as w otherwise we can not call DEBUG DIGEST and other commands against read only slaves. 2012-03-20 17:53:47 +01: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
0d44d50792 Suppress warnings compiling redis-cli with certain gcc versions. 2012-03-19 19:28:49 +01:00
antirez
bb0aadbe21 Read-only flag removed from PUBLISH command. 2012-03-19 19:16:41 +01:00
antirez
d4a515c56d Memory addressing test implemented. 2012-03-19 14:02:34 +01:00
antirez
d033ccb0af More memory tests implemented. Default number of iterations lowered to a more acceptable value of 50. 2012-03-18 18:03:27 +01:00
antirez
a5801142a4 Fixed typo. 2012-03-18 17:27:56 +01:00
antirez
1a197a3c1a Number of iteration of --test-memory is now 300 (several minutes per gigabyte). Memtest86 and Memtester links are also displayed while running the test. 2012-03-18 17:25:00 +01:00
antirez
525be599a8 On crash suggest to give --test-memory a try. 2012-03-18 11:35:35 +01:00
antirez
fb068dc91d Memory test function now less boring thanks to screen-wide progress bar. 2012-03-16 21:19:53 +01:00
antirez
54e0fa1c27 Hem... actual memtest.c file added. 2012-03-16 17:21:49 +01:00
antirez
c5166e3fc5 First implementation of --test-memory. Still a work in progress. 2012-03-16 17:17:39 +01:00
antirez
c9d3dda29c Fix for issue #391.
Use a simple protocol between clientsCron() and helper functions to
understand if the client is still valind and clientsCron() should
continue processing or if the client was freed and we should continue
with the next one.
2012-03-15 20:55:14 +01:00
huangz1990
9448ddb0c6 fix typo 2012-03-15 14:27:14 +08:00
antirez
ae22bf1ef6 Reclaim space from the client querybuf if needed. 2012-03-14 15:32:30 +01:00
antirez
739803c064 sds.c: sdsAllocSize() function added. 2012-03-14 14:58:26 +01:00
antirez
9555f8f21b sds.c new function sdsRemoveFreeSpace().
The new function is used in order to resize the string allocation so
that only the minimal allocation possible is used, removing all the free
space at the end of the string normally used to improve efficiency of
concatenation operations.
2012-03-14 10:13:23 +01:00
antirez
529bde82ec Call all the helper functions needed by clientsCron() as clientsCronSomething() for clarity. 2012-03-14 09:56:22 +01:00
antirez
d19015be12 Process async client checks like client timeouts and BLPOP timeouts incrementally using a circular list. 2012-03-13 18:05:11 +01:00
antirez
bbaeda402c Added a qbuf-free field to CLIENT LIST output. 2012-03-13 13:26:33 +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
573373802e c->bufpos initialization moved for aesthetics. 2012-03-13 12:59:27 +01:00
antirez
c3e7441dad RDB hashes loading, fixed another bug in the loading of HT-encoded hashes: when the hash entry is too big for ziplist, add the field, then convert. The code used to break before the new entry was inserted, resulting into missing fields in the loaded Hash object. 2012-03-13 11:00:18 +01:00
antirez
c3c856228d RDB hashes loading fixed removing the assertion that failed every time an HT-encoded hash was loaded. 2012-03-13 09:49:11 +01:00
antirez
64b4c33c0b Build dependencies updated. 2012-03-10 12:40:03 +01:00
antirez
f12d0224f3 RDB4 support in redis-check-dump. 2012-03-10 12:38:42 +01:00
antirez
c7d7d0a80f RDB version is no 4, because small hashes are now encoded as ziplists, so older versions of Redis will not understand this format. 2012-03-10 12:35:31 +01:00
antirez
753bb3dcbd More vertical space saved. 2012-03-10 11:19:17 +01:00
antirez
c0caa1cf54 Minor code aesthetic change to use Redis code base style rule of saving vertical space when possible. 2012-03-10 11:09:43 +01:00
antirez
d22248ae99 Removed handling of deprecated hash-max-zipmap-entries nad hash-map-zipmap-value. Pieter is too good with users ;). Better to have them switch to a saner configuration ASAP after the 2.6 upgrade. 2012-03-10 10:41:39 +01:00
antirez
addc032756 Added a top-function comment to rioWriteHashIteratorCursor() to better specify what the function does. Not immediately clear from the name. 2012-03-10 10:36:51 +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
0823e48fb9 Support for all the redis.conf fields in CONFIG GET. config.c refactored a bit. 2012-03-08 12:14:23 +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
7b845b6228 anetPeerToString() automatically populates ip/port with something that may be provided to the user as output in case of errors. 2012-03-07 11:30:30 +01:00
antirez
9494f1f15b TIME command. 2012-03-07 10:38:01 +01:00
antirez
60893c6cc6 redis-cli: CSV output added, used for the --slave mode. 2012-02-29 17:43:06 +01:00
antirez
b8283ab218 Initial implementation of redis-cli --slave support. 2012-02-29 17:10:21 +01:00
antirez
a950a84303 Ping the slave using the standard protocol instead of the inline one. 2012-02-29 16:33:54 +01:00
antirez
c1db214eeb Better implementation for BRPOP/BLPOP in the non blocking case. 2012-02-29 14:41:57 +01:00
antirez
cd8bdea31b lpush arguments vector rewrite modified for more speed and to memory leak removal. 2012-02-29 13:38:30 +01:00
antirez
b67feecacd Version bumped to 2.9.5 2012-02-29 00:54:52 +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
edba65d090 Var renamed into pushGenericCommand() to better reflect what it means. 2012-02-28 16:17:55 +01:00
antirez
ad08d059d0 Added command propagation API. 2012-02-28 16:17:00 +01:00
Jakub Wieczorek
1d6628c088 Fix the build on Mac OS X, where features.h is non-existent 2012-02-26 15:13:05 +01:00
Premysl Hruby
80ff1fc6d0 use gcc sync builtins for memory counter when possible 2012-02-26 11:45:52 +01:00
Premysl Hruby
59132e4212 fix redis-benchmark memory leak 2012-02-26 10:01:27 +01:00