chore: improve compatibility of EXPIRE functions with Redis (#2696)

* chore: improve compatibility of EXPIRE functions with Redis

Also, provide a module name if stumbled upon module data that can not be loaded
by dragonfly.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-03-12 13:50:08 +02:00 committed by GitHub
parent 4a9f816106
commit d709f2a911
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 60 additions and 20 deletions

View file

@ -203,6 +203,25 @@ int ziplistPairsConvertAndValidateIntegrity(const uint8_t* zl, size_t size, unsi
return ret;
}
string ModuleTypeName(uint64_t module_id) {
static const char ModuleNameSet[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789-_";
char name[10];
name[9] = '\0';
char* p = name + 8;
module_id >>= 10;
for (int j = 0; j < 9; j++) {
*p-- = ModuleNameSet[module_id & 63];
module_id >>= 6;
}
return string{name};
}
} // namespace
class DecompressImpl {
@ -1978,7 +1997,11 @@ error_code RdbLoader::Load(io::Source* src) {
}
if (type == RDB_OPCODE_MODULE_AUX) {
LOG(ERROR) << "Modules are not supported";
uint64_t module_id;
SET_OR_RETURN(LoadLen(nullptr), module_id);
string module_name = ModuleTypeName(module_id);
LOG(ERROR) << "Modules are not supported, error loading module " << module_name;
return RdbError(errc::feature_not_supported);
}