cpp-redis / cpp_redis

C++11 Lightweight Redis client: async, thread-safe, no dependency, pipelining, multi-platform
MIT License
720 stars 199 forks source link

How to find out sync timed out or a success return #21

Closed rayyar closed 4 years ago

rayyar commented 5 years ago

After I call redis_client->sync_commit(std::chrono::milliseconds(2000), how can I check if the return is a success or is timeout. I tried research on net, could not find the info.

Also if it is time out, how can I flush or clear callbacks so the logic is not processed late.

I am seeing timeout in the logic, as my data is not set from the reply, the processes continues. But little later the "reply" comes and while setting the data I get a core.

At a high level search my issue looked closer to "cpp_redis::client causes program to crash #156"

appkins commented 5 years ago

Hi, I checked out the linked issue in Simon's repo. There are a few speculations on what might cause this in that thread.

  1. Are you running this in Docker? If so, are you compiling and running in the same environment?
  2. Are you using tacopie as the TCP client?
  3. Are you checking the reply for is_null in the callback? The logic is contained

To answer some of your questions:

how can I flush or clear callbacks

redis_client->clear_callbacks();

how can I check if the return is a success or is timeout

If the reply from redis was an error, you can use reply.is_error() If the reply was not set (timeout), you can use reply.is_null()

fooSynaptic commented 4 years ago

redis_client->sync_commit(std::chrono::milliseconds(2000) compile success but got runtime error result to abort, someone see this issue before?