Skip to content

Conversation

BagritsevichStepan
Copy link
Contributor

Small fix for the case if we cannot parse json string during loading.

@BagritsevichStepan BagritsevichStepan self-assigned this Mar 19, 2025
if (json) {
pv_->SetJson(std::move(*json));
} else {
LOG(ERROR) << "Invalid JSON string";
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this trigger errors in productions ? Is that something that we want ? cc @adiholden

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked other methods and they log ERROR for similar issues

Copy link
Contributor

Choose a reason for hiding this comment

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

we usually print error log for internal error, when we do not expect to have failures.
Here in rdb load its iether that we had bug in snapshot serializing json incorrect or user tries to load some json but we can not parse it.
I do think that its worth to have an error print here. Please also print the blob string here so it will be easier to investigate if we see this error.
How did you get to this error flow stefan?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep I agree with Adi here, it would be useful for us to be aware of those problematic flows

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't reproduce it, but I checked the memory tracking, and during the check, I found out that if an error occurs (so the JSON should be empty), we are still trying to use the parsed value

kostasrim
kostasrim previously approved these changes Mar 19, 2025
@@ -56,10 +56,6 @@ size_t QlMAllocSize(quicklist* ql, bool slow) {
}

size_t UpdateSize(size_t size, int64_t update) {
if (update >= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this change fixes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We discussed it with Kostas that it can be deleted here. We don't need this check. The method will still work correctly

Copy link
Contributor

Choose a reason for hiding this comment

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

@adiholden this should have been removed on the previous PR, but since he had this open, I suggested him to change it here (to avoid reiterating the PR one more time). The removed code is redundant.

@@ -56,10 +56,6 @@ size_t QlMAllocSize(quicklist* ql, bool slow) {
}

size_t UpdateSize(size_t size, int64_t update) {
if (update >= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@adiholden this should have been removed on the previous PR, but since he had this open, I suggested him to change it here (to avoid reiterating the PR one more time). The removed code is redundant.

@BagritsevichStepan BagritsevichStepan merged commit f4f615f into dragonflydb:main Mar 28, 2025
10 checks passed
@BagritsevichStepan BagritsevichStepan deleted the rdb_loader/fix-json-loading branch March 28, 2025 13:30
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