twitter / twemproxy

A fast, light-weight proxy for memcached and redis
Apache License 2.0
12.13k stars 2.06k forks source link

Twemproxy + jedis. pipeline command is not work #451

Open codej99 opened 8 years ago

codej99 commented 8 years ago

Hi. I am currently studying a "Spring OAuth2". I was implemented Oauth TokenStore using the "Twemproxy" and "Redis". Redis TokenStore provided by the Spring Oauth is implemented by pipeline.

I was tested in the following environments

RedisConnection conn = jedisConnectionFactory.getConnection(); conn.openPipeline(); conn.set("accessKey".getBytes(),"AccessTokenValue".getBytes()); conn.set("authKey".getBytes(), "AuthValue".getBytes()); conn.expire("accessKey".getBytes(), 100); conn.expire("authKey".getBytes(), 200); conn.closePipeline(); conn.close();

work fine. Twemproxy Log below

[2016-02-05 09:54:18.201] nc_request.c:96 req 10 done on c 19 req_time 0.140 msec type REQ_REDIS_SET narg 3 req_len 51 rsp_len 5 key0 'accessKey' peer '10.77.164.82:65002' done 1 error 0 [2016-02-05 09:54:18.201] nc_request.c:96 req 11 done on c 19 req_time 0.144 msec type REQ_REDIS_SET narg 3 req_len 47 rsp_len 5 key0 'authKey' peer '10.77.164.82:65002' done 1 error 0 [2016-02-05 09:54:18.201] nc_request.c:96 req 12 done on c 19 req_time 0.123 msec type REQ_REDIS_EXPIRE narg 3 req_len 40 rsp_len 4 key0 'accessKey' peer '10.77.164.82:65002' done 1 error 0 [2016-02-05 09:54:18.201] nc_request.c:96 req 13 done on c 19 req_time 0.116 msec type REQ_REDIS_EXPIRE narg 3 req_len 38 rsp_len 4 key0 'authKey' peer '10.77.164.82:65002' done 1 error 0

set command excuted But expire command not excuted

127.0.0.1:6380> keys * 1) "accessKey" 2) "authKey" 127.0.0.1:6380> ttl "accessKey" (integer) -1 127.0.0.1:6380> ttl "authKey" (integer) -1


I was ReTested Not Use Twemproxy, Only Use Redis + Jedis

RedisConnection conn = jedisConnectionFactory.getConnection(); conn.openPipeline(); conn.set("accessKey".getBytes(),"AccessTokenValue".getBytes()); conn.set("authKey".getBytes(), "AuthValue".getBytes()); conn.expire("accessKey".getBytes(), 100); conn.expire("authKey".getBytes(), 200); conn.closePipeline(); conn.close();

All Work Fine.

127.0.0.1:6379> keys * 1) "authKey" 2) "accessKey" 127.0.0.1:6379> ttl "authKey" (integer) 194 127.0.0.1:6379> ttl "accessKey" (integer) 80


I was Re Re Tested Use Twemproxy + Redis + Jedis, But pipeline command devided...


RedisConnection conn = jedisConnectionFactory.getConnection();

conn.openPipeline(); conn.set("accessKey".getBytes(),"AccessTokenValue".getBytes()); conn.set("authKey".getBytes(), "AuthValue".getBytes()); conn.closePipeline();

conn.openPipeline(); conn.expire("accessKey".getBytes(), 100); conn.expire("authKey".getBytes(), 200); conn.closePipeline();

conn.close();

Twemproxy Log below

[2016-02-05 10:18:47.196] nc_request.c:96 req 46 done on c 46 req_time 0.090 msec type REQ_REDIS_SET narg 3 req_len 51 rsp_len 5 key0 'accessKey' peer '10.77.164.82:65349' done 1 error 0 [2016-02-05 10:18:47.196] nc_request.c:96 req 47 done on c 46 req_time 0.094 msec type REQ_REDIS_SET narg 3 req_len 47 rsp_len 5 key0 'authKey' peer '10.77.164.82:65349' done 1 error 0 [2016-02-05 10:18:47.207] nc_server.c:539 connected on s 58 to server '127.0.0.1:6380:1' [2016-02-05 10:18:47.207] nc_server.c:539 connected on s 57 to server '127.0.0.1:6380:1' [2016-02-05 10:18:47.207] nc_request.c:96 req 50 done on c 46 req_time 0.071 msec type REQ_REDIS_EXPIRE narg 3 req_len 40 rsp_len 4 key0 'accessKey' peer '10.77.164.82:65349' done 1 error 0 [2016-02-05 10:18:47.207] nc_request.c:96 req 51 done on c 46 req_time 0.076 msec type REQ_REDIS_EXPIRE narg 3 req_len 38 rsp_len 4 key0 'authKey' peer '10.77.164.82:65349' done 1 error 0

All Work fine.

127.0.0.1:6380> keys * 1) "accessKey" 2) "authKey" 127.0.0.1:6380> ttl "accessKey" (integer) 90 127.0.0.1:6380> ttl "authKey" (integer) 186

I don't know problem of the Jedis or problem of the Twemproxy

Can you help me?

Thanks.

charsyam commented 8 years ago

@codej99 could you upload your test code? In my case, I just test it with redis-py. I works well. and Could you upload your configuration file?

Aditya-Chowdhry commented 8 years ago

Hi any resolution to the above issue. ? Getting the same problem with node-redis client and twemproxy. Expire is not getting setup but in logs it showing that done 1 error 0