Skip to content

Update Fork #6181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
86f95d9
Fix SCAN bug regression test, avoiding empty SREM call.
antirez Jun 14, 2018
80ee609
config: handle special configuration "" for auth
soloestoy Jan 26, 2018
7012d40
rdb: incremental fsync when redis saves rdb
soloestoy Mar 15, 2018
8073575
add rdb-save-incremental-fsync option in redis.conf
soloestoy Mar 15, 2018
723f69b
Fix DEBUG LOADAOF so that redis-server will not crash unexpectedly
trevor211 Jun 2, 2018
ad3b528
Fix core dump when using 'command getkeys' with wrong arguments.
Apr 20, 2018
54da85c
Update geohash.c
zwkno1 Jun 12, 2018
237a387
optimize reply list memory usage
soloestoy Jun 13, 2018
663ba81
Fix config_set_numerical_field() integer overflow.
shenlongxing Jun 13, 2018
8a5f10a
fix exists command on slave
soloestoy Jun 13, 2018
46204ef
Fix infinite loop in dbRandomKey().
antirez Jun 14, 2018
31264ff
Sentinel: add an option to deny online script reconfiguration.
antirez Jun 14, 2018
2faa6c6
XADD MAXLEN should return an error for values < 0.
antirez Jun 17, 2018
2d5d904
Streams: fix xreadGetKeys() for correctness.
antirez Jun 18, 2018
471f941
Fix update_zmalloc_stat_alloc in zrealloc
FX-HAO Jun 14, 2018
2651a0a
Update sort.c
tigertv Jun 17, 2018
407562f
Streams: Change XADD MAXLEN handling of values <= 0.
antirez Jun 18, 2018
e3ac4ed
Streams: fix xreadGetKeys() buffer overflow.
antirez Jun 18, 2018
e03296d
Refactor createObjectFromLongLong() to be suitable for value objects.
antirez Jun 18, 2018
1c802ae
Fix incrDecrCommand() to create shared objects when needed.
antirez Jun 18, 2018
209a5fd
Revert fix #4976 just leaving the flush() part.
antirez Jun 18, 2018
5b6c2c1
Update README.md
bepahol Jun 19, 2018
12e21af
Remove AOF optimization to skip expired keys.
antirez Jun 19, 2018
6ad1191
64 bit RDB_OPCODE_RESIZEDB in rdb saving
oranagra Jun 19, 2018
553d609
use safe macro (non empty) in memrev64ifbe to eliminate empty if warning
oranagra Jun 19, 2018
9bb2295
Modify clusterRedirectClient() to handle ZPOP and XREAD.
antirez Jun 19, 2018
81ed550
AOF: remove no longer used variable "now".
antirez Jun 19, 2018
01d1f74
fix redis-rdb-check to provide proper arguments to rdbLoadMillisecond…
oranagra Jun 19, 2018
612184a
Modules: convert hash to hash table for big objects.
antirez Jun 19, 2018
bac6656
Test RDB stream encoding saving/loading.
antirez Jun 19, 2018
52691d7
add malloc_usable_size for libc malloc
oranagra Jun 19, 2018
dec86bf
Enhance RESTORE with RDBv9 new features
guybe7 Jun 20, 2018
fa73014
Fix rdbLoadIntegerObject() to create shared objects when needed.
youjiali1995 Jun 21, 2018
f4b057e
fix streams memory estimation, missing raxSeek
oranagra Jun 21, 2018
06fd717
Update ZPOPMIN/ZPOPMAX command declaration
michael-grunder Jun 21, 2018
ed0dc48
Fix compiler warning in restoreCommand
guybe7 Jun 24, 2018
1a2c684
Sentinel command renaming: config rewriting.
antirez Jun 25, 2018
f9e4294
Sentinel: make SENTINEL SET able to handle different arities.
antirez Jun 25, 2018
82319bc
Sentinel command renaming: fix CONFIG SET after refactoring.
antirez Jun 25, 2018
2240070
Sentinel command renaming: base machanism implemented.
antirez Jun 25, 2018
1c73cd5
Sentinel command renaming: rename-command option parsing.
antirez Jun 25, 2018
9933bcd
Sentinel command renaming: implement SENTINEL SET.
antirez Jun 25, 2018
e1f1434
Sentinel command renaming: fix CONFIG SET event logging.
antirez Jun 25, 2018
719c51b
Sentinel command renaming: use case sensitive hashing for the dict.
antirez Jun 25, 2018
2a94d75
Sentinel command renaming: document it into sentinel.conf.
antirez Jun 25, 2018
7ca02f6
Sentinel: drop the renamed-command entry in a more natural way.
antirez Jun 25, 2018
1acb88a
Fixed replication authentication with whitespace in password
madolson Jun 19, 2018
13313ce
Addressed comments
madolson Jun 26, 2018
9909744
Sentinel: fix SENTINEL SET error reporting.
antirez Jun 26, 2018
bb7f32d
Remove black space.
antirez Jun 26, 2018
e0fb170
Fix type of argslen in sendSynchronousCommand().
antirez Jun 26, 2018
5cf38c1
Sentinel: test command renaming feature.
antirez Jun 26, 2018
08aad64
test suite infra improvements and fix
oranagra Jun 26, 2018
ce2b687
add defrag hint support into jemalloc 5
oranagra Jun 26, 2018
eb8a2f2
add active defrag support for streams
oranagra Jun 26, 2018
51ceba8
CLIENT ID implemented.
antirez Jun 27, 2018
5449c97
Update t_stream.c
Jun 27, 2018
d32466a
CLIENT UNBLOCK: support unblocking by error.
antirez Jun 27, 2018
9c2d307
Add unblock in CLIENT HELP.
antirez Jun 27, 2018
b70a81e
Make CLIENT HELP output nicer to the eyes.
antirez Jun 27, 2018
743e4dc
Take clients in a ID -> Client handle dictionary.
antirez Jun 27, 2018
5b3d6cb
CLIENT UNBLOCK implemented.
antirez Jun 27, 2018
4491e36
minor fix in creating a stream NACK for rdb and defrag tests
oranagra Jun 27, 2018
f3b6b1e
Update help.h
Jun 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ top comment inside `server.c`.
After the command operates in some way, it returns a reply to the client,
usually using `addReply()` or a similar function defined inside `networking.c`.

