sewenew/redis-plus-plus

[QUESTION] Assertion error when getting started with Redis-plus-plus

srgorti opened this issue · 5 comments

Before starting to use Redis-plus-plus in application, I started trying it out with one of the example programs and ran into the assertion described below. Since the use-case requires RedisCluster, started directly with RedisCluster.

First, I setup a local Redis cluster using the default create-cluster utility. Then, after having built Redis++, ran test_redis++ -n 127.0.0.1 -c 30001, which ran all tests and ended with Pass all tests.
Next, took this example snippet from ReadMe. The only change I made was to modify Redis port number to 30001. Then, built it with the same hiredis and redis++ libraries (used static libraries). When running this toy example, the program is always hitting this error:

rpp-ex1: ./include/sw/redis++/connection_pool.h:123: sw::redis::SafeConnection::SafeConnection(sw::redis::ConnectionPool&): Assertion !_connection.broken()' failed.`

I have tried it multiple times and debugged by dumping all socket read/writes in hiredis. From this, I see that the "CLUSTER SLOTS" and even the SET commands are going thru. But, the issue always happen before redis_cluster.mget({"key{tag}1", "key{tag}2", "key{tag}3"}.

My environment is the following:

  • Redis - version 6.2.13
  • AmazonLinux on EC2.
  • Compiler: gcc version 7.3.1 (using C++11)
  • hiredis version: v1.0.0
  • redis-plus-plus version: 1.3.3

Then, I tried the same with the getting started example and just retained till the first redis.lpush but was still seeing the same assertion failure.
rpp-ex2: ./include/sw/redis++/connection_pool.h:123: sw::redis::SafeConnection::SafeConnection(sw::redis::ConnectionPool&): Assertion !_connection.broken()' failed.`

Perhaps I am making some silly error or missing something in the docs, even after reviewing them. Any pointers/suggestions would be most helpful.

You redis-plus-plus version is too old. Please update to the latest version to have a try.

Also please check if you install multiple hiredis version? In that case, you might get some wired problem.

Regards

Thanks a lot for the quick inputs.

Upgraded to redis-plus-plus version: 1.3.10

Also, to avoid the problem of multiple hiredis libraries, am linking statically.

/usr/bin/g++ -I./include -I./redis++/include -std=gnu++11 -c -o rpp_cluster_example.o rpp_cluster_example.cpp /usr/bin/g++ -std=gnu++11 -lm -Wl,--whole-archive ./redis++/lib64/libredis++.a -Wl,--whole-archive ./libhiredis.a rpp_cluster_example.o -Wl,--no-whole-archive -lpthread -o rpp-ex1

Still seeing the same assertion:
rpp-ex1: ./redis++/include/sw/redis++/connection_pool.h:122: sw::redis::SafeConnection::SafeConnection(sw::redis::ConnectionPool&): Assertion!_connection.broken()' failed.
`

Any suggestions ? Meanwhile, I will try by upgrading hiredis version.

Thanks.

After moving to hiredis-1.1.0, not seeing the assertion from the test program !! So, looks like the combo of: hiredis-1.1.0 and redis-plus-plus 1.3.10 is a safe pair to prototype with our application.

Tested with redis-6.2.13 and confirmed with MONITOR that commands are being received and processed.

I cannot reproduce your problem with the (hiredis and redis-plus-plus) versions you given.

Anyway, I'm glad that you worked around this problem.

I'll close this issue. If you have any other problems, feel free to let me know.

Regards