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

Make KEYS can visit expired key in import-source state #1326

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

enjoy-binbin
Copy link
Member

After #1185, a client in import-source state can visit expired
key both in read commands and write commands, this commit handle
keyIsExpired function to handle import-source state as well, so
KEYS can visit the expired key.

This is not particularly important, but it ensures the definition,
also doing some cleanup around the test, verified that the client
can indeed visit the expired key.

After valkey-io#1185, a client in import-source state can visit expired
key both in read commands and write commands, this commit handle
keyIsExpired function to handle import-source state as well, so
KEYS can visit the expired key.

This is not particularly important, but it ensures the definition,
also doing some cleanup around the test, verified that the client
can indeed visit the expired key.

Signed-off-by: Binbin <binloveplay1314@qq.com>
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.57%. Comparing base (4986310) to head (3032a99).
Report is 23 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1326      +/-   ##
============================================
- Coverage     70.68%   70.57%   -0.11%     
============================================
  Files           115      115              
  Lines         63177    63179       +2     
============================================
- Hits          44657    44589      -68     
- Misses        18520    18590      +70     
Files with missing lines Coverage Δ
src/db.c 89.12% <100.00%> (+0.01%) ⬆️
src/networking.c 88.56% <ø> (+0.16%) ⬆️

... and 12 files with indirect coverage changes

@zuiderkwast
Copy link
Contributor

I guess an importing client will not use KEYS and SCAN, but I agree, it's good to ensure the contract that this client can read expired keys.

Copy link
Contributor

@lyq2333 lyq2333 left a comment

Choose a reason for hiding this comment

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

Agree with @zuiderkwast. LGTM.

if (!keyIsExpiredWithDictIndex(db, key, dict_index)) return 0;

/* See expireIfNeededWithDictIndex for more details. */
if (server.primary_host == NULL && server.import_mode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we use iAmPrimary() here? I am not very clear about the difference between these two.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, i think we should, we probably need to use iAmMaster to replace all the server. primary_host == NULL. The difference is that i guess, when restarting a cluster replica node, its primary_host may be NULL but it is a replica node in cluster role.

Copy link
Member Author

@enjoy-binbin enjoy-binbin Nov 21, 2024

Choose a reason for hiding this comment

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

i guess it is a small change (but there are too many references that need to look with), i am going to open a new PR for a better review.

Copy link
Member Author

Choose a reason for hiding this comment

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

i remember @soloestoy had dealt with it before, do you have the old fix (backups) locally that you want to pick up?

@enjoy-binbin enjoy-binbin merged commit db7b739 into valkey-io:unstable Nov 27, 2024
48 checks passed
@enjoy-binbin enjoy-binbin deleted the import-mode branch November 27, 2024 16:16
enjoy-binbin added a commit to enjoy-binbin/valkey that referenced this pull request Nov 27, 2024
In valkey-io#1326 we make KEYS can visit expired key in import-source state
by updating keyIsExpired to check for import mode. But after valkey-io#1205,
we now use keyIsExpiredWithDictIndex to optimize and remove the
redundant dict_index, and keyIsExpiredWithDictIndex does not handle
this logic.

In this commit, we handle keyIsExpiredWithDictIndex to make it check
for import mode as well so that KEYS can visit the expired key.

Signed-off-by: Binbin <binloveplay1314@qq.com>
enjoy-binbin added a commit that referenced this pull request Nov 28, 2024
)

In #1326 we make KEYS can visit expired key in import-source state
by updating keyIsExpired to check for import mode. But after #1205,
we now use keyIsExpiredWithDictIndex to optimize and remove the
redundant dict_index, and keyIsExpiredWithDictIndex does not handle
this logic.

In this commit, we handle keyIsExpiredWithDictIndex to make it check
for import mode as well so that KEYS can visit the expired key.

Signed-off-by: Binbin <binloveplay1314@qq.com>
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