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

Bug fix: JSON document size reported by 'json.debug memory' #30

Draft
wants to merge 1 commit into
base: unstable
Choose a base branch
from

Conversation

joehu21
Copy link
Collaborator

@joehu21 joehu21 commented Jan 6, 2025

Fix 2 bugs related to json document size reported by json.debug memory:

  1. In command JSON.NUMINCRBY and JSON.NUMMULTBY, the doc size meta data is not updated. This may lead to the doc size meta data becomes negative. For example, when JSON.NUMINCRBY updates an integer value to a double value, the memory size of the key is increased (because double is stored as string). However, the doc size meta data is not updated due to the bug. Later, when JSON.SET is called to set the value to an integer (like 0) or a double that occupies less memory, the key's memory size shrinks and hence a few bytes are subtracted from the doc size meta data. If the process repeats, eventually the doc size meta data becomes negative and is wrapped around as an insanely large positive integer.
  2. The value returned from json.debug memory <key> doesn't match the value returned from json.debug memory <key> ..

Code changes:

  • RapidJSON: Added GenericValue::ComputeMallocedSize() that computes malloc'ed size of a JValue
  • Fix JSON.NUMINCRBY and JSON.NUMMULTBY: update doc size meta data

Test:
Added two python tests:

  • test_doc_mem_size_with_numincrby: This test reproduces the bug of "doc size meta data becomes negative".
  • test_verify_doc_mem_size: This test verifies the returned from json.debug memory <key> doesn't match the value returned from json.debug memory <key> ..

@joehu21 joehu21 changed the title Fix JSON document size Fix bugs related to JSON document size Jan 6, 2025
@joehu21 joehu21 changed the title Fix bugs related to JSON document size JSON document size reported by json.debug memory Jan 6, 2025
@joehu21 joehu21 changed the title JSON document size reported by json.debug memory Bug fix: JSON document size reported by 'json.debug memory' Jan 6, 2025
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.

1 participant