Commit Graph

3073 Commits

Author SHA1 Message Date
antirez 51943a78b0 Deprecate Redis Sentinel in 2.6.
Everybody should use the more robust implementation shipped with 2.8.
2014-02-25 15:18:43 +01:00
antirez 2fc65c844f Redis 2.6.17. 2013-12-11 15:35:52 +01:00
Salvatore Sanfilippo ce7588c43e Merge pull request #847 from yossigo/repldboff-fix
Fix wrong repldboff type which causes dropped replication in rare cases.
2013-12-11 02:36:16 -08:00
antirez e4c6458a94 Only run the fast active expire cycle if master & enabled. 2013-12-10 18:58:25 +01:00
antirez 9316362ae2 Log to what master a slave is going to connect to. 2013-11-11 09:25:44 +01:00
antirez aecb6406cf Fix broken rdbWriteRaw() return value check in rdb.c.
Thanks to @PhoneLi for reporting.
2013-11-07 23:54:48 +01:00
Salvatore Sanfilippo 55b6c415bb Merge pull request #1366 from yaauie/deprecate-redis-copy-script-in-2.6
2.6 branch backport of #1365
2013-11-06 01:38:10 -08:00
Ryan Biesemeyer 2738117293 Deprecate utils/redis-copy.rb in favor of redis-copy gem 2013-11-06 09:18:56 +00:00
antirez 072a976700 redis-benchmark: update help for new __rand_int__ form. 2013-10-28 18:14:19 +01:00
antirez f3a7140884 Allow AUTH / PING when disconnected from slave and serve-stale-data is no. 2013-09-17 09:46:45 +02:00
antirez 1fc83e65ab redis-cli: fix big keys search when the key no longer exist.
The code freed a reply object that was never created, resulting in a
segfault every time randomkey returned a key that was deleted before we
queried it for size.
2013-09-04 10:37:58 +02:00
antirez bf8d0e60c4 Redis 2.6.16. 2013-08-28 11:36:25 +02:00
yihuang 477e4daab9 fix lua_cmsgpack pack map as array 2013-08-27 15:19:27 +02:00
antirez ef0fa0895a Fix an hypothetical issue in processMultibulkBuffer(). 2013-08-27 13:00:17 +02:00
antirez e3cbc018a3 tryObjectEncoding(): optimize sds strings if possible.
When no encoding is possible, at least try to reallocate the sds string
with one that does not waste memory (with free space at the end of the
buffer) when the string is large enough.
2013-08-27 12:52:08 +02:00
antirez b5cc22d191 tryObjectEncoding(): don't call stringl2() for too big strings.
We are sure that a string that is longer than 21 chars cannot be
represented by a 64 bit signed integer, as -(2^64) is 21 chars:

strlen(-18446744073709551616) => 21
2013-08-27 12:52:03 +02:00
antirez 6b61e94b18 Fix DEBUG SDSLEN after 2.8 back port. 2013-08-27 12:51:56 +02:00
antirez 84472a3565 Don't over-allocate the sds string for large bulk requests.
The call to sdsMakeRoomFor() did not accounted for the amount of data
already present in the query buffer, resulting into over-allocation.
2013-08-27 12:51:51 +02:00
antirez e5fe66efe9 DEBUG SDSLEN added.
This command is only useful for low-level debugging of memory issues due
to sds wasting memory as empty buffer at the end of the string.
2013-08-27 12:51:45 +02:00
antirez 7bf2690043 Update server.lastbgsave_status when fork() fails. 2013-08-27 10:16:01 +02:00
antirez 2bfa679a0a Redis 2.6.15 2013-08-21 14:23:44 +02:00
antirez e03c730df4 Use printf %zu specifier to print private_dirty. 2013-08-20 12:09:47 +02:00
antirez 718fd3c600 dictFingerprint(): cast pointers to integer of same size. 2013-08-20 12:09:42 +02:00
antirez 3bacf4c738 Revert "Fixed type in dict.c comment: 265 -> 256."
This reverts commit 19de8e46bf.
2013-08-19 17:26:04 +02:00
antirez 19de8e46bf Fixed type in dict.c comment: 265 -> 256. 2013-08-19 15:11:09 +02:00
antirez e16dd1d86b assert.h replaced with redisassert.h when appropriate.
Also a warning was suppressed by including unistd.h in redisassert.h
(needed for _exit()).
2013-08-19 15:02:44 +02:00
antirez 85070a3044 Added redisassert.h as drop in replacement for assert.h.
By using redisassert.h version of assert() you get stack traces in the
log instead of a process disappearing on assertions.
2013-08-19 15:02:41 +02:00
antirez 3a40b02d78 dictFingerprint() fingerprinting made more robust.
The previous hashing used the trivial algorithm of xoring the integers
together. This is not optimal as it is very likely that different
hash table setups will hash the same, for instance an hash table at the
start of the rehashing process, and at the end, will have the same
fingerprint.

