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

SetNX returning false for new keys #2985

Open
alex-rufo opened this issue Apr 29, 2024 · 2 comments
Open

SetNX returning false for new keys #2985

alex-rufo opened this issue Apr 29, 2024 · 2 comments

Comments

@alex-rufo
Copy link

The existing client already incorporates support for retrials. Should an error occur during execution and it's not a readTimeout, the command undergoes retrying within the _process function. However, there are scenarios where retrying may not be appropriate. Take, for instance, the case where a connection closes during a SetNX operation in Redis. In such instances, we cannot know with absolute certainty if the element was successfully inserted or not. Retrying in this case could lead to misleading outcomes. For instance, if we retry, the key might already exist, causing Redis to return false. This could potentially mislead consumers into believing that the keys weren't present before executing the command.

Expected Behavior

To enhance reliability, consider making the SetNX call idempotent. This ensures that even if it's retried, the outcome remains consistent. If achieving idempotence isn't feasible, it's crucial to signal an error when we cannot ascertain the behavior of SetNX with absolute certainty. This approach fosters clarity and reliability in handling potential retries, safeguarding against ambiguous or misleading outcomes.

Current Behavior

In some cases, SetNX returns false even when no key was previously defined.

Steps to Reproduce

Unfortunately, there is no easy way for me to reproduce the issue :(

@wnz27
Copy link

wnz27 commented May 13, 2024

yes, i encounter this issue

@wnz27
Copy link

wnz27 commented May 13, 2024

截屏2024-05-13 12 38 03 截屏2024-05-13 12 38 16 截屏2024-05-13 12 39 37

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

No branches or pull requests

2 participants