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

Command Migration: ('HSET', 'HGET', 'HSETNX', 'HDEL') #1021

Closed
4 tasks
AshwinKul28 opened this issue Oct 8, 2024 · 14 comments
Closed
4 tasks

Command Migration: ('HSET', 'HGET', 'HSETNX', 'HDEL') #1021

AshwinKul28 opened this issue Oct 8, 2024 · 14 comments
Assignees
Labels
migration -- command Migrates current eval to a refactored eval for all protocols functionality

Comments

@AshwinKul28
Copy link
Contributor

This issue tracks the migration of the mentioned commands - ('HSET', 'HGET', 'HSETNX', 'HDEL') to make them compatible across the three protocols supported by the Dice database: RESP, HTTP, and WebSocket.
DiceDB now supports more than one protocols (Resp/http/websocket). We don't want eval operation of each command to be strictly bound with any of the protocols. Currently eval function return statements of each command is bounded to the RESP protocol.

The migration is required because:

  • The current implementation is specific to the RESP protocol
  • Evaluation functions of each command must be refactored to ensure protocol-agnostic behavior.
  • Evaluation functions should return raw responses instead of protocol specific responses.

The goal is to make the command logic protocol-independent, allowing all three protocols to call the same core functionality seamlessly.

Requirements

  • Refactor the evaluation function of [Command Name] to be generic.
  • Ensure the evaluation function does not include protocol-specific logic.

Migration Steps

  1. Analyze Current Implementation

    • Review the current codebase to understand how the command logic is implemented.
  2. Refactor Return Logic

    • Create a new function with the function definition as evalXXX(args []string, store *dstore.Store) *EvalResponse under the file /internal/eval/store_eval.go
    • Analyse return statements of the eval and modify them to send raw types without encoding
    • Use errors in the return statements from /errors/migrated_errors.go file
    • Use perdefined responses from /internal/clientio/resp.go file as RespType variables
  3. Command/Worker specific Changes

    • Make IsMigrated flag to true in the commands information under /internal/eval/commands.go file.
    • Use the newly written eval function against the NewEval parameter in the same command structure.
    • Delete the old eval function from the /internal/eval/eval.go file.
    • Add the migrated command to the /internal/worker/CommandsMeta map and make it's type as SingleShard
  4. Update Unit Tests

    • Refactor existing unit tests to accommodate the new implementation.
    • Add new unit tests if necessary to cover all possible cases.
  5. Integration Tests

    • Run all integration tests to ensure successful migration.
    • Ensure that each protocol (RESP, HTTP, WebSocket) works correctly after migration.

Checklist

  • Migrated the evalXXX function with the latest definition
  • Update or add unit tests for the new implementation.
  • All unit tests pass successfully.
  • Ensure all integration tests pass successfully.

Additional Notes

  • Describe any edge cases that need to be handled in the generic function.
  • Mention any protocol-specific optimizations required in wrappers.

If there are any questions or concerns about this migration, please mention them here.

Related Issues/PRs

  • Sample implementation for the Get, Set, GetSet and SetEx can be found in this Pull Request.
@anchalsinghrajput
Copy link

@AshwinKul28, can I pick this up?

@AshwinKul28
Copy link
Contributor Author

Hey @anchalsinghrajput thanks! Go for it. 🚀

@AshwinKul28
Copy link
Contributor Author

HI @anchalsinghrajput , I hope you are doing well. Do you happen to have any updates on this? If you've any doubts please let us know on the discord.

@vpsinghg
Copy link
Contributor

@AshwinKul28 @anchalsinghrajput if you are currently occupied with something else, I can pick this up.

@anchalsinghrajput
Copy link

Hi @AshwinKul28 @vpsinghg, I am new to go, i am still working on it, will give the update once i complete it.

@anchalsingh25
Copy link
Contributor

Hi @AshwinKul28 , can you please reassign this issue to this Git profile.

@AshwinKul28
Copy link
Contributor Author

AshwinKul28 commented Oct 17, 2024

Done @anchalsingh25 I see you have opened a PR, please attach this issue to the PR. Thanks

@AshwinKul28 AshwinKul28 linked a pull request Oct 17, 2024 that will close this issue
7 tasks
@soumya-codes soumya-codes added the migration -- command Migrates current eval to a refactored eval for all protocols functionality label Oct 17, 2024
@arpitbbhayani
Copy link
Contributor

Hello @anchalsingh25,

There has been no activity on this issue for the past 5 days.
It would be awesome if you keep posting updates to this issue so that we know you are actively working on it.

We are really eager to close this issue at the earliest, hence if we continue to see the inactivity, we will have to reassign the issue to someone else. We are doing this to ensure that the project maintains its momentum and others are not blocked on this work.

Just drop a comment with the current status of the work or share any issues you are facing. We can always chip in to help you out.

Thanks again.

@AshwinKul28
Copy link
Contributor Author

Hey @anchalsingh25 hope you are doing well. I saw on the discord that you had lost your changes, by any chance were you able to recover them?

@AshwinKul28
Copy link
Contributor Author

Hey @anchalsingh25 Sorry to bother you again, hope you are doing well, but we need to chase the timeline for the production readiness, hence for now I'm opening up this issue for others to pick it up, you can pickup any other issue once you are available and back. Thanks a lot and apologies.

@apoorvyadav1111
Copy link
Contributor

Hi @AshwinKul28 , I will be picking this up on priority. This also unblocks me to work on hashmap with expiry.

@bhima2001
Copy link
Contributor

@lucifercr07 I can work on this

@apoorvyadav1111
Copy link
Contributor

Lets close this issue together @bhima2001 .

@anchalsingh25
Copy link
Contributor

Hi @AshwinKul28 @apoorvyadav1111,

I was able to recover my changes. Can you please review the PR?

apoorvyadav1111 pushed a commit that referenced this issue Nov 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…X, HDEL #1219
JyotinderSingh pushed a commit that referenced this issue Nov 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migration -- command Migrates current eval to a refactored eval for all protocols functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants