Skip to content
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

fix(server): fix JSON.MGET implementation (#849) #876

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

iko1
Copy link
Contributor

@iko1 iko1 commented Feb 25, 2023

Fixes #849

@iko1 iko1 force-pushed the fix/json-mget branch 2 times, most recently from a2358bd to 897ace1 Compare February 26, 2023 16:16
@iko1 iko1 marked this pull request as ready for review February 26, 2023 16:16
OpResult<JsonType*> result = GetJson(op_args, it);
if (!result) {
vec.emplace_back();
vector<OptString> OpMGet(JsonExpression& expression, const Transaction* t, EngineShard* shard) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why expression is passed by mutable reference, @iko1 ?
the reason I am asking is if it's been mutated then there is a potential data-race since OpMGet is called in parallel from multiple threads.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so either lets change it to const ref or pass it by value

if (!it) {
(*cntx)->SendNull();
} else {
(*cntx)->SendSimpleString(*it);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to use SendBulkString here

@iko1 iko1 force-pushed the fix/json-mget branch 3 times, most recently from 1f59af3 to 4063db1 Compare March 1, 2023 06:34
OpResult<JsonType*> result = GetJson(op_args, it);
if (!result) {
vec.emplace_back();
vector<OptString> OpMGet(JsonExpression&& expression, const Transaction* t, EngineShard* shard) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not see a good reason to pass JsonExpression&& over JsonExpression

vector<OptString> OpMGet(JsonExpression&& expression, const Transaction* t, EngineShard* shard) {
auto args = t->GetShardArgs(shard->shard_id());
DCHECK(!args.empty());
vector<OptString> respone(args.size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

respone -> responce

@iko1 iko1 requested a review from romange March 1, 2023 06:36
@iko1 iko1 force-pushed the fix/json-mget branch 7 times, most recently from aaddf96 to 387ec7a Compare March 2, 2023 15:32
@romange romange merged commit 04f4362 into dragonflydb:main Mar 2, 2023
@romange
Copy link
Collaborator

romange commented Mar 2, 2023

Thanks, @iko1 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON.MGET not working as intended
2 participants