Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

WATCH command lacks the atomicity guarantees #4024

Open
suxb201 opened this issue Oct 31, 2024 Discussed in #4015 · 0 comments
Open

WATCH command lacks the atomicity guarantees #4024

suxb201 opened this issue Oct 31, 2024 Discussed in #4015 · 0 comments

Comments

@suxb201
Copy link

suxb201 commented Oct 31, 2024

Discussed in #4015

Originally posted by suxb201 October 30, 2024
How can we ensure the atomicity between WATCH and EXEC?

WATCH k1
MULTI
SET k2 v2
EXEC

When k1 is modified, the current conn context's watched_dirty flag is set to true. If watched_dirty is false, EXEC will begin execution. However, how can we ensure that the check of this flag and the execution of the transaction itself are atomic?

In other words, there is a potential issue where k1 could be modified during the EXEC execution, or k1 could be modified just before EXEC is executed and after the flag is checked.

You are right, the implementation of this feature is indeed lacks the atomicity guarantees. The right way to do it would be to check if something is modified during the schedule phase of MULTI transaction, when run locally on the shard thread.

#4015 (comment)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant