Skip to content

Fix redis-cli show push messages before next command.#9694

Closed
huangzhw wants to merge 1 commit intoredis:unstablefrom
huangzhw:hiredis-push
Closed

Fix redis-cli show push messages before next command.#9694
huangzhw wants to merge 1 commit intoredis:unstablefrom
huangzhw:hiredis-push

Conversation

@huangzhw
Copy link
Contributor

@huangzhw huangzhw commented Oct 28, 2021

Now invalidation messages are always after command replies. But hiredis
only handles invalidation messages before replies. redis-cli will
display output wrong. This commit do a best-efforts fix to it. After
reply, we check buffer to see whether there are invalidation messages.

127.0.0.1:6383> client tracking on
OK
127.0.0.1:6383> get hello
"1"
127.0.0.1:6383> set hello world
OK
127.0.0.1:6383> get hello
1) "invalidate"
2) 1) "hello"
127.0.0.1:6383> a
"world"

fix #8923

Now invalidation messages are always after command replies. But hiredis
only handles invalidation messages before replies. redis-cli will
display output wrong. This commit do a best-efforts fix to it. After
reply, we check buffer to see whether there are invalidation messages.
@enjoy-binbin
Copy link
Contributor

I think we can also submit a PR to hiredis repo if this is accepted

@oranagra
Copy link
Member

@michael-grunder please take a look.
@huangzhw can you please edit the top comment to show an example of redis-cli's wrong output?
do you think it's a good idea to add a redis-cli test for it (tests/integration/redis-cli.tcl)

@huangzhw
Copy link
Contributor Author

I'm not sure whether we should add it. In fact this is hiredis codes.

@michael-grunder
Copy link
Contributor

Hi @oranagra and @huangzhw,

This behavior was fixed for hiredis in these commits, although not specifically for handling in redis-cli. The changes to hiredis made the assumption that we could get a PUSH reply at any time (as long as they were not embedded in other replies).

The hiredis changes also appear to correct the redis-cli issue:

❯ src/redis-cli -3
127.0.0.1:6379> client tracking on
OK
127.0.0.1:6379> get hello
"1"
127.0.0.1:6379> set hello world
-> invalidate: 'hello'
OK
127.0.0.1:6379> get hello
"world"
127.0.0.1:6379>

If it's preferable to use this logic in hiredis instead that's OK with me too. I can go through it in detail to make sure we don't change any API behavior.

@oranagra
Copy link
Member

Is there a hiredis release we should upgrade to, or a planned one? I rather not cherry pick commits or make local changes.

@michael-grunder
Copy link
Contributor

The newest version of hiredis v1.0.2 simply has the CVE overflow fix, but I think there have been enough new features to warrant a hiredis release, which I'm happy to put together.

That said, it's probably worth letting that live in the wild for a while before integrating it back into Redis proper.

@oranagra
Copy link
Member

Redis 7.0 RC1 is planned for the end of the year, let's aim there for a new hiredis too?

@michael-grunder
Copy link
Contributor

Sure, that works for me.

@oranagra
Copy link
Member

created #9706, closing this one.

@oranagra oranagra closed this Oct 31, 2021
@huangzhw huangzhw deleted the hiredis-push branch October 31, 2021 08:24
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.

redis-cli delays reading data

4 participants