When a long unixsocket path is passed in, linux will truncate it, but redis uses the full path.

$ strace redis-server --port 0 --unixsocket /tmp/redis/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/redis.socket
...
unlink("/tmp/redis/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/redis.socket") = -1 ENOENT (No such file or directory)
socket(AF_LOCAL, SOCK_STREAM, 0)        = 4
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(4, {sa_family=AF_LOCAL, sun_path="/tmp/redis/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/redis."}, 110) = 0
...

Above you can see, that redis is unlinking the full path (ending in /redis.socket) and the bind happens on the cut off path (/redis.). This is happening because the struct defined here has a max length of 108.

postgres has coded around this issue like by adding a check and throwing (ref, ref)

Can a similar check be added to redis?

Tested with:

redis-server -v
Redis server v=3.0.5 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=a02f0957c1e82329

Comment From: shenlongxing

@mlucool You are right and i opened a PR to fix this.

Comment From: oranagra

handled by https://github.com/redis/redis/pull/9826