There are tons of commands implementations inside th Redis source code
There are tons of commands implementations inside the Redis source code
that can serve as examples of actual commands implementations. To write
a few toy commands can be a good exercise to familiarize with the code base.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,32 @@ ixalloc(tsdn_t *tsdn, void *ptr, size_t oldsize, size_t size, size_t extra,
return arena_ralloc_no_move(tsdn, ptr, oldsize, size, extra, zero);
}

JEMALLOC_ALWAYS_INLINE int
iget_defrag_hint(tsdn_t *tsdn, void* ptr, int *bin_util, int *run_util) {
int defrag = 0;
rtree_ctx_t rtree_ctx_fallback;
rtree_ctx_t *rtree_ctx = tsdn_rtree_ctx(tsdn, &rtree_ctx_fallback);
szind_t szind;
bool is_slab;
rtree_szind_slab_read(tsdn, &extents_rtree, rtree_ctx, (uintptr_t)ptr, true, &szind, &is_slab);
if (likely(is_slab)) {
/* Small allocation. */
extent_t *slab = iealloc(tsdn, ptr);
arena_t *arena = extent_arena_get(slab);
szind_t binind = extent_szind_get(slab);
bin_t *bin = &arena->bins[binind];
malloc_mutex_lock(tsdn, &bin->lock);
/* don't bother moving allocations from the slab currently used for new allocations */
if (slab != bin->slabcur) {
const bin_info_t *bin_info = &bin_infos[binind];
size_t availregs = bin_info->nregs * bin->stats.curslabs;
*bin_util = (bin->stats.curregs<<16) / availregs;
*run_util = ((bin_info->nregs - extent_nfree_get(slab))<<16) / bin_info->nregs;
defrag = 1;
}
malloc_mutex_unlock(tsdn, &bin->lock);
}
return defrag;
}

#endif /* JEMALLOC_INTERNAL_INLINES_C_H */
4 changes: 4 additions & 0 deletions deps/jemalloc/include/jemalloc/jemalloc_macros.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,7 @@
# define JEMALLOC_RESTRICT_RETURN
# define JEMALLOC_ALLOCATOR
#endif

/* This version of Jemalloc, modified for Redis, has the je_get_defrag_hint()
* function. */
#define JEMALLOC_FRAG_HINT
11 changes: 11 additions & 0 deletions deps/jemalloc/src/jemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3324,3 +3324,14 @@ jemalloc_postfork_child(void) {
}

