-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support multi-exec #352
support multi-exec #352
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one comment.
src/commands/cmd_query.c
Outdated
GraphContext *gc = GraphContext_Retrieve(ctx, qctx->graphName); | ||
RedisModule_ThreadSafeContextUnlock(ctx); | ||
|
||
CommandCtx_ThreadSafeContextUnlock(qctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theadeSafeCtx should be released only after the 'if(!gc)' block to prevent edge case of two writers that create a new graph simultaneously and one of them failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
context->argc = argc; | ||
|
||
// Make a copy of graph name. | ||
if(graphName) context->graphName = rm_strdup(RedisModule_StringPtrLen(graphName, NULL)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set context->graphName
to NULL if not provided.
src/commands/cmd_context.c
Outdated
} | ||
|
||
if(qctx->ast) AST_Free(qctx->ast); | ||
rm_free(qctx->graphName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safer to have an if condition on this free.
src/commands/cmd_context.c
Outdated
// Either we already have a context or block client is set. | ||
if(qctx->ctx) return qctx->ctx; | ||
|
||
assert(!qctx->ctx && qctx->bc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left-hand condition unnecessary.
src/commands/cmd_query.c
Outdated
|
||
// Replicate only if query has potential to modify key space. | ||
bool readonly = AST_ReadOnly(ast); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid read if we attached an AST to the QueryContext, since ast
is freed by now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution! A few minor notes, but everything looks good to me.
* support multi-exec * deal with multiple concurrent writers, when graph does not exists
#333
MULTI
GRAPH.QUERY G QUERY
GRAPH.QUERY G QUERY
GRAPH.QUERY G QUERY
EXEC