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(server): Save element expirations for hash sets & sets #2223

Merged
merged 4 commits into from
Nov 30, 2023

Conversation

chakaz
Copy link
Collaborator

@chakaz chakaz commented Nov 27, 2023

Fixes #2052


bool is_intset = true;
bool is_intset = (rdb_type_ == RDB_TYPE_HASH);
if (len <= SetFamily::MaxIntsetEntries()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the condition (rdb_type_ == RDB_TYPE_HASH && ltrace->blob_count() < SetFamily::MaxIntsetEntries()) will be more clear here.
you will not need the increment logic above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do need the increment logic for incrementing the loop, but I moved that below. Otherwise, SG.

src/server/rdb_load.cc Outdated Show resolved Hide resolved
@@ -514,6 +509,8 @@ void RdbLoaderBase::OpaqueObjLoader::CreateSet(const LoadTrace* ltrace) {
} else {
bool use_set2 = GetFlag(FLAGS_use_set2) || rdb_type_ == RDB_TYPE_SET_WITH_EXPIRY;
if (use_set2) {
LOG_IF(ERROR, !GetFlag(FLAGS_use_set2))
Copy link
Collaborator

Choose a reason for hiding this comment

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

please also print the key in the error.
I actually think that in this case we either need to use the other set impl or not load this entry.
What will be the reason for user to disable use_set2 ? if we have a bug there / cuasing a crash. So I think we should respect the flag and not use set2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If set2 is disabled, we use Redis implementation of set, which does not support field expiration.
What do you think we should do in that case? Drop the expiration data and load everything?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So we should either not load the key or we can drop the expiration data.. both options looks ok to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's easier to drop the data (I think), so I went with that
And I also fixed an existing bug (iterating an empty set crashes), but honestly I'm not sure how to reproduce it so it might be an unreachable bug

@chakaz chakaz requested a review from adiholden November 29, 2023 18:18
@chakaz chakaz merged commit d15bcf8 into main Nov 30, 2023
10 checks passed
@chakaz chakaz deleted the rdb-hash-expiry branch November 30, 2023 12:08
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.

Set and hash field expirations are not persisted after restart
2 participants