fred.rs icon indicating copy to clipboard operation
fred.rs copied to clipboard

Ping fails with SubscriberClient

Open tugtugtug opened this issue 1 year ago • 1 comments

Ping seems to be failing with the SubscriberClient consistently with an error: "Could not convert multiple frames to RedisValue". The stack seems to show the response is parsed as resp3, but the server AFAIK only supports resp2.

Environment:

redis_version:5.0.7 (Seems to fail the same with latest 7.0) fred.rs: 5.1.0

Logs:

2022-08-28 02:11:57.234867 [00d] [D] [connection]:0287 fred-JeHtXwyITZ: Read client ID: Resp2(Integer(82)) 2022-08-28 02:12:57.236755 [00c] [D] [utils ]:0400 fred-JeHtXwyITZ: Writing command PING to localhost:6379 2022-08-28 02:12:57.237310 [00a] [D] [server ]:0094 fred-JeHtXwyITZ: Recv ping response.

Stack:

  * frame #0: 0x00005555562aaa94 test`fred::protocol::utils::frame_to_single_result(frame=redis_protocol::resp3::types::Frame::Array @ 0x00007ffff649ede0) at utils.rs:547:20
    frame #1: 0x000055555582dfb9 test`fred::commands::impls::server::ping::{{closure}}((null)=core::future::ResumeTy @ 0x00007ffff649efc8) at server.rs:95:3
    frame #2: 0x0000555555a7e497 test`<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll(self=core::pin::Pin<&mut core::future::from_generator::GenFuture<fred::commands::impls::server::ping::{async_fn_env#0}>> @ 0x00007ffff649f460, cx=0x00007ffff64a93d0) at mod.rs:91:19
    frame #3: 0x00005555558197d9 test`fred::interfaces::ClientLike::ping::{{closure}}::{{closure}}((null)=core::future::ResumeTy @ 0x00007ffff64a2948) at interfaces.rs:256:58

Data:

print frame
(redis_protocol::resp3::types::Frame::Array) frame = {
  data = (2) vec![{...}, {...}] {}
  attributes = None {}
}

print frame.data.0
(alloc::raw_vec::RawVec<redis_protocol::resp3::types::Frame, alloc::alloc::Global>) buf = {
  ptr = {
    pointer = {}
    _marker = {}
  }
  cap = 2
  alloc = {}
}

tugtugtug avatar Aug 28 '22 02:08 tugtugtug

Thanks for the comprehensive bug report @tugtugtug. I'll take a look at this in the next week or so.

aembke avatar Sep 01 '22 14:09 aembke

I am not sure, but I think it's not possible to call PING in the connection that is already subscribed to some channel.

mkurtak avatar Sep 26 '22 08:09 mkurtak

I am not sure, but I think it's not possible to call PING in the connection that is already subscribed to some channel.

that is perfectly fine with redis itself, please read redis documentation here, and I quote,

The commands that are allowed in the context of a subscribed client are [SUBSCRIBE](https://redis.io/commands/subscribe), [SSUBSCRIBE](https://redis.io/commands/ssubscribe), [SUNSUBSCRIBE](https://redis.io/commands/sunsubscribe), [PSUBSCRIBE](https://redis.io/commands/psubscribe), [UNSUBSCRIBE](https://redis.io/commands/unsubscribe), [PUNSUBSCRIBE](https://redis.io/commands/punsubscribe), [PING](https://redis.io/commands/ping), [RESET](https://redis.io/commands/reset), and [QUIT](https://redis.io/commands/quit).

tugtugtug avatar Sep 26 '22 14:09 tugtugtug

@tugtugtug you are right. I missed that, sorry.

mkurtak avatar Sep 26 '22 15:09 mkurtak