Skip to content

chore: update jsoncons version to 0.178#4368

Merged
romange merged 1 commit intomainfrom
Pr1
Jan 8, 2025
Merged

chore: update jsoncons version to 0.178#4368
romange merged 1 commit intomainfrom
Pr1

Conversation

@romange
Copy link
Copy Markdown
Collaborator

@romange romange commented Dec 25, 2024

jsoncons 0.178 has some pmr related fixes that should contribute to better stability in our codebase.

Copy link
Copy Markdown
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

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

LGTM

kostasrim
kostasrim previously approved these changes Jan 7, 2025
Comment thread src/server/json_family.cc Outdated
OpResult<bool> OpSet(const OpArgs& op_args, string_view key, string_view path,
const WrappedJsonPath& json_path, std::string_view json_str,
bool is_nx_condition, bool is_xx_condition) {
JsonMemTracker mem_tracker;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this is not really used below I would rather have it local to the scope of the if statement below but IMO it doesn't really matter.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is used. mem_tracker tracks used memory and ShardJsonFromString allocates from it

Copy link
Copy Markdown
Contributor

@kostasrim kostasrim Jan 8, 2025

Choose a reason for hiding this comment

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

I mean, that mem_tracker is local to the branch below and it's only used there and not in other places within this function.

See line 1311 mem_tracker.SetJsonSize(st->it->second, st->is_new); and after it we return.

Pardon me, I wasn't very clear 😄

Comment thread src/server/json_family.cc Outdated
// is to use absl::Cleanup and dispatch another Find() but that's too complicated because then
// you need to take into account the order of destructors.
OpResult<DbSlice::AddOrFindResult> st = SetJson(op_args, key, parsed_json.value());
OpResult<DbSlice::AddOrFindResult> st = SetJson(op_args, key, std::move(*parsed_json));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is fine, because:

  1. We pass a lambda now parse_json. See changes introduced by Stefan in fb8234c#diff-0799c8810dbf8758f9da40162075f38bb51639f806be28a06d9f669a6ebb0f76R1288

(The only redundancy here is the move on the lambda since it has no capture -- but I know you like calling move() anyways so it's fine).

  1. Moving the JsonMemTracker above is also fine. We no longer parse the json in this function but rather inside the lambda so when we construct the tracker we have no extra calculated allocations and when we call mem_tracker.SetJsonSize(st->it->second, st->is_new); below we already destructed the temporaries created within SetJson() from the lambda parse_json so the tracking deltas shall be correct

kostasrim
kostasrim previously approved these changes Jan 8, 2025
@kostasrim
Copy link
Copy Markdown
Contributor

@romange

Check failed: jsoncons::is_trivial_storage(u_.json_obj.cons.json_ptr->storage_kind()) || u_.json_obj.cons.json_ptr->get_allocator().resource() == tl.local_mr 

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
@romange
Copy link
Copy Markdown
Collaborator Author

romange commented Jan 8, 2025

I removed the lambda

Comment thread src/server/json_family.cc
VLOG(1) << "got invalid JSON string '" << json_str << "' cannot be saved";
return OpStatus::SYNTAX_ERR;
}
return parsed_json.value();
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this does not move, this copies.

Copy link
Copy Markdown
Contributor

@BagritsevichStepan BagritsevichStepan left a comment

Choose a reason for hiding this comment

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

I'd like to suggest running sanitizers on this branch

@romange
Copy link
Copy Markdown
Collaborator Author

romange commented Jan 8, 2025

@BagritsevichStepan
Copy link
Copy Markdown
Contributor

BagritsevichStepan commented Jan 8, 2025

Thanks, I think it can fix this issue #4391

Upd.: Still fails

Copy link
Copy Markdown
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

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

lgtm

@romange romange merged commit f3426bd into main Jan 8, 2025
@romange romange deleted the Pr1 branch January 8, 2025 18:05
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.

3 participants