Now we hash N integers in a smarter way, by summing every integer to the
previous hash, and taking the integer hashing again (see the code for
further details). This way it is a lot less likely that we get a
collision. Moreover this way of hashing explicitly protects from the
same set of integers in a different order to hash to the same number.

This commit is related to issue #1240.
2013-08-19 15:02:38 +02:00
antirez d9bf918d5b Fix comments for correctness in zunionInterGenericCommand().
Related to issue #1240.
2013-08-19 15:02:34 +02:00
antirez bf3932ed9f Properly init/release iterators in zunionInterGenericCommand().
This commit does mainly two things:

1) It fixes zunionInterGenericCommand() by removing mass-initialization
of all the iterators used, so that we don't violate the unsafe iterator
API of dictionaries. This fixes issue #1240.

2) Since the zui* APIs required the allocator to be initialized in the
zsetopsrc structure in order to use non-iterator related APIs, this
commit fixes this strict requirement by accessing objects directly via
the op->subject->ptr pointer we have to the object.
2013-08-19 15:02:31 +02:00
antirez 4a005a2ad4 dict.c iterator API misuse protection.
dict.c allows the user to create unsafe iterators, that are iterators
that will not touch the dictionary data structure in any way, preventing
copy on write, but at the same time are limited in their usage.

The limitation is that when itearting with an unsafe iterator, no call
to other dictionary functions must be done inside the iteration loop,
otherwise the dictionary may be incrementally rehashed resulting into
missing elements in the set of the elements returned by the iterator.

However after introducing this kind of iterators a number of bugs were
found due to misuses of the API, and we are still finding
bugs about this issue. The bugs are not trivial to track because the
effect is just missing elements during the iteartion.

This commit introduces auto-detection of the API misuse. The idea is
that an unsafe iterator has a contract: from initialization to the
release of the iterator the dictionary should not change.

So we take a fingerprint of the dictionary state, xoring a few important
dict properties when the unsafe iteartor is initialized. We later check
when the iterator is released if the fingerprint is still the same. If it
is not, we found a misuse of the iterator, as not allowed API calls
changed the internal state of the dictionary.

This code was checked against a real bug, issue #1240.

This is what Redis prints (aborting) when a misuse is detected:

Assertion failed: (iter->fingerprint == dictFingerprint(iter->d)),
function dictReleaseIterator, file dict.c, line 587.
2013-08-19 15:02:26 +02:00
antirez db1e135ec1 Fix sdsempty() prototype in sds.h. 2013-08-12 11:38:32 +02:00
antirez 1c4e3011eb redis-benchmark: changes to random arguments substitution.
Before this commit redis-benchmark supported random argumetns in the
form of :rand:000000000000. In every string of that form, the zeros were
replaced with a random number of 12 digits at every command invocation.

However this was far from perfect as did not allowed to generate simply
random numbers as arguments, there was always the :rand: prefix.

Now instead every argument in the form __rand_int__ is replaced with a
12 digits number. Note that "__rand_int__" is 12 characters itself.

In order to implement the new semantic, it was needed to change a few
thigns in the internals of redis-benchmark, as new clients are created
cloning old clients, so without a stable prefix such as ":rand:" the old
way of cloning the client was no longer able to understand, from the old
command line, what was the position of the random strings to substitute.

