Skip to content
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ffbdfd2
MOD-13438 Add internal commands to the inner communication protocol
galcohen-redislabs Jan 12, 2026
ca0af6b
Adjust the includes, typedefs and function declarations
galcohen-redislabs Jan 12, 2026
7c45b96
Make MR_ClusterRegisterMsgReceiver() idempotent
galcohen-redislabs Jan 12, 2026
b5154e0
Spelling and other cleanups
galcohen-redislabs Jan 12, 2026
beaa220
Send internal-command messages to current node as well
galcohen-redislabs Jan 13, 2026
425c47c
Added support for parsing responses of internal commands and storing …
galcohen-redislabs Jan 20, 2026
a702c0d
WIP (doesn't compile now) - handling step-done and done notifications…
galcohen-redislabs Jan 22, 2026
aa0980c
Some cleanups. Now compiles but the done-step and done-execution part…
galcohen-redislabs Jan 22, 2026
b2f31de
WTF? How this trivial bug survived for so many years??
galcohen-redislabs Jan 22, 2026
33dd57b
Now we can use the flag properly
galcohen-redislabs Jan 23, 2026
467712e
Mostly cleanups of funcs and structs
galcohen-redislabs Jan 24, 2026
82b1a5e
minor cleanups
galcohen-redislabs Jan 25, 2026
2e70921
Aadded MR_ExecutionCtxSetDone()
galcohen-redislabs Jan 26, 2026
4d8d66d
typo in the rust apis
galcohen-redislabs Feb 3, 2026
ce40d25
Minor log cleanup
galcohen-redislabs Feb 5, 2026
e4248ac
Pin setuptools below 81 in CI
gabsow Feb 9, 2026
8bca138
Added a comment for internal command callbacks registrations
galcohen-redislabs Feb 9, 2026
bdcb9ef
Retry AUTH in cases of a race that cause previous AUTH to fail
galcohen-redislabs Feb 10, 2026
2683edb
Refined the condition for when to retry AUTH
galcohen-redislabs Feb 10, 2026
886d9ab
Ride on the done.callback to avoid race between timeout and done; Als…
galcohen-redislabs Feb 15, 2026
4ca8175
Merge branch 'master' into gal-13438-internal-commands-protocol
galcohen-redislabs Feb 15, 2026
ae91b57
Don't bail out before sending NOTIFY_DONE when I'm not the initiator
galcohen-redislabs Feb 17, 2026
5bbbef5
Testing something
galcohen-redislabs Feb 17, 2026
e8e1bf2
Revert "Testing something"
galcohen-redislabs Feb 18, 2026
c01e0fe
Fix cluster cleanup leaks in TLS and async connect paths.
gabsow Feb 18, 2026
59da050
Free async context from event loop thread to prevent reply leak.
gabsow Feb 18, 2026
6f12012
Merge remote-tracking branch 'origin/master' into tom/fixMemoryLeak
gabsow Feb 18, 2026
3822764
Fix comment: free is deferred within the event loop, not across threads.
gabsow Feb 22, 2026
b3cbd9e
Drain pending messages on node free to prevent execution leaks
gabsow Feb 23, 2026
b957f22
Only drain internal-command pending messages in MR_NodeFree
gabsow Feb 24, 2026
5f847c6
Revert leak fixes per Gal's feedback
gabsow Feb 24, 2026
c34df39
Remove extra blank line in MR_SetInternalCommandResults
gabsow Feb 24, 2026
344ad11
Add MR_ClusterFini to free cluster state on module teardown
gabsow Feb 24, 2026
b8cc5c4
Add MR_Fini API and call it from test module deinit
gabsow Feb 24, 2026
c0888d2
Skip testUnevenWork under Valgrind
gabsow Feb 24, 2026
381e239
Destroy thread pool in MR_Fini, reduce testUnevenWork sleep to 5s
gabsow Feb 24, 2026
14cc832
Revert thpool_destroy and sleep change, skip testUnevenWork under Val…
gabsow Feb 24, 2026
b3a30c5
Fix cluster cleanup leaks in TLS and async connect paths.
gabsow Feb 25, 2026
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
7 changes: 6 additions & 1 deletion rust_api/libmr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
//! This module provides with the Map-Reduce operations supported.

use crate::libmr_c_raw::bindings::{
MRRecordType, MR_CalculateSlot, MR_ClusterIsInClusterMode, MR_Init, MR_IsMySlot, RedisModuleCtx,
MRRecordType, MR_CalculateSlot, MR_ClusterIsInClusterMode, MR_Fini as MR_Fini_C, MR_Init,
MR_IsMySlot, RedisModuleCtx,
};
use redis_module::Context;

Expand Down Expand Up @@ -59,6 +60,10 @@ pub fn mr_init(ctx: &Context, num_threads: usize, password: Option<&str>) {
}
}

