Skip to content

cli fix for correct db number#6728

Merged
oranagra merged 4 commits intoredis:unstablefrom
hwware:clifix
Dec 13, 2020
Merged

cli fix for correct db number#6728
oranagra merged 4 commits intoredis:unstablefrom
hwware:clifix

Conversation

@hwware
Copy link
Contributor

@hwware hwware commented Jan 2, 2020

No description provided.

Copy link
Member

@itamarhaber itamarhaber left a comment

Choose a reason for hiding this comment

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

Hello @hwware

This looks like a good start. However, I think more work is needed.

For example, I don't see where DISCARD is handled and I'm unclear how this will behave if I try nested MULTI statements (which [usually] yields an error).

@hwware
Copy link
Contributor Author

hwware commented Jan 3, 2020

@itamarhaber Hi, thank you for your valuable comments, I will work on these and resolve & test these shortly..

update redis cli

solve comments
@hwware
Copy link
Contributor Author

hwware commented Jan 6, 2020

Hi @itamarhaber Can you please review this PR again? thanks!

@hwware
Copy link
Contributor Author

hwware commented Dec 9, 2020

closing this PR since we have a more recent descussion and fix in #8000

@hwware hwware closed this Dec 9, 2020
@oranagra
Copy link
Member

oranagra commented Dec 9, 2020

in my eyes, redis-cli is aiming to be simple and dumb, but considering it attempts to show the currently selected db in the prompt, i think it's its job to track multi state.
maybe even show the fact you're in multi state in the prompt too.
re-opening for further discussion.

@oranagra oranagra reopened this Dec 9, 2020
@hwware
Copy link
Contributor Author

hwware commented Dec 9, 2020

hi @oranagra , showing the multi state is a good idea in cli, it indeed give user clear idea whether it is in a transaction context, rather than checking the return value of command(will return queued). For this db number inconsistency issue, I felt like if we provide a way for fetching the current db, like #8139 or CLIENT INFO command and using this in cli when it refreshing the prompt, we shouldn't see this issue anymore. How do you think?

@oranagra
Copy link
Member

oranagra commented Dec 9, 2020

i don't think redis-cli needs to implicitly send commands to redis to refresh the prompt (even the initial COMMAND command it implicitly sends at startup may be problematic).
i think redis-cli needs to track the selected database on it's own.
so IMHO this PR goes the right way (tracking both client states in the client), i think it would be nice to reflect both in the prompt too.

@hwware
Copy link
Contributor Author

hwware commented Dec 10, 2020

thanks @oranagra for the advice,

i think redis-cli needs to track the selected database on it's own.

I was just not sure if this is the only case causing the db inconsistencies between cli and redis server and what we did here is just purely doing something in cli side rather than #8139 which provide a way for sync with server to get correct db number. but this pr actually fixing the issue #6727, if you think this make sense I can modify this pr, also include something like:
127.0.0.1:6379 (MULTI)[5]>
not sure the format looks ok to you, besides the db number, we can also show in a transaction state, how do you think? thanks!

@oranagra
Copy link
Member

seems right to me. i'd like to see what @itamarhaber thinks.
(about showing the multi-state in redis-cli with the above mentioned format)

@itamarhaber
Copy link
Member

i think redis-cli needs to track the selected database on it's own.

Agreed.

can modify this pr, also include something like: 127.0.0.1:6379 (MULTI)[5]>

Totally - a MULTI indicator would be awesome. I think that dbnum should precede it though, and for the sake of brevity I'd use something like:

hostip:port[dbnum]TX>

@hwware
Copy link
Contributor Author

hwware commented Dec 12, 2020

Thanks @oranagra @itamarhaber , based on the conversion please review my new changes of this PR, thanks!

Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

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

@itamarhaber since the db number is only shown (with brackets) when !=0, then showing the TX without any brackets will make it look odd with DB 0. (i.e. 127.0.0.1TX)
i suggest adding back the parenthesis.

@hwware
Copy link
Contributor Author

hwware commented Dec 12, 2020

thanks @oranagra @itamarhaber , pr updated based on the suggestions..

Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

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

@itamarhaber can i merge this?

@oranagra oranagra added the state:to-be-merged The PR should be merged soon, even if not yet ready, this is used so that it won't be forgotten label Dec 13, 2020
@itamarhaber
Copy link
Member

@Oran be my guest, please do.

@oranagra oranagra merged commit f74c32c into redis:unstable Dec 13, 2020
JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:to-be-merged The PR should be merged soon, even if not yet ready, this is used so that it won't be forgotten

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redis Cli db number mismatches when wrapping select db command in MULTI

3 participants