Now instead a client structure is passed as a reference for cloning, so
that we can directly clone the offsets inside the command line.
2013-08-08 18:19:12 +02:00
antirez f4f93131ba redis-benchmark: replace snprintf()+memcpy with faster code.
This change was profiler-driven, but the actual effect is hard to
measure in real-world redis benchmark runs.
2013-08-08 18:19:04 +02:00
Jan-Erik Rediger 702f3afe1e Little typo 2013-08-07 16:09:30 +02:00
antirez 4343f0b256 redis-benchmark: fix memory leak introduced by 346256f 2013-08-07 16:09:26 +02:00
antirez 79635cbed4 redis-benchmark: max pipeline length hardcoded limit removed. 2013-08-07 16:09:22 +02:00
antirez d5a4c3e842 redis-benchmark: fix db selection when :rand: feature is used. 2013-08-07 11:37:49 +02:00
antirez d2d3ac3fe9 redis-benchmark: ability to SELECT a specifid db number. 2013-08-07 11:37:45 +02:00
antirez 487e66557e Add per-db average TTL information in INFO output.
Example:

db0:keys=221913,expires=221913,avg_ttl=655

The algorithm uses a running average with only two samples (current and
previous). Keys found to be expired are considered at TTL zero even if
the actual TTL can be negative.

The TTL is reported in milliseconds.
2013-08-07 11:37:42 +02:00
antirez 2e4ec79313 activeExpireCycle(): fix about fast cycle early start.
We don't want to repeat a fast cycle too soon, the previous code was
broken, we need to wait two times the period *since* the start of the
previous cycle in order to avoid there is an even space between cycles:

.-> start                   .-> second start
|                           |
+-------------+-------------+--------------+
| first cycle |    pause    | second cycle |
+-------------+-------------+--------------+

The second and first start must be PERIOD*2 useconds apart hence the *2
in the new code.
2013-08-07 11:37:38 +02:00
antirez 1bcf296cf9 Some activeExpireCycle() refactoring. 2013-08-07 11:37:34 +02:00
antirez 97f5e86763 Remove dead code and fix comments for new expire code. 2013-08-07 11:37:30 +02:00
antirez d9a4fd0f32 Darft #2 for key collection algo: more improvements.
This commit makes the fast collection cycle time configurable, at
the same time it does not allow to run a new fast collection cycle
for the same amount of time as the max duration of the fast
collection cycle.
2013-08-07 11:37:26 +02:00
antirez ab782615cc Draft #1 of a new expired keys collection algorithm.
The main idea here is that when we are no longer to expire keys at the
rate the are created, we can't block more in the normal expire cycle as
this would result in too big latency spikes.

For this reason the commit introduces a "fast" expire cycle that does
not run for more than 1 millisecond but is called in the beforeSleep()
hook of the event loop, so much more often, and with a frequency bound
to the frequency of executed commnads.

The fast expire cycle is only called when the standard expiration
algorithm runs out of time, that is, consumed more than
REDIS_EXPIRELOOKUPS_TIME_PERC of CPU in a given cycle without being able
to take the number of already expired keys that are yet not collected
to a number smaller than 25% of the number of keys.

You can test this commit with different loads, but a simple way is to
use the following:

Extreme load with pipelining:

redis-benchmark -r 100000000 -n 100000000  \
        -P 32 set ele:rand:000000000000 foo ex 2

Remove the -P32 in order to avoid the pipelining for a more real-world
load.

In another terminal tab you can monitor the Redis behavior with:

redis-cli -i 0.1 -r -1 info keyspace

and

redis-cli --latency-history

Note: this commit will make Redis printing a lot of debug messages, it
is not a good idea to use it in production.
2013-08-07 11:37:17 +02:00
antirez 16ddbb7dfc Fixed typo in 2.6.14 changelog. verison -> version. 2013-06-20 10:56:05 +02:00
antirez f2f2b4eb9d Redis 2.6.14 2013-06-20 10:36:40 +02:00
antirez 252f0b6556 Sentinel: parse new INFO replication output correctly.
Sentinel was not able to detect slaves when connected to a very recent
version of Redis master since a previos non-backward compatible change
to INFO broken the parsing of the slaves ip:port INFO output.

This fixes issue #1164
2013-06-20 10:24:43 +02:00
antirez ee92c043fc Test: regression test for #1163. 2013-06-19 18:53:17 +02:00
antirez 8e63fd0734 Allow writes from scripts called by AOF loading in read-only slaves.
This fixes issue #1163
2013-06-19 18:29:10 +02:00