dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

implement SORT_RO

Open adiholden opened this issue 1 year ago • 9 comments

Implement this command inside Dragonfly according the to the Valkey spec: https://valkey.io/commands/sort_ro/

adiholden avatar Oct 06 '24 12:10 adiholden

Hi, Could you please provide the description of issue?

SalmanDeveloperz avatar Oct 06 '24 16:10 SalmanDeveloperz

Implement this command inside Dragonfly according the to the Valkey spec: https://valkey.io/commands/sort_ro/

romange avatar Oct 06 '24 18:10 romange

Hi,

I’m working on implementing the sort_ro command as per the Valkey spec, but I’m unsure where exactly in the project I should apply the changes. Could you point me to the specific files or modules that handle command definitions and execution within Dragonfly?

I’ve reviewed some parts of the project related to command handling, but I want to make sure I’m working in the right place before I proceed.

Thanks for your help!

SalmanDeveloperz avatar Oct 06 '24 19:10 SalmanDeveloperz

Hi @SalmanDeveloperz, this is where we implement our current SORT command: https://github.com/dragonflydb/dragonfly/blob/5efc8f11d2c4f6c5c3ad9a7069bf67af19befe9d/src/server/generic_family.cc#L1167

Reading the code now, I see that it actually does not support the STORE flag (which makes SORT a write-command, and which is not supported by the read-only SORT_RO command).

We should have a similar (preferably with code reuse) version which acts like the current one, and add STORE support to existing SORT command.

chakaz avatar Oct 06 '24 19:10 chakaz

Hey can I work on this issue? As I understood for this issue we need to modify SORT command to include STORE option with write acl and create new command SORT_RO without STORE option and read acl is this right?

H4R5H1T-007 avatar May 05 '25 13:05 H4R5H1T-007

Howdy @H4R5H1T-007,

Based on what I read from Valkey docs, it is just the read only variant of SORT. In other words, it's SORT without the STORE option so I don't I don't think ACL's are related here (other than their normal use)

kostasrim avatar May 05 '25 13:05 kostasrim

Hey Hi @kostasrim I mentioned acl because I read this in valkey document for sort_ro command

Since the original SORT has a STORE option it is technically flagged as a writing command in the Valkey command table. For this reason read-only replicas in a Valkey Cluster will redirect it to the primary instance even if the connection is in read-only mode (see the READONLY command of Valkey Cluster).

I thought maybe because of this acl for sort would be write and sort_ro would be read. Please let me know if I am incorrect 😄.

H4R5H1T-007 avatar May 05 '25 14:05 H4R5H1T-007

@H4R5H1T-007 From my understanding this clause applies only in cluster_mode and read only replicas. The second forwards SORT with STORE command to the master. You don't have to worry about that at all.

kostasrim avatar May 05 '25 14:05 kostasrim

also @H4R5H1T-007 we do not support STORE option based on the comments above. This should be a few lines PR :)

kostasrim avatar May 05 '25 14:05 kostasrim