Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
sentinel reconnect problem, and the high availability example failed #39
Comments
|
Hi, @neo1986 This issue is not a problem, This is a specification. Checkout this code and comment: https://github.com/cpp-redis/cpp_redis/blob/master/examples/cpp_redis_high_availability_client.cpp#L34-L35 So, the its default tcp library tacopie threadpool spec. see:
These variable values( |
I found that
const std::shared_ptr<io_service>&
get_default_io_service(std::uint32_t num_io_workers) {
if (io_service_default_instance == nullptr) {
io_service_default_instance = std::make_shared<io_service>(num_io_workers);
}
else {
//this code reset thread_pool to 1
//io_service_default_instance->set_nb_workers(num_io_workers);
}
return io_service_default_instance;
} |
Using the example of cpp_redis_high_availability_client
Here is my docker-compose file and redis.conf:
docker-compose file:
redis-sentinel.conf:
redis-master.conf:
port 8000redis-slave1.conf:
redis-slave2.conf
In the code, If I disable cpp_redis::network::set_default_nb_workers(2);, it will work then I stop the master, it won't try to reconnect the sentinel's new master and the programmer blocked and do nothing.
if the cpp_redis::network::set_default_nb_workers(2); enabled, it will do nothing but block on the connect function
cpp-redis is quite great and I think will replace the hiredis sooner or later, please take a look at this issue.
the code is running on win with VS2015 and I installed the cpp-redis with vcpkg.
please take a look at this issue, thanks a lot