Describe the bug
Alpine Linux runs the test suite as part of the build process.
Unfortunately the newly introduced "Process title set as expected" test fails.
[ok]: Test RDB stream encoding - sanitize dump
[err]: Process title set as expected in tests/unit/other.tcl
Expected 'TEST' to be equal to 'src/redis-server./tests/tmp/redis.conf.1107.10' (context: type eval line 10 cmd {assert_equal "TEST" [lindex $cmdline 0]} proc ::test)
[18/62 done]: unit/other (21 seconds)
Testing integration/corrupt-dump
[ok]: Server should not start if RDB file can't be open
Log from CI https://gitlab.alpinelinux.org/TBK/aports/-/jobs/330424#L1433
To reproduce
- setup dabuild (https://gitlab.alpinelinux.org/alpine/docker-abuild/)
git clone -b main/redis https://gitlab.alpinelinux.org/tbk/aportscd aports/main/redisdabuild -r
Expected behavior
Test to pass.
Additional information
redis.conf.1107.10
always-show-logo yes
notify-keyspace-events KEA
daemonize no
pidfile /var/run/redis.pid
port 23115
timeout 0
bind 127.0.0.1
loglevel verbose
logfile ''
databases 16
latency-monitor-threshold 1
save 60 10000
rdbcompression yes
dbfilename dump.rdb
dir ./tests/tmp/server.1107.9
slave-serve-stale-data yes
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
activerehashing yes
unixsocket /home/builder/aports/main/redis/src/redis-6.2.0/tests/tmp/server.1107.9/socket
server.1107.9 stdout:
### Starting server for test
2262:C 22 Feb 2021 23:31:47.444 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2262:C 22 Feb 2021 23:31:47.445 # Redis version=6.2.0, bits=64, commit=21e2f218, modified=1, pid=2262, just started
2262:C 22 Feb 2021 23:31:47.445 # Configuration loaded
2262:M 22 Feb 2021 23:31:47.446 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.2.0 (21e2f218/1) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 23115
| `-._ `._ / _.-' | PID: 2262
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
2262:M 22 Feb 2021 23:31:47.453 # Server initialized
2262:M 22 Feb 2021 23:31:47.453 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
2262:M 22 Feb 2021 23:31:47.453 * Ready to accept connections
2262:M 22 Feb 2021 23:31:47.453 * The server is now ready to accept connections at /home/builder/aports/main/redis/src/redis-6.2.0/tests/tmp/server.1107.9/socket
2262:M 22 Feb 2021 23:31:47.494 - Accepted 127.0.0.1:36749
2262:M 22 Feb 2021 23:31:47.495 - Client closed connection
2262:M 22 Feb 2021 23:31:47.535 - Accepted 127.0.0.1:44035
### Starting test Process title set as expected in tests/unit/other.tcl
2262:signal-handler (1614036707) Received SIGTERM scheduling shutdown...
2262:M 22 Feb 2021 23:31:47.654 # User requested shutdown...
2262:M 22 Feb 2021 23:31:47.654 * Saving the final RDB snapshot before exiting.
2262:M 22 Feb 2021 23:31:47.657 * DB saved on disk
2262:M 22 Feb 2021 23:31:47.657 * Removing the pid file.
2262:M 22 Feb 2021 23:31:47.657 * Removing the unix socket file.
2262:M 22 Feb 2021 23:31:47.657 # Redis is now ready to exit, bye bye...
Comment From: madolson
@TBK Thanks for reporting this. Do you know if anything about this code would fail specifically for alpine linux? https://github.com/redis/redis/blob/ec02c761aa16175eb599b2fc9d0b2792ffe8a66c/src/setproctitle.c#L275
I'm trying to launch an alpine linux now to see if I can debug further what is going on. It's not great we aren't error'ing out.
Comment From: madolson
It looks like this code relies on glibc to be present, which afaik alpine linux does not use, so we just fail at updating the process title but don't throw any type of error. I think we should update the code to be more portable across libc versions. We could probably do something temporarily to get this passing as well.
Comment From: yossigo
Looks like there are other alpine issues as well and AFAIR it's not the first time we come across libmusl compatibility issues. I'll add a daily job for it.
Comment From: TBK
Thanks for the quick response and solution :+1:
We have one additional patch to be able to use musl's malloc.
--- a/src/zmalloc.h
+++ b/src/zmalloc.h
@@ -63,12 +63,10 @@
#ifndef ZMALLOC_LIB
#define ZMALLOC_LIB "libc"
-#ifdef __GLIBC__
#include <malloc.h>
#define HAVE_MALLOC_SIZE 1
#define zmalloc_size(p) malloc_usable_size(p)
#endif
-#endif
/* We can enable the Redis defrag capabilities only if we are using Jemalloc
* and the version used is our special version modified for Redis having
Trying to compile with MALLOC=libc without the change will result in this error:
zmalloc.c:55:28: error: missing binary operator before token "("
#define PREFIX_SIZE (sizeof(size_t))
^
zmalloc.c:59:5: note: in expansion of macro 'PREFIX_SIZE'
#if PREFIX_SIZE > 0
Comment From: yossigo
@TBK We can't assume malloc_usable_size() is available on all systems.
Is there some canonical define that can be used to detect libmusl? Also, do all reasonably recent versions of libmusl support malloc_usable_size()?
Comment From: yossigo
@TBK By the way the above patch should no longer be necessary on unstable, but please confirm.