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

Implement support for read modify write operations in the hashtable and in the storage db #173

Closed
danielealbano opened this issue Aug 16, 2022 · 0 comments · Fixed by #179
Assignees
Labels
enhancement New feature or request
Projects
Milestone

Comments

@danielealbano
Copy link
Owner

Currently the hashtable and the storage db, as direct conseuquence, allow only blind updates but for certain kind of operations a RMW pattern is required.

For example the redis set command has 2 flags, NX and XX, which make it hard to atomically decide what needs to be done without a RMW operation.

Because RMW opertions are going to be slower than the normal blind updates it's necessary to implement them side by side to the blind operations introducing 3 new functions in the hashtable:

  • hashtable_op_set_rmw_start
  • hashtable_op_set_rmw_commit
  • hashtable_op_set_rmw_rollback

The hashtable_op_set_rmw_start function will have to perform the initial index search and return the bucket to be used (existing or new) and the value in the bucket.
The needed behaviour matches what hashtable_mcmp_support_op_search_key_or_create_new does behind the scenes so it can easily be a wrapper of that function once the necessary bits and pieces required are added.

The hashtable_op_set_rmw_commit instead will have to complete the operations, saving the new value in the bucket as needed.

The hashtable_op_set_rmw_rollback function instead will have to revert the operations carried out by hashtable_mcmp_support_op_search_key_or_create_new because under the hood that function marks a bucket as occupied if during the initial search one with a matching hash and key wasn't found.

Both hashtable_op_set_rmw_commit and hashtable_op_set_rmw_rollback will have to release the locks as necessary.

The work to be carried out on the hashtable can be thought almost as simply splitting the hashtable_mcmp_op_set function into 3 separated parts.

The storage db will simply have to expose this interface wrapping it to work with the entry indexes.

@danielealbano danielealbano created this issue from a note in cachegrand (In Progress) Aug 16, 2022
@danielealbano danielealbano self-assigned this Aug 16, 2022
@danielealbano danielealbano added the enhancement New feature or request label Aug 16, 2022
@danielealbano danielealbano added this to the v0.2 milestone Aug 16, 2022
cachegrand automation moved this from In Progress to Completed Aug 17, 2022
danielealbano added a commit that referenced this issue Aug 17, 2022
…e them when needed (#179)

This PR introduces 4 groups of changes:

RMW (Read-Modify-Write) operations in the multi producer mutli consumer hashtable with the ability to commit an update, commit a delete or abort the operation
RMW operations in the storage db, with the ability to commit an update, commit a delete or abort the operation, which will actual become a commit delete if the key being accessed is expired and no new values are supplied and the delete is not requested
The SET command now properly supports the NX, XX, GET and KEEPTTL options
The integration tests for the currently supported Redis commands have been improved drammatically making them much more simple and understandable and a new set of tests have been introduced for the SET command

This PR closes the issue #173
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
cachegrand
  
Completed
1 participant