diff --git a/src/facade/dragonfly_connection.cc b/src/facade/dragonfly_connection.cc index 806bf9539..20dcc3c36 100644 --- a/src/facade/dragonfly_connection.cc +++ b/src/facade/dragonfly_connection.cc @@ -332,7 +332,8 @@ void Connection::ConnectionFlow(FiberSocketBase* peer) { // We wait for dispatch_fb to finish writing the previous replies before replying to the last // offending request. if (parse_status == ERROR) { - VLOG(1) << "Error stats " << parse_status; + VLOG(1) << "Error parser status " << parse_status; + if (redis_parser_) { SendProtocolError(RedisParser::Result(parser_error_), peer); } else { diff --git a/src/facade/redis_parser.cc b/src/facade/redis_parser.cc index 4d378ab44..ab22740ad 100644 --- a/src/facade/redis_parser.cc +++ b/src/facade/redis_parser.cc @@ -13,7 +13,7 @@ using namespace std; namespace { -constexpr int kMaxArrayLen = 1024; +constexpr int kMaxArrayLen = 8192; constexpr int64_t kMaxBulkLen = 64 * (1ul << 20); // 64MB. } // namespace @@ -237,8 +237,11 @@ auto RedisParser::ConsumeArrayLen(Buffer str) -> Result { case BAD_INT: return BAD_ARRAYLEN; case OK: - if (len < -1 || len > kMaxArrayLen) + if (len < -1 || len > kMaxArrayLen) { + VLOG_IF(1, len > kMaxArrayLen) << "Milti bulk len is too big " << len; + return BAD_ARRAYLEN; + } break; default: LOG(ERROR) << "Unexpected result " << res; diff --git a/src/redis/listpack.c b/src/redis/listpack.c index a280f4262..238f97d42 100644 --- a/src/redis/listpack.c +++ b/src/redis/listpack.c @@ -1381,7 +1381,8 @@ void lpRandomPair(unsigned char *lp, unsigned long total_count, listpackEntry *k if (!val) return; - assert((p = lpNext(lp, p))); + p = lpNext(lp, p); + assert(p); val->sval = lpGetValue(p, &(val->slen), &(val->lval)); } @@ -1420,7 +1421,8 @@ void lpRandomPairs(unsigned char *lp, unsigned int count, listpackEntry *keys, l p = lpSeek(lp, lpindex); while (p && pickindex < count) { key = lpGetValue(p, &klen, &klval); - assert((p = lpNext(lp, p))); + p = lpNext(lp, p); + assert(p); value = lpGetValue(p, &vlen, &vlval); while (pickindex < count && lpindex == picks[pickindex].index) { int storeorder = picks[pickindex].order; @@ -1463,7 +1465,8 @@ unsigned int lpRandomPairsUnique(unsigned char *lp, unsigned int count, listpack if (randomDouble <= threshold) { key = lpGetValue(p, &klen, &klval); lpSaveValue(key, klen, klval, &keys[picked]); - assert((p = lpNext(lp, p))); + p = lpNext(lp, p); + assert(p); if (vals) { key = lpGetValue(p, &klen, &klval); lpSaveValue(key, klen, klval, &vals[picked]); @@ -1471,7 +1474,8 @@ unsigned int lpRandomPairsUnique(unsigned char *lp, unsigned int count, listpack remaining--; picked++; } else { - assert((p = lpNext(lp, p))); + p = lpNext(lp, p); + assert(p); } p = lpNext(lp, p); index++; diff --git a/src/redis/object.c b/src/redis/object.c index c4f532213..7c0f35821 100644 --- a/src/redis/object.c +++ b/src/redis/object.c @@ -894,7 +894,9 @@ int getIntFromObjectOrReply(client *c, robj *o, int *target, const char *msg) { return C_OK; } -char *strEncoding(int encoding) { +#endif + +const char *strEncoding(int encoding) { switch(encoding) { case OBJ_ENCODING_RAW: return "raw"; case OBJ_ENCODING_INT: return "int"; @@ -910,7 +912,6 @@ char *strEncoding(int encoding) { } } -#endif /* Given an object returns the min number of milliseconds the object was never * requested, using an approximated LRU algorithm. */ diff --git a/src/redis/object.h b/src/redis/object.h index 6880c726c..2af083c56 100644 --- a/src/redis/object.h +++ b/src/redis/object.h @@ -192,7 +192,7 @@ int hashTypeGetFromListpack(robj *o, sds field, unsigned char **vstr, unsigned int *vlen, long long *vll); - +const char *strEncoding(int encoding); /* Macro used to initialize a Redis object allocated on the stack. * Note that this macro is taken near the structure definition to make sure diff --git a/src/redis/quicklist.c b/src/redis/quicklist.c index aa05893fe..03de40220 100644 --- a/src/redis/quicklist.c +++ b/src/redis/quicklist.c @@ -1428,9 +1428,9 @@ quicklistIter *quicklistGetIteratorEntryAtIdx(quicklist *quicklist, const long l { quicklistIter *iter = quicklistGetIteratorAtIdx(quicklist, AL_START_TAIL, idx); if (!iter) return NULL; - assert(quicklistNext(iter, entry)); + quicklistNext(iter, entry); return iter; - } +} static void quicklistRotatePlain(quicklist *quicklist) { quicklistNode *new_head = quicklist->tail; diff --git a/src/server/debugcmd.cc b/src/server/debugcmd.cc index 1b099c241..b4284a622 100644 --- a/src/server/debugcmd.cc +++ b/src/server/debugcmd.cc @@ -25,7 +25,7 @@ using namespace std; using namespace util; namespace this_fiber = ::boost::this_fiber; using boost::fibers::fiber; -using facade::kUintErr; +using namespace facade; namespace fs = std::filesystem; struct PopulateBatch { @@ -60,6 +60,8 @@ void DebugCmd::Run(CmdArgList args) { if (subcmd == "HELP") { std::string_view help_arr[] = { "DEBUG [ [value] [opt] ...]. Subcommands are:", + "OBJECT ", + " Show low-level info about `key` and associated value.", "RELOAD [option ...]", " Save the RDB on disk (TBD) and reload it back to memory. Valid