Commit Graph
7709 Commits
Author SHA1 Message Date
Khem Raj 3c610b4e8d Mark extern definition of SDS_NOINIT in sds.h
This helps in avoiding multiple definition of this variable, its also
defined globally in sds.c

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2020-02-12 14:06:04 +01:00
Seunghoon Woo 16b2d07f0a [FIX] revisit CVE-2015-8080 vulnerability 2020-02-10 10:49:43 +01:00
yz1509 19f3358564 avoid sentinel changes promoted_slave to be its own replica. 2020-01-08 12:31:23 +01:00
antirez 4891612bb5 Redis 5.0.7. 5.0.7 2019-11-19 18:05:52 +01:00
antirez 4d2a31aed8 Test: fix implementation-dependent test after code change. 2019-11-19 17:41:47 +01:00
Oran Agra 9f63fc98df RED-31295 - redis: avoid race between dlopen and thread creation
It seeems that since I added the creation of the jemalloc thread redis
sometimes fails to start with the following error:

Inconsistency detected by ld.so: dl-tls.c: 493: _dl_allocate_tls_init: Assertion `listp->slotinfo[cnt].gen <= GL(dl_tls_generation)' failed!

This seems to be due to a race bug in ld.so, in which TLS creation on the
thread, collide with dlopen.

Move the creation of BIO and jemalloc threads to after modules are loaded.

plus small bugfix when trying to disable the jemalloc thread at runtime
2019-11-19 17:37:21 +01:00
antirez 1a9e70c1d7 Cluster: fix memory leak of cached master.
This is what happened:

1. Instance starts, is a slave in the cluster configuration, but
actually server.masterhost is not set, so technically the instance
is acting like a master.

2. loadDataFromDisk() calls replicationCacheMasterUsingMyself() even if
the instance is a master, in the case it is logically a slave and the
cluster is enabled. So now we have a cached master even if the instance
is practically configured as a master (from the POV of
server.masterhost value and so forth).

3. clusterCron() sees that the instance requires to replicate from its
master, because logically it is a slave, so it calls
replicationSetMaster() that will in turn call
replicationCacheMasterUsingMyself(): before this commit, this call would
overwrite the old cached master, creating a memory leak.
2019-11-19 17:28:59 +01:00
Guy Benoish 69b1b5be6b Fix usage of server.stream_node_max_* 2019-11-19 17:27:57 +01:00
喜欢兰花山丘 1fd97ee7f1 Update mkreleasehdr.sh
fix date +%s errata
2019-11-19 17:26:14 +01:00
antirez 1a9855d7d9 Remove additional space from comment. 2019-11-19 17:25:56 +01:00
antirez 32a6e3e48e Fix stream test after addition of 0-0 ID test. 2019-11-19 17:25:42 +01:00
Yuan Zhou c9e6cda9e8 aof: fix assignment for aof_fsync_offset
Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
2019-11-19 17:25:18 +01:00
antirez d3eeacf93d Merge branch '5.0' of github.com:/antirez/redis into 5.0 2019-11-19 17:24:30 +01:00
antirez da5dc4583f Rename var to fixed_time_expire now that is more general. 2019-11-19 17:24:06 +01:00
antirez 0fefed25e4 Fix patch provided in #6554. 2019-11-19 17:22:39 +01:00
zhaozhao.zz e9fbc96033 expires & blocking: handle ready keys as call() 2019-11-19 17:22:21 +01:00
Guy Benoish 08ec8f71ca XADD with ID 0-0 stores an empty key
Calling XADD with 0-0 or 0 would result in creating an
empty key and storing it in the database.
Even worse, because XADD will reply with error the action
will not be replicated, creating a master-replica
inconsistency
2019-11-19 17:21:08 +01:00
Loris Cro 09e1fe274d fix unreported overflow in autogerenared stream IDs 2019-11-19 17:20:45 +01:00
Salvatore Sanfilippo 09f9e4b030 Merge pull request #6600 from oranagra/5_module_flags
module documentation mismatches: loading and fork child for 5.0 branch
2019-11-19 17:19:12 +01:00
Oran Agra 8d8d68ddf3 module documentation mismatches: loading and fork child for 5.0 branch
loading flag was missing from docs, and fork chidl indicator was removed from
the code but left int he doc and header, re-adding it to the doc together with
the missing function that was needed for it to work.
2019-11-19 17:59:29 +02:00
antirez 7a7fbe708a Modules: RM_GetContextFlags(): remove non Redis 5 features. 2019-11-14 17:50:39 +01:00
antirez b5830486ca Modules: fix moduleCreateArgvFromUserFormat() casting bug.
In 32 bit systems casting to "long" will cut the result to 32 bit.
2019-11-14 17:48:59 +01:00
antirez b7a2a53a8c module: fix propagation API bug. 2019-11-14 17:48:51 +01:00
antirez 278bd6e3b6 Modules: add new flags to context, replica state + more. 2019-11-14 17:47:21 +01:00
antirez 61d9a1542a Modules: RM_Call(): give pointer to documentation. 2019-11-14 17:46:31 +01:00
antirez 0e7ea0aaa3 Modules: RM_Call/Replicate() ability to exclude AOF/replicas. 2019-11-14 17:46:25 +01:00
antirez 3b38164e8f Modules: RM_Replicate() in thread safe contexts. 2019-11-14 17:44:37 +01:00
antirez ef9fe9b0cb Modules: implement RM_Replicate() from async callbacks. 2019-11-14 17:44:29 +01:00
antirez 8066d2a197 Modules: handle propagation when ctx is freed. Flag modules commands ctx. 2019-11-14 17:44:26 +01:00
antirez d3f4dec440 Update PR #6537: use a fresh time outside call().
One problem with the solution proposed so far in #6537 is that key
lookups outside a command execution via call(), still used a cached
time. The cached time needed to be refreshed in multiple places,
especially because of modules callbacks from timers, cluster bus, and
thread safe contexts, that may use RM_Open().

In order to avoid this problem, this commit introduces the ability to
detect if we are inside call(): this way we can use the reference fixed
time only when we are in the context of a command execution or Lua
script, but for the asynchronous lookups, we can still use mstime() to
get a fresh time reference.
2019-11-06 17:31:52 +01:00
antirez 33f42665a8 Update PR #6537 patch to for generality.
After the thread in #6537 and thanks to the suggestions received, this
commit updates the original patch in order to:

1. Solve the problem of updating the time in multiple places by updating
it in call().
2. Avoid introducing a new field but use our cached time.

This required some minor refactoring to the function updating the time,
and the introduction of a new cached time in microseconds in order to
use less gettimeofday() calls.
2019-11-06 17:30:57 +01:00
zhaozhao.zz 68d71d8370 expires: refactoring judgment about whether a key is expired
Calling lookupKey*() many times to search a key in one command
may get different result.

That's because lookupKey*() calls expireIfNeeded(), and delete
the key when reach the expire time. So we can get an robj before
the expire time, but a NULL after the expire time.

The worst is that may lead to Redis crash, for example
`RPOPLPUSH foo foo` the first time we get a list form `foo` and
hold the pointer, but when we get `foo` again it's expired and
deleted. Now we hold a freed memory, when execute rpoplpushHandlePush()
redis crash.

To fix it, we can refactor the judgment about whether a key is expired,
using the same basetime `server.cmd_start_mstime` instead of calling
mstime() everytime.
2019-11-06 17:27:50 +01:00
antirez 62588dbfa7 Modules: fix thread safe context creation crash.
See #6525, this likely creates a NULL deference if the client was
terminated by Redis between the creation of the blocked client and the
creation of the thread safe context.
2019-10-31 18:09:06 +01:00
antirez bb78454b0f Redis 5.0.6. 5.0.6 2019-09-25 12:40:18 +02:00
antirez 7a41047a61 RDB: fix MODULE_AUX loading by continuing to next opcode.
Thanks to @JohnSully for noticing this problem.
2019-09-25 12:32:49 +02:00
Oran Agra 4eb3028bc6 missing per-skiplist overheads in MEMORY USAGE
these had severe impact for small zsets, for instance ones with just one
element that is longer than 64 (causing it not to be ziplist encoded)
2019-09-25 11:52:24 +02:00
Oran Agra 5d09f9bc8e RM_Log - add support for logging without a context or context without module
for instance detached thread safe contexts, or various callbacks that don't
provide a context.
2019-09-25 11:51:08 +02:00
antirez 2810de9fc1 Cluster: abort loading nodes data if vars arguments are unbalanced.
See for reference PR #6337. Thanks to @git-hulk for spotting this.
2019-09-25 11:50:30 +02:00
antirez f5c63ce0ae More strict checks and better comments in flushSlaveOutputBuffers().
Related to #6296.
2019-09-25 11:50:17 +02:00
antirez 7f289c3b92 Improve comment in flushSlavesOutputBuffers(). 2019-09-25 11:50:07 +02:00
antirez 7ab62d4b92 Replication: clarify why repl_put_online_on_ack exists at all. 2019-09-25 11:49:28 +02:00
zhaozhao.zz 495dd0da54 networking: flushSlavesOutputBuffers bugfix 2019-09-25 11:49:12 +02:00
Salvatore Sanfilippo c1ccf0f188 Merge pull request #6366 from oranagra/5.0_rm_reply_cstring
RM_ReplyWithCString was missing registration
2019-09-05 13:31:26 +02:00
Salvatore Sanfilippo a50dad73c2 Merge pull request #6365 from oranagra/5.0_module_aux
backport module rdb aux data into 5.0
2019-09-05 13:31:10 +02:00
Oran Agra d6294d05cd RM_ReplyWithCString was missing registration
(cherry picked from commit 0a97149dec)
2019-09-05 14:26:32 +03:00
Oran Agra 8c56fc864b Fix to module aux data rdb format for backwards compatibility with old check-rdb
When implementing the code that saves and loads these aux fields we used rdb
format that was added for that in redis 5.0, but then we added the 'when' field
which meant that the old redis-check-rdb won't be able to skip these.
this fix adds an opcode as if that 'when' is part of the module data.

(cherry picked from commit 3bfcae247a)
2019-09-05 14:22:07 +03:00
Oran Agra 98b1314f07 Implement module api for aux data in rdb
Other changes:
* fix memory leak in error handling of rdb loading of type OBJ_MODULE

(cherry picked from commit 3b6aeea44c)
2019-09-05 14:20:30 +03:00
antirez 08b03e2322 redis-cli: always report server errors on read errors.
Before this commit we may have not consumer buffers when a read error is
encountered. Such buffers may contain errors that are important clues
for the user: for instance a protocol error in the payload we send in
pipe mode will cause the server to abort the connection. If the user
does not get the protocol error, debugging what is happening can be a
nightmare.

This commit fixes issue #3756.
2019-09-04 17:57:39 +02:00
wubostc 239069dec7 Reduce the calling stack 2019-07-31 18:57:42 +02:00
antirez 90bf631345 Make EMBSTR case of #6261 more obvious. 2019-07-31 18:57:35 +02:00