6301 Commits

Author SHA1 Message Date
antirez
8449227f55 PSYNC2: Fix off by one buffer size in luaCreateFunction(). 2017-11-30 18:41:05 +01:00
antirez
eeac1d35d9 PSYNC2: just store script bodies into RDB.
Related to #4483. As suggested by @soloestoy, we can retrieve the SHA1
from the body. Given that in the new implementation using AUX fields we
ended copying around a lot to create new objects and strings, extremize
such concept and trade CPU for space inside the RDB file.
2017-11-30 18:41:00 +01:00
antirez
fb0441a8a2 PSYNC2: luaCreateFunction() should handle NULL client parameter.
See #4483. This is needed because luaCreateFunction() is now called
from RDB loading code outside a client context.
2017-11-30 18:40:53 +01:00
antirez
0429db3c65 PSYNC2: Save Lua scripts state into RDB file.
This is currently needed in order to fix #4483, but this can be
useful in other contexts, so maybe later we may want to remove the
conditionals and always save/load scripts.

Note that we are using the "lua" AUX field here, in order to guarantee
backward compatibility of the RDB file. The unknown AUX fields must be
discarded by past versions of Redis.
2017-11-30 18:40:35 +01:00
antirez
d06fbbdd54 Regression test: Slave restart with EVALSHA in backlog issue #4483. 2017-11-30 18:40:27 +01:00
antirez
ab3d3aca48 Prevent corruption of server.executable after DEBUG RESTART.
Doing the following ended with a broken server.executable:

1. Start Redis with src/redis-server
2. Send CONFIG SET DIR /tmp/
3. Send DEBUG RESTART

