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

Consistent reads #432

Merged
merged 20 commits into from
Oct 11, 2023
Merged

Consistent reads #432

merged 20 commits into from
Oct 11, 2023

Conversation

danielealbano
Copy link
Owner

This PR implements a mechanism to guarantee consistent reads adding support for read-only transactions and leveraging this new transaction type to synchronize the read and write operations.

A major advantage of this approach is that meanwhile before commands like MSET or MSETNX would have allowed a client to read a value of a sequence being set, breaking the ABI with the Redis interface (where MSET, MSETNX and all the other commands that operate on the same set of keys are atomic), now the new mechanism implemented directly into the transaction logic and leveraged internally by the hashtable, ensures that the reads will wait any write transaction in progress.

Meanwhile this is causing a performance penalty, the major advantage is that now cachegrand is much more ACID compliant (infact when used with the on-disk storage cachegrand is fully ACID compliant) providing transaction isolation.

Another major advantage is that now a lot of complexity implemented to allow reads with writes in progress can be dropped, which will lead to (a) an esamplification of the code and (b) some performance improvements.

These changes have room for improvement, the locks now might last for several seconds, depending on the type of operation being carried out, and there is no reason for a fiber to wait spinning, it makes much more sense to yield after some spinning to let other fibers to carry out their own operations.
Also, so far all the operation that required access to multiple keys were forced to use read-write transaction but for several it's not really required and they can switch to read-only transaction.

Because there is (plenty) of room for improvement, no benchmark is included to compare the performances.

…re read transactions which in turn require a worker context, the worker context needs to be set for the tests to run properly
@danielealbano danielealbano added the enhancement New feature or request label Oct 11, 2023
@danielealbano danielealbano added this to the v0.5 milestone Oct 11, 2023
@danielealbano danielealbano self-assigned this Oct 11, 2023
@codecov
Copy link

codecov bot commented Oct 11, 2023

@danielealbano danielealbano merged commit 5f682cc into main Oct 11, 2023
5 checks passed
@danielealbano danielealbano deleted the feature/consistent-reads branch October 11, 2023 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

1 participant