pub fn mr_fini() {
unsafe { MR_Fini_C() };
}

pub fn calc_slot(s: &[u8]) -> usize {
unsafe { MR_CalculateSlot(s.as_ptr() as *const c_char, s.len()) }
}
Expand Down
13 changes: 10 additions & 3 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ static int checkTLS(char** client_key, char** client_cert, char** ca_cert, char*
MR_FREE(*client_cert);
}
if (*ca_cert) {
MR_FREE(*client_cert);
MR_FREE(*ca_cert);
Comment thread
gabsow marked this conversation as resolved.
}
}

Expand Down Expand Up @@ -684,8 +684,8 @@ static void MR_ConnectToShard(Node* n){
return;
}
if (c->err) {
/* Let *c leak for now... */
Comment thread
gabsow marked this conversation as resolved.
RedisModule_Log(mr_staticCtx, "warning", "Error: %s\n", c->errstr);
redisAsyncFree(c);
return;
}
c->data = n;
Expand Down Expand Up @@ -747,7 +747,10 @@ static void MR_NodeFree(Node* n){
MR_NodeFreeInternals(n);
}

static void MR_ClusterFree(){
static void MR_ClusterFree(void){
if(!clusterCtx.CurrCluster){
return;
}
if(clusterCtx.CurrCluster->myId){
MR_FREE(clusterCtx.CurrCluster->myId);
}
Expand Down Expand Up @@ -779,6 +782,10 @@ static void MR_ClusterFree(){
memset(clusterCtx.myId, '0', REDISMODULE_NODE_ID_LEN);
}

void MR_ClusterFini(void){
MR_ClusterFree();
}

static Node* MR_GetNode(const char* id){
mr_dictEntry *entry = mr_dictFind(clusterCtx.CurrCluster->nodes, id);
Node* n = NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ size_t MR_ClusterGetSize();

int MR_ClusterInit(RedisModuleCtx* rctx, char *password);

void MR_ClusterFini(void);

size_t MR_ClusterGetSlotByKey(const char* key, size_t len);

int MR_ClusterIsMySlot(size_t slot);
Expand Down
4 changes: 4 additions & 0 deletions src/mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,10 @@ int MR_Init(RedisModuleCtx* ctx, size_t numThreads, char *password) {
return REDISMODULE_OK;
}

LIBMR_API void MR_Fini(void) {
MR_ClusterFini();
}
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated

int MR_RegisterObject(MRObjectType* t) {
mrCtx.objectTypesDict = array_append(mrCtx.objectTypesDict, t);
t->id = array_len(mrCtx.objectTypesDict) - 1;
Expand Down
3 changes: 3 additions & 0 deletions src/mr.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ LIBMR_API void MR_FreeExecution(Execution* e);
/* Initialize mr library */
LIBMR_API int MR_Init(struct RedisModuleCtx* ctx, size_t numThreads, char *password);

/* Teardown mr library (frees cluster state) */
LIBMR_API void MR_Fini(void);

/* Register a new object type */
LIBMR_API int MR_RegisterObject(MRObjectType* t);

Expand Down
8 changes: 7 additions & 1 deletion tests/mr_test_module/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use redis_module::{

use mr::libmr::{
accumulator::AccumulateStep, base_object::BaseObject, calc_slot,
execution_builder::create_builder, filter::FilterStep, mapper::MapStep, mr_init,
execution_builder::create_builder, filter::FilterStep, mapper::MapStep, mr_fini, mr_init,
reader::Reader, record::Record, remote_task::run_on_all_shards, remote_task::run_on_key,
remote_task::RemoteTask, RustMRError,
};
Expand Down Expand Up @@ -867,13 +867,19 @@ fn init_func(ctx: &Context, args: &[RedisString]) -> Status {
Status::Ok
}

fn deinit_func(_ctx: &Context) -> Status {
mr_fini();
Status::Ok
}

#[cfg(not(test))]
redis_module! {
name: "lmrtest",
version: 99_99_99,
allocator: (RedisAlloc, RedisAlloc),
data_types: [],
init: init_func,
deinit: deinit_func,
commands: [
["lmrtest.dbsize", lmr_dbsize, "readonly", 0,0,0, AclCategory::None],
["lmrtest.get", lmr_get, "readonly", 0,0,0, AclCategory::None],
Expand Down
Loading