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

#281: added support for DUMP command #633

Merged
merged 20 commits into from
Oct 1, 2024

Conversation

TheRanomial
Copy link
Contributor

@TheRanomial TheRanomial commented Sep 20, 2024

#281: Add DUMP and RESTORE Commands

Overview

This pull request introduces the DUMP and RESTORE commands to the DiceDB system, enhancing its capability to serialize and deserialize key-value pairs in a Redis-compatible format. These commands allow users to export the serialized form of a key's value and restore it later.

Changes

1. Implementation of DUMP and RESTORE Commands

  • Command Definitions:

    • Added metadata for DUMP and RESTORE commands in internal/eval/commands.go.
    • Defined command names, descriptions, evaluation functions (evalDUMP, evalRestore), arity, and key specifications.
  • Command Evaluation Logic:

    • Created internal/eval/dump_restore.go to handle the core logic for both commands.
    • evalDUMP:
      • Serializes the value stored at the specified key into a Redis-specific format.
      • Encodes the serialized data using Base64.
      • Returns the encoded string to the user.
    • evalRestore:
      • Accepts a key, TTL (Time To Live), and a Base64-encoded serialized value.
      • Decodes and deserializes the data.
      • Restores the key with the original value and TTL.
  • Serialization/Deserialization Support:

    • Implemented functions for serializing (rdbSerialize) and deserializing (rdbDeserialize) objects.
    • Supported data types include strings and integers.
    • Included CRC64 checksum for data integrity verification.
    • Handled error scenarios such as unsupported types and malformed data.

@apoorvyadav1111
Copy link
Contributor

Hi @TheRanomial , I have doubts regarding the implementation, just for my understanding purposes. I tried running the commands in redis and it was a different output. I understand that we might be using some other algorithm to dump the key. However when I read more about it online, it seems like DUMP and RESTORE go hand in hand. I feel that along with DUMP command, we should be implementing RESTORE such that the behavior can be validated completely. What are your thoughts on this?

@TheRanomial
Copy link
Contributor Author

I am having problems in running the restore command. I have made a commit which is failing test cases as restore is being timed out . @apoorvyadav1111. Added implementation for restore but it is not working i guess.

@apoorvyadav1111
Copy link
Contributor

Hey @TheRanomial , I tried some changes on my local using your branch and I was able to run following commands.
image
I share suggestions in the review for what changes I made. Since dump supports all data types, we need to handle all the types including set, hmap and json. We can discuss further on discord if you would prefer. Thanks

Copy link
Contributor

@apoorvyadav1111 apoorvyadav1111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @TheRanomial , After making these changes, I was able to run dump and restore. This looks like a good start. Please let me know if you have any suggestions.

internal/eval/commands.go Show resolved Hide resolved
internal/eval/eval.go Outdated Show resolved Hide resolved
internal/eval/eval.go Outdated Show resolved Hide resolved
internal/eval/eval.go Outdated Show resolved Hide resolved
internal/eval/eval.go Outdated Show resolved Hide resolved
internal/eval/eval.go Outdated Show resolved Hide resolved
@TheRanomial
Copy link
Contributor Author

@apoorvyadav1111 Thanks a lot for your suggestions. I made the changes you requested and the tests are working fine. Also added the TTL functionality. Open to new changes if any.

Copy link
Contributor

@apoorvyadav1111 apoorvyadav1111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most of the changes look good, left some minor comments. In addition to them, We still need to support other data types like set, bytearray and json. I feel that this can lead to big PR as tests have to be extensive (like ensuring expire works). Maybe it can be a separate PR. Maybe one of the collaborator and maintainers can provide suggestion here.

internal/eval/commands.go Show resolved Hide resolved
integration_tests/commands/dump_test.go Outdated Show resolved Hide resolved
@TheRanomial
Copy link
Contributor Author

@lucifercr07 kindly review it.

@lucifercr07
Copy link
Contributor

@TheRanomial apologies for delay will review by tomorrow, meanwhile can you resolve conflicts?

@TheRanomial
Copy link
Contributor Author

@lucifercr07 solved the conflicts.

internal/eval/eval.go Outdated Show resolved Hide resolved
internal/eval/eval.go Outdated Show resolved Hide resolved
internal/eval/eval.go Outdated Show resolved Hide resolved
internal/eval/eval.go Outdated Show resolved Hide resolved
@JyotinderSingh JyotinderSingh changed the title added support for DUMP command #281: added support for DUMP command Oct 1, 2024
Copy link
Collaborator

@JyotinderSingh JyotinderSingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the effort in this PR and for addressing all the reviews @TheRanomial! The changes look good, merging.

@JyotinderSingh JyotinderSingh merged commit 96a0202 into DiceDB:master Oct 1, 2024
2 checks passed
svkaizoku added a commit to svkaizoku/dice that referenced this pull request Oct 2, 2024
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

Successfully merging this pull request may close these issues.

4 participants