-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to enable to selection of clustered or non clustered when I bootup my program #170
Comments
@ShadowKai The code looks good to me. It might be some problem elsewhere. I suggest you writing a simple test that only contains the definition of
Regards |
@sewenew I added try catch exceptions when i create Redis and RedisCluster object, it doesn't show anything when I start it. This is my coredump log: |
@ShadowKai As I mentioned above, you'd better give me a simple test code, i.e. only have redis-plus-plus related code, that can reproduce the problem. Otherwise, the problem might be some elsewhere. Regards |
I got the similar problem about core dump. Did you find a solution for it? @ShadowKai |
@Sharonlalala Can you give me the code that can reproduce your problem? And what's your version of hiredis and redis-plus-plus? Also please check if you installed multiple hiredis versions? Thanks! Regrads |
@Sharonlalala Did you enable TLS support when installing redis++, while you didn’t enable TLS support when installing hiredis? Please check the doc to enable both or neither. |
|
@Sharonlalala Since you enabled TLS support, you also need to link libhiredis_ssl.a, -lssl and -lcrypto:
Please check the doc for detail. |
Thank you so much for your help! @sewenew It can run now! The only problem is when I use cluster with setting more than 5MB value, the cluster will down. Do you know why that happened? I got same problem when using benchmark. I've changed each node's maxmemory to 100G. |
@Sharonlalala First of all, you should never try to set a large key, e.g. 5MB, since it might block Redis for a while, and have a huge performance penalty. This seems not a redis-plus-plus problem. Maybe one node is blocking on the large key setting work, and cannot communicate with other nodes in the cluster. So others thought this node is down, and reply with client with CLUSTERDOWN error. You'd better ask a Redis expert to dig into this problem. |
Ok, I got it. Thank you very much! @sewenew |
hi, sorry for the late reply. I was met with a personal emergency. also I have enabled TLS support but am currently not using it for this testcode and I have linked with |
@ShadowKai You code cannot compile. I modified it as follows:
However, I cannot reproduce your problem with the above code. In my test, both Redis and Redis Cluster are alive, and the test can output all results. You can try the above code to test if it fails. Also try to catch possible B.T.W. what's your version of redis-plus-plus and hiredis? |
@sewenew , I tried compiling your code and I get the same issue, which coredumps when trying to execute set on cluster. If I comment out the non cluster, it works correctly. I added the catch (const std::exception &e) and there isn't any exception thrown as well. both Redis server and Redis Cluster are alive. I can connect to both and execute commands using redis-cli. redis-plus-plus version is v1.2.1 |
@ShadowKai Can you try the latest code of redis-plus-plus, i.e. code on master branch or v1.2.2? I fixed a crash problem recently. However, that's a problem on Pipeline or Transaction. If your code doesn't use Pipeline or Transaction, and the Redis instances are always alive, you should not get the problem. Also please check if you installed multiple versions of hiredis. If you do, you need uninstall those extra ones, and only keep one hiredis version installed. Otherwise, you might get some wired problems. If you still have problem with it, can you give me a docker image which can reproduce the problem. So that I can help to debug. |
@sewenew, thanks for your help, it seems to be because i have multiple hiredis installed. |
I'm trying to get my project to run clustered/non-clustered based on a specific configuration when I start the program which the value will be stored into the variable mRedisClusterEnable, the value is not changeable after initialization.
This is how I initialize it, the mMyRedisC and mMyRedis are pointers of their respective classes (RedisCluster and Redis) which I only initialize after checking the value mRedisClusterEnable.
My Initialization:
sw::redis::ConnectionOptions connection_options;
connection_options.host = mRedisServer.mRedisSvrCfg.mRedisIp;
connection_options.port = mRedisServer.mRedisSvrCfg.mRedisPort;
sw::redis::ConnectionPoolOptions pool_options;
pool_options.wait_timeout = std::chrono::milliseconds(100);
pool_options.connection_lifetime = std::chrono::minutes(1);
if (this->mRedisClusterEnable == 1)
{
this->mMyRedisC = new sw::redis::RedisCluster(connection_options, pool_options);
if (this->mMyRedisC == NULL)
return -1;
}
else
{
this->mMyRedis = new sw::redis::Redis(connection_options, pool_options); //<--------- over here
if (this->mMyRedis == NULL)
return -1;
}
my get and set function is as follows:
int MyRedisServer::Set(std::string name, std::string value, int cache_expiry)
{
if (!value.empty() && !name.empty())
{
try
{
if (this->mRedisClusterEnable == 1)
{
if (cache_expiry == 0)
mMyRedisC->set(name.c_str(), value.c_str());
else
mMyRedisC->set(name.c_str(), value.c_str(), std::chrono::milliseconds(cache_expiry1000));
}
else
{
if (cache_expiry == 0)
mMyRedis->set(name.c_str(), value.c_str());
else
mMyRedis->set(name.c_str(), value.c_str(), std::chrono::milliseconds(cache_expiry1000));
}
return 0;
}
catch (const sw::redis::Error &err){}
}
return -1;
}
int MyRedisServer::Get(std::string name, std::string* output) const
{
try
{
if (this->mRedisClusterEnable == 1)
{
auto val = mMyRedisC->get(name.c_str());
if (val)
{
output->assign(*val);
return 0;
}
else
output->assign("");
}
else
{
auto val = mMyRedis->get(name.c_str());
if (val)
{
output->assign(*val);
return 0;
}
else
output->assign("");
}
}
catch (const sw::redis::Error &e) {}
return -1;
}
However when I call the functions Set/Get with mRedisClusterEnable=1 (it's not interchangeable and it's fixed at the start of the program) my program resulted in a coredump. However, when mRedisClusterEnable=0, it has no issue. I tried commenting out the initialize part (this part "//<--------- over here") for the non-clustered when my mRedisClusterEnable=1 and then the coredump no longer occurs and I'm getting the correct output from my Set/Get functions.
This is confusing because when mRedisClusterEnable=1 it shouldn't even go through the non-clustered part so i'm suspecting the issue is somewhere else but I have no idea where to start.
The text was updated successfully, but these errors were encountered: