kvrocks icon indicating copy to clipboard operation
kvrocks copied to clipboard

feat: Add DELPREFIX to delete keys by prefix

Open iihimanshuu opened this issue 10 months ago • 8 comments

Description of Changes

I introduced updates in two files: commander.cc and cmd_key.cc. The primary changes involve the CommandDelPrefix and RegisterToCommandTable functions. Additionally, there are numerous lines of code changes due to the application of clang-format, which reformatted the codebase for consistency and readability.

solution for issue: https://github.com/apache/kvrocks/issues/2628

iihimanshuu avatar Mar 13 '25 19:03 iihimanshuu

when I format document with clang format it shows many line of code changes Screenshot 2025-03-14 095137 Screenshot 2025-03-14 095213

iihimanshuu avatar Mar 14 '25 04:03 iihimanshuu

Screenshot 2025-03-21 001242 the build test was successful!

iihimanshuu avatar Mar 20 '25 18:03 iihimanshuu

@PragmaTwice please review once..

iihimanshuu avatar Mar 21 '25 17:03 iihimanshuu

I just thought of another thing. Currently, kvrocks in cluster mode distributes data across shards based on slots. In the implementation, keys are prefixed with their hash value when stored, but it seems your delprefix implementation might not be accounting for this prefix handling. Have you considered how the hash prefix affects the key matching in the delprefix operation? Therefore, I believe this feature might be difficult to implement reliably in cluster mode. To avoid inconsistencies, it might be better to explicitly disable the delprefix command when kvrocks is operating in cluster mode.

RiversJin avatar Mar 22 '25 03:03 RiversJin

Hello, @Reviewer

I appreciate your thoughtful comments. You make a good point when you mention that the hash prefix in cluster mode may cause problems with key matching.

Present Implementation: The hash prefix used in cluster mode is not currently taken into consideration by the delprefix command, which may result in inconsistent results when trying to match and remove keys.

In order to remedy this, I suggest the following:

  1. deactivate delprefix in Cluster Mode: When kvrocks is running in cluster mode 2, we can specifically deactivate the delprefix command to avoid irregularities. Future Consideration: We can investigate more reliable prefix deletion methods that appropriately manage the hash prefix in cluster mode. Before making deletions, this may require extra logic to extract and match the hash prefix.

Next Steps:

I will update the implementation to disable the delprefix command in cluster mode and push the changes for review. Please let me know if you have any further suggestions or if this approach seems reasonable.

Thank you for your valuable input.

iihimanshuu avatar Mar 22 '25 08:03 iihimanshuu

@PragmaTwice request for review

iihimanshuu avatar Mar 29 '25 09:03 iihimanshuu

@git-hulk Request to review commits

iihimanshuu avatar Mar 30 '25 12:03 iihimanshuu

I would love to hear some suggestions..

iihimanshuu avatar Apr 03 '25 19:04 iihimanshuu