/******************************************************************************/

/* Helps the application decide if a pointer is worth re-allocating in order to reduce fragmentation.
* returns 0 if the allocation is in the currently active run,
* or when it is not causing any frag issue (large or huge bin)
* returns the bin utilization and run utilization both in fixed point 16:16.
* If the application decides to re-allocate it should use MALLOCX_TCACHE_NONE when doing so. */
JEMALLOC_EXPORT int JEMALLOC_NOTHROW
get_defrag_hint(void* ptr, int *bin_util, int *run_util) {
assert(ptr != NULL);
return iget_defrag_hint(TSDN_NULL, ptr, bin_util, run_util);
}
6 changes: 6 additions & 0 deletions redis.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,12 @@ hz 10
# big latency spikes.
aof-rewrite-incremental-fsync yes

# When redis saves RDB file, if the following option is enabled
# the file will be fsync-ed every 32 MB of data generated. This is useful
# in order to commit the file to the disk more incrementally and avoid
# big latency spikes.
rdb-save-incremental-fsync yes

# Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good
# idea to start with the default settings and only change them after investigating
# how to improve the performances and how the keys LFU change over time, which
Expand Down
28 changes: 28 additions & 0 deletions sentinel.conf
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,31 @@ sentinel failover-timeout mymaster 180000
#
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh

# SECURITY
#
# By default SENTINEL SET will not be able to change the notification-script
# and client-reconfig-script at runtime. This avoids a trivial security issue
# where clients can set the script to anything and trigger a failover in order
# to get the program executed.

sentinel deny-scripts-reconfig yes