At this point we called execve with an argv[0] that is no longer related
to the new path. So after the restart the absolute path of the
executable is recomputed in the wrong way. With this fix we pass the
absolute path already computed as argv[0].
2017-11-30 18:40:20 +01:00
antirez
b7c7edf912 Be more verbose when DEBUG RESTART fails. 2017-11-30 18:40:17 +01:00
antirez
cbb6f45784 Redis 4.0.3. 4.0.3 2017-11-30 13:23:42 +01:00
antirez
d766322e67 LFU: Fix LFUDecrAndReturn() to just decrement.
Splitting the popularity in half actually just needs decrementing the
counter because the counter is logarithmic.
2017-11-30 13:14:04 +01:00
zhaozhao.zz
6544796ab4 LFU: add hotkeys option to redis-cli 2017-11-30 13:13:56 +01:00
zhaozhao.zz
e2355c192c LFU: do some changes about LFU to find hotkeys
Firstly, use access time to replace the decreas time of LFU.
For function LFUDecrAndReturn,
it should only try to get decremented counter,
not update LFU fields, we will update it in an explicit way.
And we will times halve the counter according to the times of
elapsed time than server.lfu_decay_time.
Everytime a key is accessed, we should update the LFU
including update access time, and increment the counter after
call function LFUDecrAndReturn.
If a key is overwritten, the LFU should be also updated.
Then we can use `OBJECT freq` command to get a key's frequence,
and LFUDecrAndReturn should be called in `OBJECT freq` command
in case of the key has not been accessed for a long time,
because we update the access time only when the key is read or
overwritten.
2017-11-30 13:13:56 +01:00
zhaozhao.zz
22969a13a0 LFU: change lfu* parameters to int 2017-11-30 13:13:56 +01:00
zhaozhao.zz
6b71f714bd LFU: fix the missing of config get and rewrite 2017-11-30 13:13:56 +01:00
Felix Krause
2090052ef2 Update link to https and use inline link 2017-11-28 18:45:03 +01:00
Bo Cai
a75f2025f2 redis-cli.c typo: Requets -> Requests.
Signed-off-by: Bo Cai <charpty@gmail.com>
2017-11-28 18:45:03 +01:00
Bo Cai
76aab08f1f redis-cli.c typo: helpe -> helper.
Signed-off-by: Bo Cai <charpty@gmail.com>
2017-11-28 18:45:03 +01:00
Sébastien Fievet
b6fe5074e1 Fix some typos 2017-11-28 18:45:03 +01:00
antirez
eda5cb0a04 t_hash.c: clarify calling two times the same function. 2017-11-28 18:38:49 +01:00
antirez
4a60fbd8b5 adlist: fix listJoin() in the case the second list is empty.
See #4192, the original PR removed lines of code that are actually
needed, so thanks to @chunqiulfq for reporting the problem, but merging
solution from @jeesyn after checking, together with @artix75, that the
logic covers all the cases.
2017-11-28 18:27:59 +01:00
Chris Lamb
060eb3b2d0 Correct spelling of "faield". 2017-11-28 18:27:59 +01:00
antirez
3c942b1269 Improve OBJECT HELP descriptions.
See #4472.
2017-11-28 17:34:47 +01:00
antirez
6b6a83c7ab Fix entry command table entry for OBJECT for HELP option.
After #4472 the command may have just 2 arguments.
2017-11-28 17:34:47 +01:00
Itamar Haber
048097ada8 Adds OBJECT help 2017-11-28 17:34:47 +01:00
David Carlier
906134fe52 Fix undefined behavior constant defined. 2017-11-28 17:34:47 +01:00
rouzier
03657e88fe Fix file descriptor leak and error handling 2017-11-28 17:34:08 +01:00
Itamar Haber
52fda0132d Prevents OBJECT freq with noeviction
When maxmemory is set to noeviction, idletime is implicitly kept. This renders access frequency nonsensical.
2017-11-27 13:08:35 +01:00
Itamar Haber
15bc8e97a9 Adds -u <uri> option to redis-cli. 2017-11-27 12:32:58 +01:00
antirez
f30454c1f6 Test: regression test for latency expire events logging bug.
Regression for #4452.
2017-11-27 12:32:41 +01:00
zhaozhao.zz
1e7227f429 expire & latency: fix the missing latency records generated by expire 2017-11-27 12:32:38 +01:00
antirez
9524fce0ac Modules: fix memory leak in RM_IsModuleNameBusy(). 2017-11-24 13:30:06 +01:00
antirez
2a27da1cf5 PSYNC2: reorganize comments related to recent fixes.
Related to PR #4412 and issue #4407.
2017-11-24 11:10:03 +01:00
zhaozhao.zz
e0c2a0ecfd PSYNC2: persist cached_master's dbid inside the RDB 2017-11-24 11:09:28 +01:00
zhaozhao.zz
2eca8aed14 PSYNC2: make repl_stream_db never be -1
it means that after this change all the replication
info in RDB is valid, and it can distinguish us from
the older version.
2017-11-24 11:09:28 +01:00
zhaozhao.zz
3594238350 PSYNC2: clarify the scenario when repl_stream_db can be -1 2017-11-24 11:09:28 +01:00
zhaozhao.zz
be1b9ee0d5 PSYNC2 & RDB: fix the missing rdbSaveInfo for BGSAVE 2017-11-24 11:09:18 +01:00
zhaozhao.zz
9f69e179cf PSYNC2: safe free backlog when reach the time limit
When we free the backlog, we should use a new
replication ID and clear the ID2. Since without
backlog we can not increment master_repl_offset
even do write commands, that may lead to inconsistency
when we try to connect a "slave-before" master
(if this master is our slave before, our replid
equals the master's replid2). As the master have our
history, so we can match the master's replid2 and
second_replid_offset, that make partial sync work,
but the data is inconsistent.
2017-11-24 11:09:14 +01:00
zhaozhao.zz
0205dd01e2 Modules: handle the busy module name 2017-11-24 09:38:34 +01:00
zhaozhao.zz
3cce566eb1 Modules: handle the conflict of registering commands 2017-11-24 09:38:31 +01:00
Oran Agra
d01f163ce0 fix string to double conversion, stopped parsing on \0 even if the string has more data.
getLongLongFromObject calls string2ll which has this line:
/* Return if not all bytes were used. */
so if you pass an sds with 3 characters "1\01" it will fail.

but getLongDoubleFromObject calls strtold, and considers it ok if eptr[0]==`\0`
i.e. if the end of the string found by strtold ends with null terminator

127.0.0.1:6379> set a 1
OK
127.0.0.1:6379> setrange a 2 2
(integer) 3
127.0.0.1:6379> get a
"1\x002"
127.0.0.1:6379> incrbyfloat a 2
"3"
127.0.0.1:6379> get a
"3"
2017-11-24 09:00:37 +01:00
antirez
9a3e15c6a2 Modules: fix for scripting replication of modules commands.
See issue #4466 / #4467.
2017-11-23 15:15:50 +01:00
Yossi Gottlieb
fa87879bab Nested MULTI/EXEC may replicate in different cases.
For example:
1. A module command called within a MULTI section.
2. A Lua script with replicate_commands() called within a MULTI section.
3. A module command called from a Lua script in the above context.
2017-11-23 15:15:50 +01:00
zhaozhao.zz
bc7076b090 rehash: handle one db until finished 2017-11-21 09:50:08 +01:00
kmiku7
7675b00a64 fix boundary case for _dictNextPower 2017-11-08 17:09:01 +01:00
Itamar Haber
f31d9b12fd Fixes an off-by-one in argument handling of MEMORY USAGE
Fixes #4430
2017-11-08 15:50:59 +01:00
antirez
897d857115 SDS: improve sdsRemoveFreeSpace() to avoid useless data copy.
Since SDS v2, we no longer have a single header, so the function to
rewrite the SDS in terms of the minimum space required, instead of just
using realloc() and let the underlying allocator decide what to do,
was doing an allocation + copy every time the minimum possible header
needed to represent the string was different than the current one.
This could be often a bit wasteful, because if we go, for instance, from
the 32 bit fields header to the 16 bit fields header, the overhead of
the header is normally very small. With this commit we call realloc
instead, unless the change in header size is very significant in relation
to the string length.
2017-11-08 15:50:59 +01:00
antirez
1ee6af4d87 Fix saving of zero-length lists.
Normally in modern Redis you can't create zero-len lists, however it's
possible to load them from old RDB files generated, for instance, using
Redis 2.8 (see issue #4409). The "Right Thing" would be not loading such
lists at all, but this requires to hook in rdb.c random places in a not
great way, for a problem that is at this point, at best, minor.

Here in this commit instead I just fix the fact that zero length lists,
materialized as quicklists with the first node set to NULL, were
iterated in the wrong way while they are saved, leading to a crash.

The other parts of the list implementation are apparently able to deal
with empty lists correctly, even if they are no longer a thing.
2017-11-06 12:37:28 +01:00
antirez
1740300f35 Fix buffer overflows occurring reading redis.conf.
There was not enough sanity checking in the code loading the slots of
Redis Cluster from the nodes.conf file, this resulted into the
attacker's ability to write data at random addresses in the process
memory, by manipulating the index of the array. The bug seems
exploitable using the following techique: the config file may be altered so
that one of the nodes gets, as node ID (which is the first field inside the
structure) some data that is actually executable: then by writing this
address in selected places, this node ID part can be executed after a
jump. So it is mostly just a matter of effort in order to exploit the
bug. In practice however the issue is not very critical because the
bug requires an unprivileged user to be able to modify the Redis cluster
nodes configuration, and at the same time this should result in some
gain. However Redis normally is unprivileged as well. Yet much better to
have this fixed indeed.

Fix #4278.
2017-10-31 09:52:56 +01:00
antirez
b25c245156 Regression test for issue #4391. 2017-10-30 13:46:11 +01:00
antirez
1847b987c6 More robust object -> double conversion.
Certain checks were useless, at the same time certain malformed inputs
were accepted without problems (emtpy strings parsed as zero).
Cases where strtod() returns ERANGE but we still want to parse the input
where ok in getDoubleFromObject() but not in the long variant.

As a side effect of these fixes, this commit fixes #4391.
2017-10-30 13:46:09 +01:00
antirez
c94cd1d831 Limit statement in RM_BlockClient() to 80 cols. 2017-10-04 16:12:47 +02:00