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(rdb_load): fix loading huge hmaps with ttl #3825

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

andydunstall
Copy link
Contributor

Fixes loading huge hmaps with TTL fields, where the TTL isn't parsed correctly:

Can't parse hashmap TTL for d6e8d4c162dd4b7252c55a5e348d017de976ac0b1ca5b3a262, ttl='cab59b6814524488e8ead622fc430e28f11b1fbd86e8f9f13b', val=52505369

This is caused by kMaxBlobLen not being a multiple of 3. As each LoadTrace segment contains elements key, value and TTL, when the segment is truncated, the next segment will be invalid. Such as it may start with 'value', 'ttl' instead of 'key', 'value', 'ttl', which leads to the above parsing error.

Therefore when the map includes a TTL, each segment must be a multiple of 3.

(I guess a simpler alternative is just to set kMaxBlobLen to be a multiple of both 2 and 3? I'm not sure how important being a power of 2 is?)

size_t n = len;
if (n > kMaxBlobLen) {
// Ensure n is a multiple of increment.
n = kMaxBlobLen - (kMaxBlobLen % increment);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets define kMaxBlobLen be a multiple of 6 with a comment why it's needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure updated

@romange romange merged commit 5d64e14 into dragonflydb:main Sep 30, 2024
9 checks passed
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