Skip to content

Commit 65b29a4

Browse files
Add changes to support 9.1 builds (#52)
Signed-off-by: Evgeniy Patlan <evgeniy.patlan@percona.com>
1 parent 2171fe7 commit 65b29a4

14 files changed

Lines changed: 1269 additions & 24 deletions

packaging/9.1/debian/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
valkey (9.1.0-1) unstable; urgency=medium
2+
3+
* Initial build
4+
5+
-- Evgeniy Patlan <evgeniy.patlan@percona.com> Wed, 04 Feb 2025 08:00:00 +0000
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
From: Chris Lamb <lamby@debian.org>
2+
Date: Mon, 28 Apr 2025 15:45:49 -0300
3+
Subject: Fix FTBFS on kFreeBSD
4+
5+
Last-Update: 30-10-2015
6+
---
7+
src/fmacros.h | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/src/fmacros.h b/src/fmacros.h
11+
index c5c8ff4..b256d12 100644
12+
--- a/src/fmacros.h
13+
+++ b/src/fmacros.h
14+
@@ -48,7 +48,7 @@
15+
#define _ALL_SOURCE
16+
#endif
17+
18+
-#if defined(__linux__) || defined(__OpenBSD__)
19+
+#if defined(__linux__) || defined(__OpenBSD__) || defined(__GLIBC__)
20+
#define _XOPEN_SOURCE 700
21+
/*
22+
* On NetBSD, _XOPEN_SOURCE undefines _NETBSD_SOURCE and
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
From: Chris Lamb <lamby@debian.org>
2+
Date: Mon, 28 Apr 2025 15:45:49 -0300
3+
Subject: Add CPPFLAGS to upstream makefiles
4+
5+
Last-Update: 30-01-2026
6+
---
7+
deps/fpconv/Makefile | 2 +-
8+
deps/hdr_histogram/Makefile | 2 +-
9+
deps/linenoise/Makefile | 2 +-
10+
src/Makefile | 2 +-
11+
4 files changed, 4 insertions(+), 4 deletions(-)
12+
13+
diff --git a/deps/fpconv/Makefile b/deps/fpconv/Makefile
14+
index 2654888..64d2ed0 100644
15+
--- a/deps/fpconv/Makefile
16+
+++ b/deps/fpconv/Makefile
17+
@@ -2,7 +2,7 @@ STD=
18+
WARN= -Wall
19+
OPT= -Os
20+
21+
-R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS)
22+
+R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(CPPFLAGS)
23+
R_LDFLAGS= $(LDFLAGS)
24+
DEBUG= -g
25+
26+
diff --git a/deps/hdr_histogram/Makefile b/deps/hdr_histogram/Makefile
27+
index 28dd93e..3a6413e 100644
28+
--- a/deps/hdr_histogram/Makefile
29+
+++ b/deps/hdr_histogram/Makefile
30+
@@ -2,7 +2,7 @@ STD= -std=c99
31+
WARN= -Wall
32+
OPT= -Os
33+
34+
-R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) -DHDR_MALLOC_INCLUDE=\"hdr_redis_malloc.h\"
35+
+R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(CPPFLAGS) -DHDR_MALLOC_INCLUDE=\"hdr_redis_malloc.h\"
36+
R_LDFLAGS= $(LDFLAGS)
37+
DEBUG= -g
38+
39+
diff --git a/deps/linenoise/Makefile b/deps/linenoise/Makefile
40+
index 1dd894b..12ada21 100644
41+
--- a/deps/linenoise/Makefile
42+
+++ b/deps/linenoise/Makefile
43+
@@ -6,7 +6,7 @@ R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS)
44+
R_LDFLAGS= $(LDFLAGS)
45+
DEBUG= -g
46+
47+
-R_CC=$(CC) $(R_CFLAGS)
48+
+R_CC=$(CC) $(R_CFLAGS) $(CPPFLAGS)
49+
R_LD=$(CC) $(R_LDFLAGS)
50+
51+
linenoise.o: linenoise.h linenoise.c
52+
diff --git a/src/Makefile b/src/Makefile
53+
index 1437f41..ac88fc0 100644
54+
--- a/src/Makefile
55+
+++ b/src/Makefile
56+
@@ -391,7 +391,7 @@ else
57+
MAYBE_UNINSTALL_REDIS_SYMLINK=
58+
endif
59+
60+
-SERVER_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) -I.
61+
+SERVER_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) $(CPPFLAGS) -I.
62+
SERVER_AR=$(QUIET_AR)$(AR)
63+
SERVER_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS)
64+
ENGINE_INSTALL=$(QUIET_INSTALL)$(INSTALL)
65+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From: Chris Lamb <lamby@debian.org>
2+
Date: Thu, 16 Nov 2017 03:40:26 +0900
3+
Subject: Use get_current_dir_name over PATHMAX, etc.
4+
5+
Last-Update: 29-10-2024
6+
---
7+
src/rdb.c | 8 ++++----
8+
1 file changed, 4 insertions(+), 4 deletions(-)
9+
10+
diff --git a/src/rdb.c b/src/rdb.c
11+
index 07c6af6..e3d9d34 100644
12+
--- a/src/rdb.c
13+
+++ b/src/rdb.c
14+
@@ -1492,7 +1492,6 @@ werr: /* Write error. */
15+
}
16+
17+
static int rdbSaveInternal(int req, const char *filename, rdbSaveInfo *rsi, int rdbflags) {
18+
- char cwd[MAXPATHLEN]; /* Current working dir path for error messages. */
19+
rio rdb;
20+
int error = 0;
21+
int saved_errno;
22+
@@ -1502,11 +1501,12 @@ static int rdbSaveInternal(int req, const char *filename, rdbSaveInfo *rsi, int
23+
if (!fp) {
24+
saved_errno = errno;
25+
char *str_err = strerror(errno);
26+
- char *cwdp = getcwd(cwd, MAXPATHLEN);
27+
+ char *cwdp = get_current_dir_name();
28+
serverLog(LL_WARNING,
29+
"Failed opening the temp RDB file %s (in server root dir %s) "
30+
"for saving: %s",
31+
filename, cwdp ? cwdp : "unknown", str_err);
32+
+ zfree(cwdp);
33+
errno = saved_errno;
34+
return C_ERR;
35+
}
36+
@@ -1572,7 +1572,6 @@ int rdbSaveToFile(const char *filename) {
37+
/* Save the DB on disk. Return C_ERR on error, C_OK on success. */
38+
int rdbSave(int req, char *filename, rdbSaveInfo *rsi, int rdbflags) {
39+
char tmpfile[256];
40+
- char cwd[MAXPATHLEN]; /* Current working dir path for error messages. */
41+
42+
startSaving(rdbflags);
43+
snprintf(tmpfile, 256, "temp-%d.rdb", (int)getpid());
44+
@@ -1586,11 +1585,12 @@ int rdbSave(int req, char *filename, rdbSaveInfo *rsi, int rdbflags) {
45+
* if the generate DB file is ok. */
46+
if (rename(tmpfile, filename) == -1) {
47+
char *str_err = strerror(errno);
48+
- char *cwdp = getcwd(cwd, MAXPATHLEN);
49+
+ char *cwdp = get_current_dir_name();
50+
serverLog(LL_WARNING,
51+
"Error moving temp DB file %s on the final "
52+
"destination %s (in server root dir %s): %s",
53+
tmpfile, filename, cwdp ? cwdp : "unknown", str_err);
54+
+ zfree(cwdp);
55+
unlink(tmpfile);
56+
stopSaving(0);
57+
return C_ERR;
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
From: Chris Lamb <lamby@debian.org>
2+
Date: Mon, 28 Apr 2025 15:45:49 -0300
3+
Subject: Add support for USE_SYSTEM_JEMALLOC flag.
4+
5+
Last-Update: 14-04-2026
6+
Updated for Valkey 9.1 (deps/Makefile:distclean dropped fast_float_c_interface and gained rm -f .make-*)
7+
---
8+
deps/Makefile | 2 ++
9+
src/Makefile | 5 +++++
10+
src/debug.c | 4 ++++
11+
src/object.c | 4 ++++
12+
src/sds.c | 4 ++++
13+
src/zmalloc.c | 11 +++++++++++
14+
src/zmalloc.h | 4 ++++
15+
7 files changed, 34 insertions(+)
16+
17+
diff --git a/deps/Makefile b/deps/Makefile
18+
--- a/deps/Makefile
19+
+++ b/deps/Makefile
20+
@@ -39,7 +39,9 @@ distclean:
21+
-(cd libvalkey && $(MAKE) clean) > /dev/null || true
22+
-(cd linenoise && $(MAKE) clean) > /dev/null || true
23+
-(cd lua && $(MAKE) clean) > /dev/null || true
24+
+ifneq ($(USE_SYSTEM_JEMALLOC),yes)
25+
-(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true
26+
+endif
27+
-(cd hdr_histogram && $(MAKE) clean) > /dev/null || true
28+
-(cd fpconv && $(MAKE) clean) > /dev/null || true
29+
-(rm -f .make-*)
30+
diff --git a/src/Makefile b/src/Makefile
31+
index ac88fc0..8aefc33 100644
32+
--- a/src/Makefile
33+
+++ b/src/Makefile
34+
@@ -289,10 +289,15 @@ ifeq ($(MALLOC),tcmalloc_minimal)
35+
endif
36+
37+
ifeq ($(MALLOC),jemalloc)
38+
+ifeq ($(USE_SYSTEM_JEMALLOC),yes)
39+
+ FINAL_CFLAGS+= -DUSE_JEMALLOC -DUSE_SYSTEM_JEMALLOC -I/usr/include/jemalloc
40+
+ FINAL_LIBS := -ljemalloc $(FINAL_LIBS)
41+
+else
42+
DEPENDENCY_TARGETS+= jemalloc
43+
FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include
44+
FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS)
45+
endif
46+
+endif
47+
48+
ifeq ($(USE_LTTNG),yes)
49+
FINAL_CFLAGS+=-DUSE_LTTNG
50+
diff --git a/src/debug.c b/src/debug.c
51+
index 4a57cd4..88b37af 100644
52+
--- a/src/debug.c
53+
+++ b/src/debug.c
54+
@@ -82,6 +82,10 @@ void bugReportEnd(int killViaSignal, int sig);
55+
void logStackTrace(void *eip, int uplevel, int current_thread);
56+
void sigalrmSignalHandler(int sig, siginfo_t *info, void *secret);
57+
58+
+#if defined(USE_JEMALLOC) && defined(USE_SYSTEM_JEMALLOC)
59+
+#define je_mallctl mallctl
60+
+#endif
61+
+
62+
/* ================================= Debugging ============================== */
63+
64+
/* Compute the sha1 of string at 's' with 'len' bytes long.
65+
diff --git a/src/object.c b/src/object.c
66+
index 9ddd412..d60d867 100644
67+
--- a/src/object.c
68+
+++ b/src/object.c
69+
@@ -45,6 +45,10 @@
70+
/* For objects with large embedded keys, we reserve space for an expire field,
71+
* so if expire is set later, we don't need to reallocate the object. */
72+
#define KEY_SIZE_TO_INCLUDE_EXPIRE_THRESHOLD 128
73+
+#if defined(USE_JEMALLOC) && defined(USE_SYSTEM_JEMALLOC)
74+
+#define je_mallctl mallctl
75+
+#define je_malloc_stats_print malloc_stats_print
76+
+#endif
77+
78+
/* ===================== Creation and parsing of objects ==================== */
79+
80+
diff --git a/src/sds.c b/src/sds.c
81+
index 7843363..ea1551d 100644
82+
--- a/src/sds.c
83+
+++ b/src/sds.c
84+
@@ -39,6 +39,10 @@
85+
#include "sdsalloc.h"
86+
#include "util.h"
87+
88+
+#ifdef USE_SYSTEM_JEMALLOC
89+
+#define je_nallocx(size, flags) nallocx(size, flags)
90+
+#endif
91+
+
92+
const char *SDS_NOINIT = "SDS_NOINIT";
93+
94+
int sdsHdrSize(char type) {
95+
diff --git a/src/zmalloc.c b/src/zmalloc.c
96+
index 24dd11a..5c8e17a 100644
97+
--- a/src/zmalloc.c
98+
+++ b/src/zmalloc.c
99+
@@ -80,11 +80,22 @@ void zlibc_free(void *ptr) {
100+
#define free(ptr) tc_free(ptr)
101+
/* Explicitly override malloc/free etc when using jemalloc. */
102+
#elif defined(USE_JEMALLOC)
103+
+#ifdef USE_SYSTEM_JEMALLOC
104+
+#define malloc(size) malloc(size)
105+
+#define calloc(count,size) calloc(count,size)
106+
+#define realloc(ptr,size) realloc(ptr,size)
107+
+#define free(ptr) free(ptr)
108+
+#define mallocx(size,flags) mallocx(size,flags)
109+
+#define dallocx(ptr,flags) dallocx(ptr,flags)
110+
+#define je_sdallocx(ptr,size,flags) sdallocx(ptr,size,flags)
111+
+#define je_mallctl mallctl
112+
+#else
113+
#define malloc(size) je_malloc(size)
114+
#define calloc(count, size) je_calloc(count, size)
115+
#define realloc(ptr, size) je_realloc(ptr, size)
116+
#define free(ptr) je_free(ptr)
117+
#endif
118+
+#endif
119+
120+
#define thread_local _Thread_local
121+
122+
diff --git a/src/zmalloc.h b/src/zmalloc.h
123+
index 68b4df6..6bfab3d 100644
124+
--- a/src/zmalloc.h
125+
+++ b/src/zmalloc.h
126+
@@ -53,7 +53,11 @@
127+
#include <jemalloc/jemalloc.h>
128+
#if (JEMALLOC_VERSION_MAJOR == 2 && JEMALLOC_VERSION_MINOR >= 1) || (JEMALLOC_VERSION_MAJOR > 2)
129+
#define HAVE_MALLOC_SIZE 1
130+
+#ifdef USE_SYSTEM_JEMALLOC
131+
+#define zmalloc_size(p) malloc_usable_size(p)
132+
+#else
133+
#define zmalloc_size(p) je_malloc_usable_size(p)
134+
+#endif
135+
#else
136+
#error "Newer version of jemalloc required"
137+
#endif
138+
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
From: Chris Lamb <lamby@debian.org>
2+
Date: Mon, 28 Apr 2025 15:45:49 -0300
3+
Subject: Set Debian configuration defaults
4+
5+
Last-Update: 28-04-2025
6+
---
7+
sentinel.conf | 8 ++++----
8+
valkey.conf | 10 +++++-----
9+
2 files changed, 9 insertions(+), 9 deletions(-)
10+
11+
diff --git a/sentinel.conf b/sentinel.conf
12+
index 4c98a09..e8a5d84 100644
13+
--- a/sentinel.conf
14+
+++ b/sentinel.conf
15+
@@ -12,12 +12,12 @@ port 26379
16+
# By default Valkey Sentinel does not run as a daemon. Use 'yes' if you need it.
17+
# Note that Valkey will write a pid file in /var/run/valkey-sentinel.pid when
18+
# daemonized.
19+
-daemonize no
20+
+daemonize yes
21+
22+
# When running daemonized, Valkey Sentinel writes a pid file in
23+
# /var/run/valkey-sentinel.pid by default. You can specify a custom pid file
24+
# location here.
25+
-pidfile /var/run/valkey-sentinel.pid
26+
+pidfile /run/sentinel/valkey-sentinel.pid
27+
28+
# Specify the server verbosity level.
29+
# This can be one of:
30+
@@ -31,7 +31,7 @@ loglevel notice
31+
# Specify the log file name. Also the empty string can be used to force
32+
# Sentinel to log on the standard output. Note that if you use standard
33+
# output for logging but daemonize, logs will be sent to /dev/null
34+
-logfile ""
35+
+logfile /var/log/valkey/valkey-sentinel.log
36+
37+
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
38+
# and optionally update the other syslog parameters to suit your needs.
39+
@@ -70,7 +70,7 @@ logfile ""
40+
# For Valkey Sentinel to chdir to /tmp at startup is the simplest thing
41+
# for the process to don't interfere with administrative tasks such as
42+
# unmounting filesystems.
43+
-dir /tmp
44+
+dir /var/lib/valkey
45+
46+
# sentinel monitor <master-name> <ip> <valkey-port> <quorum>
47+
#
48+
diff --git a/valkey.conf b/valkey.conf
49+
index df12b72..ad8edd0 100644
50+
--- a/valkey.conf
51+
+++ b/valkey.conf
52+
@@ -153,7 +153,7 @@ tcp-backlog 511
53+
# incoming connections. There is no default, so the server will not listen
54+
# on a unix socket when not specified.
55+
#
56+
-# unixsocket /run/valkey.sock
57+
+# unixsocket /run/valkey/valkey-server.sock
58+
# unixsocketgroup wheel
59+
# unixsocketperm 700
60+
61+
@@ -353,7 +353,7 @@ tcp-keepalive 300
62+
# By default the server does not run as a daemon. Use 'yes' if you need it.
63+
# Note that the server will write a pid file in /var/run/valkey.pid when daemonized.
64+
# When the server is supervised by upstart or systemd, this parameter has no impact.
65+
-daemonize no
66+
+daemonize yes
67+
68+
# If you run the server from upstart or systemd, the server can interact with your
69+
# supervision tree. Options:
70+
@@ -385,7 +385,7 @@ daemonize no
71+
#
72+
# Note that on modern Linux systems "/run/valkey.pid" is more conforming
73+
# and should be used instead.
74+
-pidfile /var/run/valkey_6379.pid
75+
+pidfile /run/valkey/valkey-server.pid
76+
77+
# Specify the server verbosity level.
78+
# This can be one of:
79+
@@ -416,7 +416,7 @@ loglevel notice
80+
# Specify the log file name. Also the empty string can be used to force
81+
# the server to log on the standard output. Note that if you use standard
82+
# output for logging but daemonize, logs will be sent to /dev/null
83+
-logfile ""
84+
+logfile /var/log/valkey/valkey-server.log
85+
86+
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
87+
# and optionally update the other syslog parameters to suit your needs.
88+
@@ -606,7 +606,7 @@ rdb-del-sync-files no
89+
# Note that modifying 'dir' during runtime may have unexpected behavior,
90+
# for example when a child process is running, related file operations may
91+
# have unexpected effects.
92+
-dir ./
93+
+dir /var/lib/valkey
94+
95+
################################# REPLICATION #################################
96+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
debian-packaging/0001-Set-Debian-configuration-defaults.patch
2+
0001-Fix-FTBFS-on-kFreeBSD.patch
3+
0002-Add-CPPFLAGS-to-upstream-makefiles.patch
4+
0003-Use-get_current_dir_name-over-PATHMAX.patch
5+
0004-Add-support-for-USE_SYSTEM_JEMALLOC-flag.patch

0 commit comments

Comments
 (0)