From ef0c2a926899e91e1ea0503ede5dc2e747079db3 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 1 May 2020 18:45:51 +0200 Subject: [PATCH 1/4] Save a call to stopThreadedIOIfNeeded() for the base case. Probably no performance changes, but the code should be trivial to read as in "No threading? Use the normal function and return". --- src/networking.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/networking.c b/src/networking.c index 767206ab9..d4c0306c3 100644 --- a/src/networking.c +++ b/src/networking.c @@ -2997,9 +2997,9 @@ int handleClientsWithPendingWritesUsingThreads(void) { int processed = listLength(server.clients_pending_write); if (processed == 0) return 0; /* Return ASAP if there are no clients. */ - /* If we have just a few clients to serve, don't use I/O threads, but the - * boring synchronous code. */ - if (stopThreadedIOIfNeeded()) { + /* If I/O threads are disabled or we have few clients to serve, don't + * use I/O threads, but thejboring synchronous code. */ + if (server.io_threads_num == 1 || stopThreadedIOIfNeeded()) { return handleClientsWithPendingWrites(); } From 410e48ffb46b53f707d9134c8316ed4274ebe0cb Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 1 May 2020 23:57:11 +0200 Subject: [PATCH 2/4] Revert "optimize memory usage of deferred replies" This reverts commit 4ed5b7cb74caf5bef6606909603e371af0da4f9b. --- src/networking.c | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/src/networking.c b/src/networking.c index d4c0306c3..c4a277e0a 100644 --- a/src/networking.c +++ b/src/networking.c @@ -436,36 +436,6 @@ void addReplyStatusFormat(client *c, const char *fmt, ...) { sdsfree(s); } -/* Sometimes we are forced to create a new reply node, and we can't append to - * the previous one, when that happens, we wanna try to trim the unused space - * at the end of the last reply node which we won't use anymore. */ -void trimReplyUnusedTailSpace(client *c) { - listNode *ln = listLast(c->reply); - clientReplyBlock *tail = ln? listNodeValue(ln): NULL; - - /* Note that 'tail' may be NULL even if we have a tail node, becuase when - * addDeferredMultiBulkLength() is used */ - if (!tail) return; - - /* We only try to trim the space is relatively high (more than a 1/4 of the - * allocation), otherwise there's a high chance realloc will NOP. - * Also, to avoid large memmove which happens as part of realloc, we only do - * that if the used part is small. */ - if (tail->size - tail->used > tail->size / 4 && - tail->used < PROTO_REPLY_CHUNK_BYTES) - { - size_t old_size = tail->size; - tail = zrealloc(tail, tail->used + sizeof(clientReplyBlock)); - /* If realloc was a NOP, we got the same value which has internal frag */ - if (tail == listNodeValue(ln)) return; - /* take over the allocation's internal fragmentation (at least for - * memory usage tracking) */ - tail->size = zmalloc_usable(tail) - sizeof(clientReplyBlock); - c->reply_bytes += tail->size - old_size; - listNodeValue(ln) = tail; - } -} - /* Adds an empty object to the reply list that will contain the multi bulk * length, which is not known when this function is called. */ void *addReplyDeferredLen(client *c) { @@ -473,7 +443,6 @@ void *addReplyDeferredLen(client *c) { * ready to be sent, since we are sure that before returning to the * event loop setDeferredAggregateLen() will be called. */ if (prepareClientToWrite(c) != C_OK) return NULL; - trimReplyUnusedTailSpace(c); listAddNodeTail(c->reply,NULL); /* NULL is our placeholder. */ return listLast(c->reply); } From 1812dc1644d537b6f8bd77ed42e6cc9c52240af1 Mon Sep 17 00:00:00 2001 From: antirez Date: Sat, 2 May 2020 00:02:18 +0200 Subject: [PATCH 3/4] Cast printf() argument to the format specifier. We could use uint64_t specific macros, but after all it's simpler to just use an obvious equivalent type plus casting: this will be a no op and is simpler than fixed size types printf macros. --- src/rdb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rdb.c b/src/rdb.c index 9f6bf13f1..4fc385848 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -2292,7 +2292,9 @@ int rdbLoadRio(rio *rdb, int rdbflags, rdbSaveInfo *rsi) { serverLog(LL_WARNING,"RDB file was saved with checksum disabled: no check performed."); } else if (cksum != expected) { serverLog(LL_WARNING,"Wrong RDB checksum expected: (%llx) but " - "got (%llx). Aborting now.",expected,cksum); + "got (%llx). Aborting now.", + (unsigned long long)expected, + (unsigned long long)cksum); rdbExitReportCorruptRDB("RDB CRC error"); } } From d36292e2b85c06f87540c15957bbb28c43fffa93 Mon Sep 17 00:00:00 2001 From: antirez Date: Sat, 2 May 2020 00:10:20 +0200 Subject: [PATCH 4/4] Redis 6.0.1. --- 00-RELEASENOTES | 28 ++++++++++++++++++++++++++++ src/version.h | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/00-RELEASENOTES b/00-RELEASENOTES index 2b67732a1..1d5486ae8 100644 --- a/00-RELEASENOTES +++ b/00-RELEASENOTES @@ -11,6 +11,34 @@ CRITICAL: There is a critical bug affecting MOST USERS. Upgrade ASAP. SECURITY: There are security fixes in the release. -------------------------------------------------------------------------------- +================================================================================ +Redis 6.0.1 Released Sat May 02 00:06:07 CEST 2020 +================================================================================ + +Upgrade urgency HIGH: This release fixes a crash when builiding against + Libc malloc. + +Here we revert 8110ba888, an optimization that causes a crash due to a +bug in the code. It does not happen with the default allocator because of +differences between Jemalloc and libc malloc, so this escaped all our +testing but was reported by a user. We'll add back the original optimization +that was reverted here later, after checking what happens: it is not a +critical optimization. + +The other commits are minor stuff: + +antirez in commit db73d0998: + Cast printf() argument to the format specifier. + 1 file changed, 3 insertions(+), 1 deletion(-) + +antirez in commit 7c0fe7271: + Revert "optimize memory usage of deferred replies" + 1 file changed, 31 deletions(-) + +antirez in commit 8fe25edc7: + Save a call to stopThreadedIOIfNeeded() for the base case. + 1 file changed, 3 insertions(+), 3 deletions(-) + ================================================================================ Redis 6.0.0 GA Released Thu Apr 30 14:55:02 CEST 2020 ================================================================================ diff --git a/src/version.h b/src/version.h index 8236702db..91d3566d3 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define REDIS_VERSION "6.0.0" +#define REDIS_VERSION "6.0.1"