Skip to content

chore(json_family): Clean up the memory tracking code for JSON mutate operations. FOURTH PR #5070

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

Conversation

BagritsevichStepan
Copy link
Contributor

@BagritsevichStepan BagritsevichStepan commented May 6, 2025

This is fourth PR that fixes memory tracking issues in JSON.

This PR cleans up the code, removes MutateOperationOptions as it is no longer needed, and replaces JsonMemTracker with JsonAutoUpdater. Although there is currently no bug with op_args.shard->search_indices()->RemoveDoc after initializing JsonMemTracker — since the current JSON API does not allow this issue to be reproduced — it is still considered bad practice. To prevent potential future bugs, JsonAutoUpdater is used instead.

Bugs that were found and fixed:

  1. Bug in JsonMutateOperation, where we called op_args.shard->search_indices()->RemoveDoc after starting the memory tracking. RemoveDoc has a static cache that may allocate some memory, but this memory does not belong to the JSON object itself. As a result, memory usage will be overestimated in this case.

@romange
Copy link
Collaborator

romange commented May 7, 2025

I do not see any test changes in this PR. Does this PR removes completely JsonMemTracker?

@BagritsevichStepan
Copy link
Contributor Author

I can try to reproduce the bug in the tests

@BagritsevichStepan BagritsevichStepan changed the title fix(json_family): Fix memory tracking for JSON mutate operations. FOURTH PR chore(json_family): Clean up the memory tracking code for JSON mutate operations. FOURTH PR May 27, 2025
@BagritsevichStepan
Copy link
Contributor Author

@romange I updated the description of the PR, there is no need in test here

@BagritsevichStepan BagritsevichStepan force-pushed the memory/fix-memory-tracking-for-mutate-json-operations branch from 9e81535 to 6453149 Compare May 27, 2025 14:24
@BagritsevichStepan BagritsevichStepan enabled auto-merge (squash) May 27, 2025 15:11
@BagritsevichStepan BagritsevichStepan merged commit e241efc into dragonflydb:main May 27, 2025
10 checks passed
@BagritsevichStepan BagritsevichStepan deleted the memory/fix-memory-tracking-for-mutate-json-operations branch May 27, 2025 16:33
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.

2 participants