srcache & redis_pass get request invalid argument question
Hi all,
I am attempting to make a request to Redis via Twemproxy via nginx using the modules srcache, ngx_http_redis-0.3.8 and redis2-nginx-module.
For the purposes of this test, I am using the default advised configuration for Redis in nginx for use with srcache, I can provide this if it is needed.
The set command executes fine, and correctly stores the data and sets the expire, however the get request part fails.
When the request is made, using the nutcracker debug logs I can see the following error segment: (logs are cut for brevity)
Twemproxy version nutcracker-0.4.1-1.x86_64 being used, on CentOS 7.
[2018-05-18 11:35:50.836] nc_epoll.c:254 epoll 0001 triggered on conn 0x683da0
[2018-05-18 11:35:50.836] nc_core.c:324 event 00FF on c 14
[2018-05-18 11:35:50.836] nc_util.c:235 malloc(32) at 0x683d50 @ nc_array.c:29
[2018-05-18 11:35:50.836] nc_util.c:235 malloc(16) at 0x683d80 @ nc_array.c:34
[2018-05-18 11:35:50.836] nc_message.c:320 get msg 0x683bf0 id 11 request 1 owner sd 14
[2018-05-18 11:35:50.836] nc_mbuf.c:99 get mbuf 0x68de20
[2018-05-18 11:35:50.836] nc_mbuf.c:182 insert mbuf 0x68de20 len 0
[2018-05-18 11:35:50.836] nc_connection.c:346 recv on sd 14 48 of 16336
[2018-05-18 11:35:50.836] nc_redis.c:1694 parsed bad req 11 res 1 type 0 state 0
00000000 73 65 6c 65 63 74 20 30 0d 0a 67 65 74 20 36 36 |select 0..get 66|
00000010 36 36 63 64 37 36 66 39 36 39 35 36 34 36 39 65 |66cd76f96956469e|
00000020 37 62 65 33 39 64 37 35 30 63 63 37 64 39 0d 0a |7be39d750cc7d9..|
[2018-05-18 11:35:50.836] nc_core.c:198 recv on c 14 failed: Invalid argument
[2018-05-18 11:35:50.836] nc_core.c:237 close c 14 'x.x.x.x:52462' on event 00FF eof 0 done 0 rb 1520 sb 9: Invalid argument
where [2018-05-18 11:35:50.836] nc_core.c:237 close c 14 'x.x.x.x:52462' on event 00FF eof 0 done 0 rb 1520 sb 9: Invalid argument is the most intriguing.
Now, in the request body I realised that redis_pass appeared to be sending "select 0" also, which I know is not supported by Twemproxy, so after much testing with twemproxy, I decided to remove the section of the module which passes this (running the get 66cd76f96956469e7be39d750cc7d9 manually via redis-cli succeeds).
Upon removing the section in the nginx module ngx_http_redis_module.c the select no longer is sent, however I am now getting the following:
[2018-05-21 13:19:54.602] nc_epoll.c:254 epoll 0001 triggered on conn 0x1d11640
[2018-05-21 13:19:54.602] nc_core.c:324 event 00FF on c 13
[2018-05-21 13:19:54.602] nc_util.c:235 malloc(32) at 0x1d19da0 @ nc_array.c:29
[2018-05-21 13:19:54.602] nc_util.c:235 malloc(16) at 0x1d19dd0 @ nc_array.c:34
[2018-05-21 13:19:54.602] nc_message.c:320 get msg 0x1d19c40 id 12 request 1 owner sd 13
[2018-05-21 13:19:54.602] nc_mbuf.c:99 get mbuf 0x1d23e50
[2018-05-21 13:19:54.602] nc_mbuf.c:182 insert mbuf 0x1d23e50 len 0
[2018-05-21 13:19:54.602] nc_connection.c:346 recv on sd 13 38 of 16336
[2018-05-21 13:19:54.602] nc_redis.c:1694 parsed bad req 12 res 1 type 0 state 0
00000000 67 65 74 20 36 36 36 36 63 64 37 36 66 39 36 39 |get 6666cd76f969|
00000010 35 36 34 36 39 65 37 62 65 33 39 64 37 35 30 63 |56469e7be39d750c|
00000020 63 37 64 39 0d 0a |c7d9..|
[2018-05-21 13:19:54.602] nc_core.c:198 recv on c 13 failed: Invalid argument
[2018-05-21 13:19:54.602] nc_core.c:237 close c 13 'x.x.x.x:41642' on event 00FF eof 0 done 0 rb 1510 sb 9: Invalid argument
I can supply more information if needed, however, I am mostly curious as to what argument is invalid as it is a relatively straight forward command that needs to be executed.
Twemproxy is running nutcracker -d -c /etc/nutcracker/nutcracker.yml -v 11 -o /var/log/nutcracker/nutcracker.log verbosity 11 for this output.
And the Twemproxy configuration being used is as follows:
staging1:
listen: x.x.x.17:22121
hash: fnv1a_64
distribution: modula
preconnect: true
auto_eject_hosts: false
redis: true
backlog: 512
server_retry_timeout: 2000
server_failure_limit: 2
servers:
- x.x.x.6:6379:1
- x.x.x.7:6379:1
- x.x.x.8:6379:1
- x.x.x.9:6379:1
- x.x.x.10:6379:1
The error message presented by nginx is simply:
2018/05/21 13:24:57 [error] 3790#3790: *1 upstream prematurely closed connection while reading response header from upstream, client: x.x.x.x, server: 001.xxx.com, request: "GET / HTTP/1.1", subrequest: "/redis", upstream: "redis://x.x.x.17:22121", host: "001.xxx.com"
Any advice on how to proceed to debug/resolve this issue would be greatly appreciated!
Hi @met3or, found solutions for this problem?
*2
$3
get
$3
key
A redis request to get a key would look like this in the redis protocol
[2018-05-21 13:19:54.602] nc_redis.c:1694 parsed bad req 12 res 1 type 0 state 0
00000000 67 65 74 20 36 36 36 36 63 64 37 36 66 39 36 39 |get 6666cd76f969|
00000010 35 36 34 36 39 65 37 62 65 33 39 64 37 35 30 63 |56469e7be39d750c|
00000020 63 37 64 39 0d 0a |c7d9..|
But what you're sending to twemproxy would be a valid memcached command and an invalid redis command - get key\r\n is a memcache request to twemproxy on that port - see https://github.com/twitter/twemproxy/blob/master/notes/memcache.md and redis.md