-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
BRPOP... 0 (and similar) now timeout after connection timeout rather than block #722
Comments
BRPOP <x> 0
(and similar) now timeout after connection timeout rather than block
Reproducing code: $ cat Makefile
$ cat blocker.c
(in another shell...) $ docker run -p 6379:6379 redis
You can see the BLPOP has not blocked. If you now edit
... Which hangs indefinitely - the expected behaviour |
Deleted previous message because it wasn't that commit. I think the relevant commit is 4830786. You can get what you want by using #include <stdio.h>
#include <stdlib.h>
#include "hiredis/hiredis.h"
int main(int argc, char **argv) {
redisContext *rc = NULL;
struct timeval redis_timeout = { 1, 500000 }; // 1.5 seconds
redisReply *reply;
rc = redisConnectWithTimeout("localhost", 6379, redis_timeout);
if (rc == NULL || rc->err) {
if (rc) {
printf("Redis connection error: %s\n", rc->errstr);
redisFree(rc);
} else {
printf("Redis connection error: can't allocate redis context\n");
}
exit(1);
}
/* Use an unlimited read timeout if we've been passed an argument */
if (argc > 1) {
struct timeval tm = {.tv_sec = 0, .tv_usec = 0};
redisSetTimeout(rc, tm);
}
reply = redisCommand(rc, "BRPOP tokens 0");
if (rc->err) {
printf("Connection error on wakeup: %s\n", rc->errstr);
exit(1);
}
freeReplyObject(reply);
printf("finished\n");
} |
I agree on the bisect. Thanks for a workaround.
|
I think it is fair to say this is a substantial breaking change to your public API, and the various higher language API wrappers would need to address this. |
Fortunately many of the hiredis wrappers vendor the library so those would be unaffected. Agree it's a breaking change, but we're able to do that if this and other changes are released as 1.0. |
I'm going to close this issue as we're about to release v1.0.0 and can break things 😄 |
I have a c program that does a blocking pop from a redis list to retrieve work. In order to prevent long connection timeouts, I set a connection timeout.
Using hiredis
master
, theConnection error on wakeup
fires after 1.5s.If I wanted an operation timeout, i would use a non-zero final argument to BRPOP
If I build this against v14, it blocks until the server has an item pushed into the list.
From a quick review of master I think this is a regression with the new SSL support, although I will need to bisect it to be sure.
The text was updated successfully, but these errors were encountered: