Skip to content

Commit

Permalink
better validation of rmr command formatting, and better logging of ti…
Browse files Browse the repository at this point in the history
…meouts in rmr
  • Loading branch information
dvirsky committed Dec 10, 2017
1 parent 5fab027 commit 0a64918
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/dep/rmr/rmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static void freePrivDataCB(void *p) {

static int timeoutHandler(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
// concurrentRequests_g--;
fprintf(stderr, "Timeout!\n");
RedisModule_Log(ctx, "notice", "Timed out coordination request");
return RedisModule_ReplyWithError(ctx, "Timeout calling command");
}

Expand Down Expand Up @@ -288,7 +288,6 @@ static void uvFanoutRequest(struct MRRequestCtx *mc) {
}

static void uvMapRequest(struct MRRequestCtx *mc) {

MRCtx *mrctx = mc->ctx;
mrctx->numReplied = 0;
mrctx->reducer = mc->f;
Expand Down Expand Up @@ -353,6 +352,7 @@ int MR_Map(struct MRCtx *ctx, MRReduceFunc reducer, MRCommandGenerator cmds) {

rc->cb = uvMapRequest;
RQ_Push(&rq_g, rc);

return REDIS_OK;
}

Expand Down
2 changes: 1 addition & 1 deletion src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ int searchResultReducer(struct MRCtx *mc, int count, MRReply **replies) {

// got no replies - this means timeout
if (count == 0 || req->limit < 0) {
return RedisModule_ReplyWithError(ctx, "Could not send query to cluter");
return RedisModule_ReplyWithError(ctx, "Could not send query to cluster");
}

long long total = 0;
Expand Down
5 changes: 4 additions & 1 deletion src/search_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SearchCluster NewSearchCluster(size_t size, const char **table, size_t tableSize

int SearchCluster_RewriteCommandArg(SearchCluster *sc, MRCommand *cmd, int partitionKey, int arg) {

if (arg < 0) {
if (arg < 0 || arg >= cmd->num || partitionKey >= cmd->num) {
return 0;
}

Expand All @@ -33,6 +33,9 @@ int SearchCluster_RewriteCommand(SearchCluster *sc, MRCommand *cmd, int partitio

int sk = -1;
if ((sk = MRCommand_GetShardingKey(cmd)) >= 0) {
if (partitionKey >= cmd->num || sk >= cmd->num) {
return 0;
}
// the partition arg is the arg which we select the partition on
char *partitionArg = cmd->args[partitionKey];
// the sharding arg is the arg that we will add the partition tag to
Expand Down

0 comments on commit 0a64918

Please sign in to comment.