Hi, I am using ubuntu 20.04.1 LTS (Focal Fossa) and I installed a redis server from official repo using apt install redis.
My question is" why redis-server is a symbolic link of redis-check-rdb ", anybody can answer this? I googled it and have no luck, thank you for any help.
I post the basic info as follows:
guodong@lu18:~$ /usr/bin/redis-server -v
Redis server v=5.0.7 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=636cde3b5c7a3923
guodong@lu18:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
guodong@lu18:~$ uname -a
Linux lu18 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
guodong@lu18:~$ which redis-server
/usr/bin/redis-server
guodong@lu18:~$ ls -al /usr/bin/redis-server
lrwxrwxrwx 1 root root 15 Feb 8 2020 /usr/bin/redis-server -> redis-check-rdb
guodong@lu18:~$
guodong@lu18:~$ ps -ef|grep redis
redis 1275 1 0 Aug11 ? 00:19:22 /usr/bin/redis-server 127.0.0.1:6379
guodong 1382582 1369183 0 09:58 pts/1 00:00:00 grep --color=auto redis
Comment From: DingGuodong
I found this in http://metadata.ftp-master.debian.org/changelogs/main/r/redis/unstable_changelog
redis (3:3.2.8-3) unstable; urgency=medium
* Revert the creation of the redis-tools:/usr/bin/redis-check-rdb ->
redis-server:/usr/bin/redis-server symlink to avoid a dangling symlink if
only the redis-tools binary package is installed.
This was a regression since 3:3.2.6-3 where we attempted to avoid shipping
duplicate file; the redis-server binary changes behaviour based on the
contents of argv.
One alternative would be to ship a symlink in redis-server but that would
mean users wishing to check RDB databases would have to install the server
package, so reverting to shipping a duplicate file seems justified.
(Closes: #858519)
-- Chris Lamb <lamby@debian.org> Thu, 23 Mar 2017 12:00:22 +0000
Is this the answer we want?
Comment From: oranagra
the redis-server main() function has the following code:
/* Check if we need to start in redis-check-rdb/aof mode. We just execute
* the program main. However the program is part of the Redis executable
* so that we can easily execute an RDB check on loading errors. */
if (strstr(argv[0],"redis-check-rdb") != NULL)
redis_check_rdb_main(argc,argv,NULL);
else if (strstr(argv[0],"redis-check-aof") != NULL)
redis_check_aof_main(argc,argv);
this is done because much of the code on these is shared code (i.e rdb parsing is used in both redis-server and redis-check-rdb), so it is enough to keep just one binary on the disk, and it'll do the right thing according to its name.
Comment From: itamarhaber
@oran - actually, I believe symlinking is an optimization adopted by downstream (e.g. debian & docker). The core project actually makes real duplicate binaries, which is addressed by #5745. Do you see any reason not to accept that PR?
Comment From: oranagra
odd, i remembered we had symlinks too. i'll look at the PR.
Comment From: DingGuodong
This's a question that generally makes users wonder why this was done, including me, and although I've since figured out why it was achieved this way, I actually remain skeptical that it was really necessary.