# REDIS COMMANDS RENAMING
#
# Sometimes the Redis server has certain commands, that are needed for Sentinel
# to work correctly, renamed to unguessable strings. This is often the case
# of CONFIG and SLAVEOF in the context of providers that provide Redis as
# a service, and don't want the customers to reconfigure the instances outside
# of the administration console.
#
# In such case it is possible to tell Sentinel to use different command names
# instead of the normal ones. For example if the master "mymaster", and the
# associated slaves, have "CONFIG" all renamed to "GUESSME", I could use:
#
# sentinel rename-command mymaster CONFIG GUESSME
#
# After such configuration is set, every time Sentinel would use CONFIG it will
# use GUESSME instead. Note that there is no actual need to respect the command
# case, so writing "config guessme" is the same in the example above.
#
# SENTINEL SET can also be used in order to perform this configuration at runtime.
14 changes: 5 additions & 9 deletions src/aof.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static void killAppendOnlyChild(void) {
void stopAppendOnly(void) {
serverAssert(server.aof_state != AOF_OFF);
flushAppendOnlyFile(1);
aof_fsync(server.aof_fd);
redis_fsync(server.aof_fd);
close(server.aof_fd);

server.aof_fd = -1;
Expand Down Expand Up @@ -476,10 +476,10 @@ void flushAppendOnlyFile(int force) {

/* Perform the fsync if needed. */
if (server.aof_fsync == AOF_FSYNC_ALWAYS) {
/* aof_fsync is defined as fdatasync() for Linux in order to avoid
/* redis_fsync is defined as fdatasync() for Linux in order to avoid
* flushing metadata. */
latencyStartMonitor(latency);
aof_fsync(server.aof_fd); /* Let's try to get this data on the disk */
redis_fsync(server.aof_fd); /* Let's try to get this data on the disk */
latencyEndMonitor(latency);
latencyAddSampleIfNeeded("aof-fsync-always",latency);
server.aof_last_fsync = server.unixtime;
Expand Down Expand Up @@ -1221,7 +1221,6 @@ int rewriteAppendOnlyFileRio(rio *aof) {
dictIterator *di = NULL;
dictEntry *de;
size_t processed = 0;
long long now = mstime();
int j;

for (j = 0; j < server.dbnum; j++) {
Expand All @@ -1247,9 +1246,6 @@ int rewriteAppendOnlyFileRio(rio *aof) {

expiretime = getExpire(db,&key);

/* If this key is already expired skip it */
if (expiretime != -1 && expiretime < now) continue;

/* Save the key and associated value */
if (o->type == OBJ_STRING) {
/* Emit a SET command */
Expand Down Expand Up @@ -1322,7 +1318,7 @@ int rewriteAppendOnlyFile(char *filename) {
rioInitWithFile(&aof,fp);

if (server.aof_rewrite_incremental_fsync)
rioSetAutoSync(&aof,AOF_AUTOSYNC_BYTES);
rioSetAutoSync(&aof,REDIS_AUTOSYNC_BYTES);

if (server.aof_use_rdb_preamble) {
int error;
Expand Down Expand Up @@ -1690,7 +1686,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
oldfd = server.aof_fd;
server.aof_fd = newfd;
if (server.aof_fsync == AOF_FSYNC_ALWAYS)
aof_fsync(newfd);
redis_fsync(newfd);
else if (server.aof_fsync == AOF_FSYNC_EVERYSEC)
aof_background_fsync(newfd);
server.aof_selected_db = -1; /* Make sure SELECT is re-issued */
Expand Down
2 changes: 1 addition & 1 deletion src/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void *bioProcessBackgroundJobs(void *arg) {
if (type == BIO_CLOSE_FILE) {
close((long)job->arg1);
} else if (type == BIO_AOF_FSYNC) {
aof_fsync((long)job->arg1);
redis_fsync((long)job->arg1);
} else if (type == BIO_LAZY_FREE) {
/* What we free changes depending on what arguments are set:
* arg1 -> free the object at pointer.
Expand Down
40 changes: 36 additions & 4 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -4835,15 +4835,39 @@ void dumpCommand(client *c) {

/* RESTORE key ttl serialized-value [REPLACE] */
void restoreCommand(client *c) {
long long ttl;
long long ttl, lfu_freq = -1, lru_idle = -1, lru_clock = -1;
rio payload;
int j, type, replace = 0;
int j, type, replace = 0, absttl = 0;
robj *obj;

/* Parse additional options */
for (j = 4; j < c->argc; j++) {
int additional = c->argc-j-1;
if (!strcasecmp(c->argv[j]->ptr,"replace")) {
replace = 1;
} else if (!strcasecmp(c->argv[j]->ptr,"absttl")) {
absttl = 1;
} else if (!strcasecmp(c->argv[j]->ptr,"idletime") && additional >= 1 &&
lfu_freq == -1)
{
if (getLongLongFromObjectOrReply(c,c->argv[j+1],&lru_idle,NULL)
!= C_OK) return;
if (lru_idle < 0) {
addReplyError(c,"Invalid IDLETIME value, must be >= 0");
return;
}
lru_clock = LRU_CLOCK();
j++; /* Consume additional arg. */
} else if (!strcasecmp(c->argv[j]->ptr,"freq") && additional >= 1 &&
lru_idle == -1)
{
if (getLongLongFromObjectOrReply(c,c->argv[j+1],&lfu_freq,NULL)
!= C_OK) return;
if (lfu_freq < 0 || lfu_freq > 255) {
addReplyError(c,"Invalid FREQ value, must be >= 0 and <= 255");
return;
}
j++; /* Consume additional arg. */
} else {
addReply(c,shared.syntaxerr);
return;
Expand Down Expand Up @@ -4884,7 +4908,11 @@ void restoreCommand(client *c) {

/* Create the key and set the TTL if any */
dbAdd(c->db,c->argv[1],obj);
if (ttl) setExpire(c,c->db,c->argv[1],mstime()+ttl);
if (ttl) {
if (!absttl) ttl+=mstime();
setExpire(c,c->db,c->argv[1],ttl);
}
objectSetLRUOrLFU(obj,lfu_freq,lru_idle,lru_clock);
signalModifiedKey(c->db,c->argv[1]);
addReply(c,shared.ok);
server.dirty++;
Expand Down Expand Up @@ -5589,7 +5617,11 @@ void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_co
* longer handles, the client is sent a redirection error, and the function
* returns 1. Otherwise 0 is returned and no operation is performed. */
int clusterRedirectBlockedClientIfNeeded(client *c) {
if (c->flags & CLIENT_BLOCKED && c->btype == BLOCKED_LIST) {
if (c->flags & CLIENT_BLOCKED &&
(c->btype == BLOCKED_LIST ||
c->btype == BLOCKED_ZSET ||
c->btype == BLOCKED_STREAM))
{
dictEntry *de;
dictIterator *di;

Expand Down
Loading