Skip to content

Fix issues with server.allow_access_expired#14262

Merged
sundb merged 7 commits intoredis:unstablefrom
Jam804:unstable
Oct 12, 2025
Merged

Fix issues with server.allow_access_expired#14262
sundb merged 7 commits intoredis:unstablefrom
Jam804:unstable

Conversation

@Jam804
Copy link
Contributor

@Jam804 Jam804 commented Aug 8, 2025

Close #14214

  1. When the server.allow_access_expired flag is set to 1, it allows access to expired keys that have not yet been evicted. All places involving access to expired keys should consider the impact of this parameter.
  2. The modifications involve five methods: hfieldIsExpired, hashTypeNext, hashTypeLength, keyIsExpired, and hashTypeIsExpired. When the server.allow_access_expired flag is set to 1, these methods will not skip expired keys, otherwise they follow the normal logic execution.

@CLAassistant
Copy link

CLAassistant commented Aug 8, 2025

CLA assistant check
All committers have signed the CLA.

@snyk-io
Copy link

snyk-io bot commented Aug 8, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@kaplanben
Copy link

kaplanben commented Aug 8, 2025

Logo
Checkmarx One – Scan Summary & Details4622f44d-d4c1-4c64-a4e1-395029a501bf

New Issues (5)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
CRITICAL Buffer_Improper_Index_Access /src/dict.c: 1412
detailsThe array index entries at /src/dict.c in line 1412 is used to reference an index of a cell of the array entries at /src/dict.c in line 1412 in a...
ID: 4FV2BYbldlpSrbF4lW7Dv2o9Dx4%3D
Attack Vector
MEDIUM Divide_By_Zero /src/object.c: 1236
detailsThe application performs an illegal operation in objectComputeSize, in /src/object.c. In line 1236, the program attempts to divide by elecount, w...
ID: Blm6eEEj9vF5UfiAV2Vg9JeRDf4%3D
Attack Vector
LOW Unpinned Actions Full Length Commit SHA /daily.yml: 973
detailsPinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA help...
ID: K90d22j%2B5y9BqWICFgc5IB5GJmI%3D
LOW Unpinned Actions Full Length Commit SHA /daily.yml: 1012
detailsPinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA help...
ID: ngpCPc8xRqiGpjip1VdNRg0fOyg%3D
LOW Unpinned Actions Full Length Commit SHA /daily.yml: 1138
detailsPinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA help...
ID: g8ggXzSad9Bi6hVITKKmTVlxfL4%3D
Fixed Issues (5)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
HIGH Use_After_Free /deps/lua/src/strbuf.c: 104
MEDIUM Divide_By_Zero /src/object.c: 1239
LOW Unpinned Actions Full Length Commit SHA /daily.yml: 1073
LOW Unpinned Actions Full Length Commit SHA /daily.yml: 917
LOW Unpinned Actions Full Length Commit SHA /daily.yml: 956

@Jam804 Jam804 force-pushed the unstable branch 2 times, most recently from 8d57e8d to b94faef Compare August 13, 2025 07:48
src/db.c Outdated
@@ -1275,7 +1275,7 @@ void keysCommand(client *c) {
sds key = kvobjGetKey(kv);

if (allkeys || stringmatchlen(pattern,plen,key,sdslen(key),0)) {
if (!keyIsExpired(c->db, NULL, kv)) {
if (server.allow_access_expired || !keyIsExpired(c->db, NULL, kv)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not add server.allow_access_expired to keyIsExpired?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea, but since keyIsExpired is used in many places, I need to test whether this change will cause any bugs.

@Jam804
Copy link
Contributor Author

Jam804 commented Aug 14, 2025

@sundb Would you mind taking a look at this? Thank you so much!

Copy link
Collaborator

@sundb sundb left a comment

Choose a reason for hiding this comment

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

please also add a module test to cover it, thx.

@sundb
Copy link
Collaborator

sundb commented Aug 15, 2025

@Jam804 why not fix another issue(hashTypeGetValue doesn't consider the flag, returning GETF_EXPIRED instead of GETF_OK ) mentioned in #14214?

@Jam804
Copy link
Contributor Author

Jam804 commented Aug 15, 2025

@Jam804为什么不修复#14214hashTypeGetValue doesn't consider the flag, returning GETF_EXPIRED instead of GETF_OK 中提到的另一个问题()?

I'm currently researching, and I plan to tackle them one by one. I'll complete the unit tests later.

@Jam804
Copy link
Contributor Author

Jam804 commented Aug 16, 2025

@Jam804为什么不修复#14214hashTypeGetValue doesn't consider the flag, returning GETF_EXPIRED instead of GETF_OK 中提到的另一个问题()?

I'm currently researching, and I plan to tackle them one by one. I'll complete the unit tests later.

done

@sundb sundb added this to Redis 8.2 Aug 18, 2025
@sundb sundb added the release-notes indication that this issue needs to be mentioned in the release notes label Aug 18, 2025
@Jam804 Jam804 force-pushed the unstable branch 2 times, most recently from 9c9e9d5 to 23ae347 Compare August 18, 2025 16:04
@Jam804
Copy link
Contributor Author

Jam804 commented Aug 18, 2025

@sundb Thank you very much for your corrections. This is my first time contributing code to Redis, please be lenient with me. I will continue to study Redis in depth and pay more attention in future PRs.

@sundb
Copy link
Collaborator

sundb commented Aug 19, 2025

@Jam804 please don't use force push

@sundb
Copy link
Collaborator

sundb commented Aug 19, 2025

I'm currently researching, and I plan to tackle them one by one. I'll complete the unit tests later.

done

but i don't see any change you made for this fix.

@Jam804 Jam804 reopened this Sep 13, 2025
@Jam804 Jam804 force-pushed the unstable branch 2 times, most recently from 6ebc948 to af7c952 Compare September 13, 2025 14:16
@moticless
Copy link
Collaborator

@Jam804, thanks for the updates 🙏. Please avoid git push --force on PRs that others need to follow. It rewrites history, forces reviewers to start over, and makes comments/diffs harder to track. A normal push works best, and cleanup can wait until just before merge. Thanks!

@Jam804
Copy link
Contributor Author

Jam804 commented Sep 23, 2025

@moticless Could you please advise if any other modifications are needed in this Pull Request? I'll diligently work on resolving all identified issues.

@sundb sundb moved this from Done to Awaits Merge in Redis 8.4 Sep 23, 2025
src/t_hash.c Outdated
/* Move to the next entry in the hash. Return C_OK when the next entry
* could be found and C_ERR when the iterator reaches the end. */
int hashTypeNext(hashTypeIterator *hi, int skipExpiredFields) {
skipExpiredFields &= !server.allow_access_expired;
Copy link
Collaborator

Choose a reason for hiding this comment

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

i don't like this &=, it should be just =
(same above)

Copy link
Collaborator

Choose a reason for hiding this comment

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

it's not logically wrong, just looks weird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@sundb
Copy link
Collaborator

sundb commented Oct 11, 2025

@Jam804 can you take a look at this failure, but I'm not sure it's related to this PR.

@Jam804
Copy link
Contributor Author

Jam804 commented Oct 11, 2025

@Jam804 can you take a look at this failure, but I'm not sure it's related to this PR.

After reviewing both failing tests, I can confirm they are unrelated to this commit. These appear to be test environment instability issues.

@sundb
Copy link
Collaborator

sundb commented Oct 11, 2025

@Jam804 please merge the latest unstable and let's try again. thx.

@Jam804
Copy link
Contributor Author

Jam804 commented Oct 11, 2025

@Jam804 please merge the latest unstable and let's try again. thx.

done

@sundb
Copy link
Collaborator

sundb commented Oct 12, 2025

@Jam804 please update the top comment, maybe list all the modifications that need to be noticed.

@Jam804
Copy link
Contributor Author

Jam804 commented Oct 12, 2025

@Jam804请更新顶部评论,也许列出所有需要注意的修改。

done

@sundb sundb merged commit 083f38e into redis:unstable Oct 12, 2025
19 checks passed
@github-project-automation github-project-automation bot moved this from Awaits Merge to Done in Redis 8.4 Oct 12, 2025
@sundb
Copy link
Collaborator

sundb commented Oct 12, 2025

@Jam804 merged, thx.

@Jam804
Copy link
Contributor Author

Jam804 commented Oct 12, 2025

Thank you for your patient review and assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Issues with server.allow_access_expired

6 participants