From ccea128f658d96697fcc61264980279baaf2bfd4 Mon Sep 17 00:00:00 2001 From: Sam Feifer Date: Tue, 16 Sep 2025 11:48:30 -0400 Subject: [PATCH 01/11] update comments for libvalkey migration --- qa/1290 | 2 +- qa/1662 | 2 +- src/external/dict.c | 2 +- src/external/dict.h | 2 +- src/libpcp3/src/include/pcp/dict.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/qa/1290 b/qa/1290 index d515438fb4f..db5e7477bbe 100755 --- a/qa/1290 +++ b/qa/1290 @@ -265,7 +265,7 @@ then else echo "Warning: no extra suppressions found for valgrind version $__version" >>$seq_full fi -# skip valgrind errors in upstream non-PCP code, like hiredis ... +# skip valgrind errors in upstream non-PCP code, like libvalkey ... # (seen on vm11 Debian 10.13) # ... same suppressions as for qa/1662 # diff --git a/qa/1662 b/qa/1662 index 9916b304f5e..b05b8db7127 100755 --- a/qa/1662 +++ b/qa/1662 @@ -96,7 +96,7 @@ path = $dir EOF src/time_stamp $tmp.stamp 'pmproxy start' >>$seq_full grind_extra="--track-origins=yes --read-var-info=yes --read-inline-info=yes" -# skip valgrind errors in upstream non-PCP code, like hiredis ... +# skip valgrind errors in upstream non-PCP code, like libvalkey ... # (seen on vm11 Debian 10.13) # ... same suppressions as for qa/1290 # diff --git a/src/external/dict.c b/src/external/dict.c index 73360c189ff..481c414c7cd 100644 --- a/src/external/dict.c +++ b/src/external/dict.c @@ -905,7 +905,7 @@ unsigned long dictScan(dict *d, return v; } -/* ------------------ compat functions required in hiredis ------------------ */ +/* ------------------ compat functions required in libvalkey ------------------ */ void dictInitIterator(dictIterator *iter, dict *d) { // please refer to dictGetSafeIterator() diff --git a/src/external/dict.h b/src/external/dict.h index 6575d174fa9..79eaf6ca15e 100644 --- a/src/external/dict.h +++ b/src/external/dict.h @@ -182,7 +182,7 @@ unsigned long dictScan(dict *d, unsigned long v, dictScanFunction *fn, dictScanB uint64_t dictGetHash(dict *d, const void *key); dictEntry **dictFindEntryRefByPtrAndHash(dict *d, const void *oldptr, uint64_t hash); -/* compat functions required for hiredis */ +/* compat functions required for libvalkey */ void dictInitIterator(dictIterator *iter, dict *d); #define dictGetEntryVal dictGetVal #define dictSetHashVal dictSetVal diff --git a/src/libpcp3/src/include/pcp/dict.h b/src/libpcp3/src/include/pcp/dict.h index 6575d174fa9..79eaf6ca15e 100644 --- a/src/libpcp3/src/include/pcp/dict.h +++ b/src/libpcp3/src/include/pcp/dict.h @@ -182,7 +182,7 @@ unsigned long dictScan(dict *d, unsigned long v, dictScanFunction *fn, dictScanB uint64_t dictGetHash(dict *d, const void *key); dictEntry **dictFindEntryRefByPtrAndHash(dict *d, const void *oldptr, uint64_t hash); -/* compat functions required for hiredis */ +/* compat functions required for libvalkey */ void dictInitIterator(dictIterator *iter, dict *d); #define dictGetEntryVal dictGetVal #define dictSetHashVal dictSetVal From 6147cffe0d9864f622b12ca340698bd1d08561af Mon Sep 17 00:00:00 2001 From: Sam Feifer Date: Tue, 16 Sep 2025 12:17:32 -0400 Subject: [PATCH 02/11] Small changes for libvlakey migration --- scripts/cull-build-warnings | 9 ++++----- src/libpcp_web/src/keys.c | 2 +- src/libpcp_web/src/load.c | 4 ++-- src/libpcp_web/src/query.c | 8 ++++---- src/libpcp_web/src/schema.c | 6 +++--- src/libpcp_web/src/search.c | 4 ++-- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/scripts/cull-build-warnings b/scripts/cull-build-warnings index 91df01fcaf2..bd6a464223f 100755 --- a/scripts/cull-build-warnings +++ b/scripts/cull-build-warnings @@ -8,7 +8,7 @@ # The things we're culling are # - false warnings, often from older toolchains # - warnings from code the is not part of PCP proper, e.g. the qwt library -# and the vendor code (hiredis, hiredis-cluster, jasonl, libbpf-tools, +# and the vendor code (libvalkey, jasonl, libbpf-tools, # bpftool, htop, etc) ... we assume fixed these is "someone else's # problem" # - things's we triaged and decided are OK, e.g. rand() or random() use @@ -56,10 +56,9 @@ mv $tmp.out $tmp.in sed <$tmp.in >$tmp.out \ -e '/^qwt_/d' \ -e '/^\.\/qwt_/d' \ - -e '/^deps\/hiredis\/async.c[ :].* unused variable /d' \ - -e '/^deps\/hiredis\/sds.h[ :].* declaration of .sh. shadows a previous local/d' \ - -e '/^deps\/hiredis\/sds.c[ :].* declaration of .sh. shadows a previous local/d' \ - -e '/^deps\/hiredis\/sds.c[ :].* declaration shadows a local variable/d' \ + -e '/^deps\/libvalkey\/src\/sds.h[ :].* declaration of .sh. shadows a previous local/d' \ + -e '/^deps\/libvalkey\/src\/sds.c[ :].* declaration of .sh. shadows a previous local/d' \ + -e '/^deps\/libvalkey\/src\/sds.c[ :].* declaration shadows a local variable/d' \ -e '/\/selinux\/.*\.if[ :].* duplicate definition of /d' \ -e '/^libbpf.c[ :].* comparison of integer expressions of different signedness/d' \ -e '/^libbpf.c[ :].* comparison between signed and unsigned integer expressions/d' \ diff --git a/src/libpcp_web/src/keys.c b/src/libpcp_web/src/keys.c index c85d84b6ceb..cff0d109b19 100644 --- a/src/libpcp_web/src/keys.c +++ b/src/libpcp_web/src/keys.c @@ -27,7 +27,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include "keys.h" const char * diff --git a/src/libpcp_web/src/load.c b/src/libpcp_web/src/load.c index eac565d43e3..d0853a63a58 100644 --- a/src/libpcp_web/src/load.c +++ b/src/libpcp_web/src/load.c @@ -1095,10 +1095,10 @@ connect_keys_source_service(seriesLoadBaton *baton) if ((baton->flags & PM_SERIES_FLAG_TEXT)) flags |= SLOTS_SEARCH; baton->slots = data->slots = - keySlotsConnect( + &(keySlotsConnect( data->config, flags, baton->info, series_load_end_phase, baton->userdata, - data->events, (void *)baton); + data->events, (void *)baton))->slots; } } } diff --git a/src/libpcp_web/src/query.c b/src/libpcp_web/src/query.c index e0f24236ec4..58f1132ae6f 100644 --- a/src/libpcp_web/src/query.c +++ b/src/libpcp_web/src/query.c @@ -5141,10 +5141,10 @@ series_query_services(void *arg) baton->error = -ENOTSUP; else baton->slots = data->slots = - keySlotsConnect( + &(keySlotsConnect( data->config, 1, baton->info, series_query_end_phase, baton->userdata, - data->events, (void *)baton); + data->events, (void *)baton))->slots; } } @@ -6166,10 +6166,10 @@ series_lookup_services(void *arg) baton->error = -ENOTSUP; else baton->slots = data->slots = - keySlotsConnect( + &(keySlotsConnect( data->config, 1, baton->info, series_query_end_phase, baton->userdata, - data->events, (void *)baton); + data->events, (void *)baton))->slots; } } diff --git a/src/libpcp_web/src/schema.c b/src/libpcp_web/src/schema.c index 6eb739d1618..079fb32bf69 100644 --- a/src/libpcp_web/src/schema.c +++ b/src/libpcp_web/src/schema.c @@ -1457,7 +1457,7 @@ keysSchemaLoad(keySlots *slots, keySlotsFlags flags, /* Register the pmsearch schema with RediSearch if needed */ if (flags & SLOTS_SEARCH) { /* if we got a route update means we are in cluster mode */ - if (slots->acc->cc->route_version > 0) { + if (slots->acc && slots->acc->cc.route_version > 0) { pmNotifyErr(LOG_INFO, "disabling search module " "because it does not support cluster mode\n"); } else { @@ -1707,9 +1707,9 @@ pmSeriesSetup(pmSeriesModule *module, void *arg) if (option && strcmp(option, "true") == 0) flags |= SLOTS_SEARCH; - data->slots = keySlotsConnect( + data->slots = &(keySlotsConnect( data->config, flags, module->on_info, - module->on_setup, arg, data->events, arg); + module->on_setup, arg, data->events, arg))->slots; data->shareslots = 0; } diff --git a/src/libpcp_web/src/search.c b/src/libpcp_web/src/search.c index 744e56c2345..61e0fe8176c 100644 --- a/src/libpcp_web/src/search.c +++ b/src/libpcp_web/src/search.c @@ -1090,9 +1090,9 @@ pmSearchSetup(pmSearchModule *module, void *arg) return -ENOTSUP; /* establish an initial connection to key server instance(s) */ - data->slots = keySlotsConnect( + data->slots = &(keySlotsConnect( data->config, flags, module->on_info, - module->on_setup, arg, data->events, arg); + module->on_setup, arg, data->events, arg))->slots; data->shareslots = 0; } return 0; From 2fd3e07b62004aa1e81333ede69199ee29e57f07 Mon Sep 17 00:00:00 2001 From: Sam Feifer Date: Tue, 16 Sep 2025 12:34:43 -0400 Subject: [PATCH 03/11] Makefile changes for libvalkey migration --- src/include/pcp/GNUmakefile | 2 +- src/libpcp_web/src/GNUmakefile | 45 +++++++++++++++------------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/include/pcp/GNUmakefile b/src/include/pcp/GNUmakefile index 2405ca2b4a5..0120c5935db 100644 --- a/src/include/pcp/GNUmakefile +++ b/src/include/pcp/GNUmakefile @@ -50,7 +50,7 @@ $(EXTERNAL_HFILES): $(INIH_HFILES): $(LN_S) -f $(TOPDIR)/vendor/github.com/benhoyt/inih/$@ . $(SDSH_HFILES): - $(LN_S) -f $(TOPDIR)/vendor/github.com/redis/hiredis/$@ . + $(LN_S) -f $(TOPDIR)/vendor/github.com/valkey-io/libvalkey/src/$@ . $(USDT_HFILES): $(LN_S) -f $(TOPDIR)/vendor/github.com/libbpf/usdt/$@ . diff --git a/src/libpcp_web/src/GNUmakefile b/src/libpcp_web/src/GNUmakefile index b1cee866b5b..fc1b5662eff 100644 --- a/src/libpcp_web/src/GNUmakefile +++ b/src/libpcp_web/src/GNUmakefile @@ -26,25 +26,20 @@ else INIH_XFILES = endif -HIREDIS_HFILES = $(addprefix deps/hiredis/, \ - alloc.h async.h async_private.h fmacros.h hiredis.h net.h \ - read.h sds.h sdsalloc.h sockcompat.h win32.h adapters/libuv.h) -HIREDIS_CFILES = $(addprefix deps/hiredis/, \ - alloc.c async.c hiredis.c net.c sds.c sockcompat.c read.c) -HIREDIS_XFILES = $(HIREDIS_HFILES) $(HIREDIS_CFILES) - -HIREDIS_CLUSTER_HFILES = $(addprefix deps/hiredis-cluster/, \ - adlist.h command.h hiarray.h hiutil.h hircluster.h win32.h \ - adapters/libuv.h) -HIREDIS_CLUSTER_CFILES = $(addprefix deps/hiredis-cluster/, \ - adlist.c command.c crc16.c hiarray.c hiutil.c hircluster.c) -HIREDIS_CLUSTER_XFILES = $(HIREDIS_CLUSTER_HFILES) $(HIREDIS_CLUSTER_CFILES) +LIBVALKEY_HFILES = $(addprefix deps/libvalkey/, \ + include/valkey/alloc.h include/valkey/async.h src/async_private.h src/fmacros.h include/valkey/valkey.h include/valkey/net.h \ + include/valkey/read.h include/valkey/visibility.h src/sds.h src/sdsalloc.h include/valkey/sockcompat.h src/win32.h include/valkey/adapters/libuv.h \ + src/adlist.h src/command.h src/vkutil.h include/valkey/cluster.h src/valkey_private.h src/cmddef.h) +LIBVALKEY_CFILES = $(addprefix deps/libvalkey/, \ + src/alloc.c src/async.c src/valkey.c src/net.c src/sds.c src/sockcompat.c src/read.c \ + src/adlist.c src/command.c src/crc16.c src/vkutil.c src/cluster.c src/conn.c) +LIBVALKEY_XFILES = $(LIBVALKEY_HFILES) $(LIBVALKEY_CFILES) CFILES = jsmn.c http_client.c http_parser.c siphash.c \ query.c schema.c load.c sha1.c util.c slots.c \ keys.c dict.c maps.c batons.c encoding.c \ search.c json_helpers.c config.c \ - $(HIREDIS_CFILES) $(HIREDIS_CLUSTER_CFILES) + $(LIBVALKEY_CFILES) ifneq "$(HAVE_LIBINIH)" "true" CFILES += $(INIH_CFILES) endif @@ -52,7 +47,7 @@ HFILES = jsmn.h http_client.h http_parser.h zmalloc.h \ query.h schema.h load.h sha1.h util.h slots.h \ keys.h dict.h maps.h batons.h encoding.h \ search.h discover.h private.h \ - $(HIREDIS_HFILES) $(HIREDIS_CLUSTER_HFILES) + $(LIBVALKEY_HFILES) ifneq "$(HAVE_LIBINIH)" "true" HFILES += $(INIH_HFILES) endif @@ -72,7 +67,7 @@ ifneq "$(HAVE_LIBINIH)" "true" LCFLAGS += -Iinih endif -LCFLAGS += $(C99_CFLAGS) -DJSMN_PARENT_LINKS=1 -DJSMN_STRICT=1 -DHTTP_PARSER_STRICT=0 -Ideps +LCFLAGS += $(C99_CFLAGS) -DJSMN_PARENT_LINKS=1 -DJSMN_STRICT=1 -DHTTP_PARSER_STRICT=0 -Ideps -Ideps/libvalkey/include/valkey ifeq "$(HAVE_LIBUV)" "true" CFILES += discover.c loggroup.c webgroup.c timer.c @@ -113,12 +108,12 @@ SYMTARGET = endif VERSION_SCRIPT = exports -LDIRT = $(XFILES) $(YFILES) $(HIREDIS_XFILES) $(HIREDIS_CLUSTER_XFILES) $(SYMTARGET) $(YFILES:%.y=%.tab.?) exports +LDIRT = $(XFILES) $(YFILES) $(LIBVALKEY_XFILES) $(SYMTARGET) $(YFILES:%.y=%.tab.?) ifneq "$(HAVE_LIBINIH)" "true" LDIRT += $(INIH_XFILES) endif -default: exports $(XFILES) $(HIREDIS_XFILES) $(HIREDIS_CLUSTER_XFILES) $(INIH_XFILES) $(LIBTARGET) $(SYMTARGET) $(STATICLIBTARGET) +default: $(XFILES) $(LIBVALKEY_XFILES) $(INIH_XFILES) $(LIBTARGET) $(SYMTARGET) $(STATICLIBTARGET) include $(BUILDRULES) @@ -148,12 +143,10 @@ $(INIH_XFILES): mkdir -p deps/inih $(LN_S) -f $(realpath $(TOPDIR))/vendor/github.com/benhoyt/$(@:deps/%=%) $@ endif -$(HIREDIS_XFILES): - mkdir -p deps/hiredis/adapters - $(LN_S) -f $(realpath $(TOPDIR))/vendor/github.com/redis/$(@:deps/%=%) $@ -$(HIREDIS_CLUSTER_XFILES): - mkdir -p deps/hiredis-cluster/adapters - $(LN_S) -f $(realpath $(TOPDIR))/vendor/github.com/Nordix/$(@:deps/%=%) $@ +$(LIBVALKEY_XFILES): + mkdir -p deps/libvalkey/include/valkey/adapters + mkdir -p deps/libvalkey/src + $(LN_S) -f $(realpath $(TOPDIR))/vendor/github.com/valkey-io/$(@:deps/%=%) $@ .NOTPARALLEL: query_parser.tab.h query_parser.tab.c: query_parser.y query.h @@ -167,9 +160,11 @@ default_pcp: default install_pcp: install ifneq ($(LIBTARGET),) -$(LIBTARGET): $(VERSION_SCRIPT) $(XFILES) $(HIREDIS_XFILES) $(HIREDIS_CLUSTER_XFILES) $(INIH_XFILES) +$(LIBTARGET): $(VERSION_SCRIPT) $(XFILES) $(LIBVALKEY_XFILES) $(INIH_XFILES) endif +%.o: $(LIBVALKEY_XFILES) $(INIH_XFILES) + jsmn.o: jsmn.c jsmn.h discover.o: discover.h discover.c http_parser.o: http_parser.c http_parser.h From bd1f79b45d8b55635a39d31e7a8eb42f91359fda Mon Sep 17 00:00:00 2001 From: Sam Feifer Date: Tue, 16 Sep 2025 12:35:07 -0400 Subject: [PATCH 04/11] libvalkey migration for slots files --- src/libpcp_web/src/slots.c | 176 ++++++++++++++----------------------- src/libpcp_web/src/slots.h | 14 ++- 2 files changed, 76 insertions(+), 114 deletions(-) diff --git a/src/libpcp_web/src/slots.c b/src/libpcp_web/src/slots.c index defe67f4b22..5a113195747 100644 --- a/src/libpcp_web/src/slots.c +++ b/src/libpcp_web/src/slots.c @@ -21,7 +21,7 @@ #include #endif #if defined(HAVE_LIBUV) -#include +#include #else static int keyClusterLibuvAttach() { return RESP_OK; } #endif @@ -29,7 +29,7 @@ static int keyClusterLibuvAttach() { return RESP_OK; } static char default_server[] = "localhost:6379"; static void -key_server_connect_callback(const keysAsyncContext *keys, int status) +key_server_connect_callback(keysAsyncContext *keys, int status) { if (status == RESP_OK) { if (pmDebugOptions.series) @@ -154,10 +154,10 @@ keySlotsSetMetricRegistry(keySlots *slots, mmv_registry_t *registry) return -ENOMEM; } -keySlots * +keySlotsContext * keySlotsInit(dict *config, void *events) { - keySlots *slots; + keySlotsContext *context; sds servers = NULL; sds def_servers = NULL; sds username = NULL; @@ -166,19 +166,19 @@ keySlotsInit(dict *config, void *events) struct timeval connection_timeout = {5, 0}; // 5s struct timeval command_timeout = {60, 0}; // 1m - if ((slots = (keySlots *)calloc(1, sizeof(keySlots))) == NULL) { - pmNotifyErr(LOG_ERR, "%s: failed to allocate keySlots\n", + if ((context = (keySlotsContext *)calloc(1, sizeof(keySlotsContext))) == NULL) { + pmNotifyErr(LOG_ERR, "%s: failed to allocate keySlotsContext\n", "keySlotsInit"); return NULL; } - slots->state = SLOTS_DISCONNECTED; - slots->events = events; - slots->keymap = dictCreate(&sdsKeyDictCallBacks, "keymap"); - if (slots->keymap == NULL) { + context->slots.state = SLOTS_DISCONNECTED; + context->slots.events = events; + context->slots.keymap = dictCreate(&sdsKeyDictCallBacks, "keymap"); + if (context->slots.keymap == NULL) { pmNotifyErr(LOG_ERR, "%s: failed to allocate keymap\n", "keySlotsInit"); - free(slots); + free(context); return NULL; } @@ -201,107 +201,58 @@ keySlotsInit(dict *config, void *events) if (password == NULL) password = pmIniFileLookup(config, "pmseries", "auth.password"); - if ((slots->acc = keyClusterAsyncContextInit()) == NULL) { - /* Coverity CID370635 */ - pmNotifyErr(LOG_ERR, "%s: %s failed\n", - "keySlotsInit", "keyClusterAsyncContextInit"); - sdsfree(def_servers); - return slots; - } - - if (slots->acc->err) { - pmNotifyErr(LOG_ERR, "%s: %s\n", "keySlotsInit", slots->acc->errstr); - sdsfree(def_servers); - return slots; - } - - sts = keyClusterSetOptionAddNodes(slots->acc->cc, servers); - if (sts != RESP_OK) { - pmNotifyErr(LOG_ERR, "%s: failed to add key server nodes: %s\n", - "keySlotsInit", slots->acc->cc->errstr); - sdsfree(def_servers); - return slots; - } - sdsfree(def_servers); /* Coverity CID370634 */ - /* + * Add options to the valkeyClusterOptions struct * the ini parser already removes spaces at the beginning and end of the * configuration values, so checking for empty strings using sdslen() is - * fine - */ - if (username != NULL && sdslen(username) > 0) { - sts = keyClusterSetOptionUsername(slots->acc->cc, username); - if (sts != RESP_OK) { - pmNotifyErr(LOG_ERR, "%s: failed to set key server username: %s\n", - "keyClusterSetOptionUsername", slots->acc->cc->errstr); - return slots; - } - } - - /* + * fine. * see note above re empty configuration values having only a password * set and no username is a valid key server configuration, details: * https://valkey.io/commands/auth - */ - if (password != NULL && sdslen(password) > 0) { - sts = keyClusterSetOptionPassword(slots->acc->cc, password); - if (sts != RESP_OK) { - pmNotifyErr(LOG_ERR, "%s: failed to set key server password: %s\n", - "keyClusterSetOptionPassword", slots->acc->cc->errstr); - return slots; - } - } - - sts = keyClusterSetOptionConnectTimeout(slots->acc->cc, connection_timeout); - if (sts != RESP_OK) { - pmNotifyErr(LOG_ERR, "%s: failed to set connect timeout: %s\n", - "keySlotsInit", slots->acc->errstr); - return slots; - } - - sts = keyClusterSetOptionTimeout(slots->acc->cc, command_timeout); - if (sts != RESP_OK) { - pmNotifyErr(LOG_ERR, "%s: failed to set command timeout: %s\n", - "keySlotsInit", slots->acc->cc->errstr); - return slots; - } - - sts = keyClusterLibuvAttach(slots->acc, slots->events); - if (sts != RESP_OK) { - pmNotifyErr(LOG_ERR, "%s: failed to attach to event loop: %s\n", - "keySlotsInit", slots->acc->errstr); - return slots; - } + */ + + context->opts.initial_nodes = servers; // sds string + context->opts.username = (username && sdslen(username)) ? username : NULL; + context->opts.password = (password && sdslen(password)) ? password : NULL; + context->opts.connect_timeout = &connection_timeout; // struct timeval* + context->opts.command_timeout = &command_timeout; // struct timeval* + context->opts.async_connect_callback = key_server_connect_callback; + context->opts.async_disconnect_callback = key_server_disconnect_callback; +#if defined(HAVE_LIBUV) + context->opts.attach_fn = keyLibuvAttachAdapter; + context->opts.attach_data = (uv_loop_t *)events; +#endif - sts = keyClusterAsyncSetConnectCallback(slots->acc, key_server_connect_callback); - if (sts != RESP_OK) { - pmNotifyErr(LOG_ERR, "%s: failed to set connect callback: %s\n", - "keySlotsInit", slots->acc->errstr); - return slots; + if ((context->slots.acc = keyClusterAsyncContextInit(&context->opts)) == NULL) { + /* Coverity CID370635 */ + pmNotifyErr(LOG_ERR, "%s: %s failed\n", + "keySlotsInit", "keyClusterAsyncContextInit"); + sdsfree(def_servers); + return context; + } + + if (context->slots.acc->err) { + pmNotifyErr(LOG_ERR, "%s: %s\n", "keySlotsInit", context->slots.acc->errstr); + sdsfree(def_servers); + return context; } - sts = keyClusterAsyncSetDisconnectCallback(slots->acc, key_server_disconnect_callback); - if (sts != RESP_OK) { - pmNotifyErr(LOG_ERR, "%s: failed to set disconnect callback: %s\n", - "keySlotsInit", slots->acc->errstr); - return slots; - } + sdsfree(def_servers); /* Coverity CID370634 */ - return slots; + return context; } /** - * despite the name, this function also handles the initial - * connection to the key server + * Handles reconnection logic and schema loading after initial + * connection (which happens in keySlotsInit with libvalkey) */ void keySlotsReconnect(keySlots *slots, keySlotsFlags flags, keysInfoCallBack info, keysDoneCallBack done, - void *userdata, void *events, void *arg) + void *userdata, void *events, void *arg, valkeyClusterOptions *opts) { dictIterator *iterator; dictEntry *entry; - int sts = 0; static int log_connection_errors = 1; if (slots == NULL) @@ -323,15 +274,20 @@ keySlotsReconnect(keySlots *slots, keySlotsFlags flags, slots->search = 0; dictEmpty(slots->keymap, NULL); - sts = keyClusterConnect2(slots->acc->cc); - if (sts == RESP_OK) { + /* Connect to the key server */ + /* libvalkey determines cluster mode during initial connect */ + valkeyClusterContext *tmp = keyClusterConnect2(opts); + if (tmp) { + slots->acc->cc = *tmp; + } + if (slots->acc->cc.err == 0) { slots->cluster = 1; } - else if (slots->acc->cc->err && - strcmp(slots->acc->cc->errstr, RESP_ENOCLUSTER) == 0) { + else if (slots->acc->cc.err && + strcmp(slots->acc->cc.errstr, RESP_ENOCLUSTER) == 0) { /* key server instance has cluster support disabled */ - slots->acc->cc->err = 0; - memset(slots->acc->cc->errstr, '\0', strlen(slots->acc->cc->errstr)); + slots->acc->cc.err = 0; + memset(slots->acc->cc.errstr, '\0', strlen(slots->acc->cc.errstr)); slots->cluster = 0; /* @@ -339,7 +295,7 @@ keySlotsReconnect(keySlots *slots, keySlotsFlags flags, * is configured, but cluster mode is disabled * otherwise all other nodes silently don't get any data */ - iterator = dictGetSafeIterator(slots->acc->cc->nodes); + iterator = dictGetSafeIterator(slots->acc->cc.nodes); entry = dictNext(iterator); if (entry && dictNext(iterator)) { dictReleaseIterator(iterator); @@ -353,7 +309,7 @@ keySlotsReconnect(keySlots *slots, keySlotsFlags flags, else { if (log_connection_errors || pmDebugOptions.desperate) { pmNotifyErr(LOG_INFO, "Cannot connect to key server: %s\n", - slots->acc->cc->errstr); + slots->acc->cc.errstr); log_connection_errors = 0; } slots->state = SLOTS_DISCONNECTED; @@ -370,12 +326,12 @@ keySlotsReconnect(keySlots *slots, keySlotsFlags flags, * compatibility, the actual connection to the key server happens in * keySlotsReconnect() */ -keySlots * +keySlotsContext * keySlotsConnect(dict *config, keySlotsFlags flags, keysInfoCallBack info, keysDoneCallBack done, void *userdata, void *events, void *arg) { - keySlots *slots; + keySlotsContext *context; sds enabled, msg; if (!(enabled = pmIniFileLookup(config, "resp", "enabled"))) @@ -383,8 +339,8 @@ keySlotsConnect(dict *config, keySlotsFlags flags, if (enabled && strcmp(enabled, "false") == 0) return NULL; - slots = keySlotsInit(config, events); - if (slots == NULL) { + context = keySlotsInit(config, events); + if (context == NULL) { msg = NULL; infofmt(msg, "Failed to allocate memory for key server slots"); info(PMLOG_ERROR, msg, arg); @@ -392,8 +348,8 @@ keySlotsConnect(dict *config, keySlotsFlags flags, return NULL; } - keySlotsReconnect(slots, flags, info, done, userdata, events, arg); - return slots; + keySlotsReconnect(&context->slots, flags, info, done, userdata, events, arg, &context->opts); + return context; } void @@ -585,7 +541,7 @@ keySlotsRequestFirstNode(keySlots *slots, const sds cmd, { dictIterator *iterator; dictEntry *entry; - cluster_node *node; + valkeyClusterNode *node; keySlotsReplyData *srd; uint64_t size; int sts; @@ -597,7 +553,7 @@ keySlotsRequestFirstNode(keySlots *slots, const sds cmd, if (UNLIKELY(slots->state != SLOTS_CONNECTED && slots->state != SLOTS_READY)) return -ENOTCONN; - iterator = dictGetSafeIterator(slots->acc->cc->nodes); + iterator = dictGetSafeIterator(slots->acc->cc.nodes); entry = dictNext(iterator); dictReleaseIterator(iterator); if (!entry) { @@ -735,8 +691,8 @@ reportReplyError(keysInfoCallBack info, void *userdata, msg = sdscatfmt(msg, "\nRESP reply error: %s", reply->str); else if (acc->err) msg = sdscatfmt(msg, "\nRESP acc error: %s", acc->errstr); - else if (acc->cc->err) - msg = sdscatfmt(msg, "\nRESP cc error: %s", acc->cc->errstr); + else if (acc->cc.err) + msg = sdscatfmt(msg, "\nRESP cc error: %s", acc->cc.errstr); info(PMLOG_RESPONSE, msg, userdata); sdsfree(msg); } diff --git a/src/libpcp_web/src/slots.h b/src/libpcp_web/src/slots.h index d9209da0f44..5b0d8d3341d 100644 --- a/src/libpcp_web/src/slots.h +++ b/src/libpcp_web/src/slots.h @@ -14,7 +14,7 @@ #ifndef SLOTS_H #define SLOTS_H -#include +#include #include #include "batons.h" #include "keys.h" @@ -79,13 +79,19 @@ typedef struct keySlotsReplyData { typedef void (*keyPhase)(keySlots *, void *); /* phased operations */ +/* Wrapper struct that holds both keySlots and the original connection options */ +typedef struct keySlotsContext { + keySlots slots; /* the key slots structure */ + valkeyClusterOptions opts; /* original connection options */ +} keySlotsContext; + extern void keySlotsSetupMetrics(keySlots *); extern int keySlotsSetMetricRegistry(keySlots *, mmv_registry_t *); -extern keySlots *keySlotsInit(dict *, void *); -extern keySlots *keySlotsConnect(dict *, keySlotsFlags, +extern keySlotsContext *keySlotsInit(dict *, void *); +extern keySlotsContext *keySlotsConnect(dict *, keySlotsFlags, keysInfoCallBack, keysDoneCallBack, void *, void *, void *); extern void keySlotsReconnect(keySlots *, keySlotsFlags, - keysInfoCallBack, keysDoneCallBack, void *, void *, void *); + keysInfoCallBack, keysDoneCallBack, void *, void *, void *, valkeyClusterOptions *); extern uint64_t keySlotsInflightRequests(keySlots *); extern int keySlotsRequest(keySlots *, sds, keyClusterCallbackFn *, void *); extern int keySlotsRequestFirstNode(keySlots *slots, const sds cmd, From 8c1d2179b41fc90d1464c1322aa3146234db79c8 Mon Sep 17 00:00:00 2001 From: Sam Feifer Date: Tue, 16 Sep 2025 12:35:32 -0400 Subject: [PATCH 05/11] libvalkey migration for keys files --- src/libpcp_web/src/keys.h | 84 +++++++++++++++++++-------------------- src/pmproxy/src/keys.c | 31 ++++++++++++--- 2 files changed, 68 insertions(+), 47 deletions(-) diff --git a/src/libpcp_web/src/keys.h b/src/libpcp_web/src/keys.h index 2dd87a0a930..c9d4d17e4b8 100644 --- a/src/libpcp_web/src/keys.h +++ b/src/libpcp_web/src/keys.h @@ -30,13 +30,13 @@ #ifndef RESP_KEYS_H #define RESP_KEYS_H -#include -#include +#include +#include -#define RESP_OK REDIS_OK -#define RESP_ERR REDIS_ERR -#define RESP_ERR_IO REDIS_ERR_IO -#define RESP_CONN_UNIX REDIS_CONN_UNIX +#define RESP_OK VALKEY_OK +#define RESP_ERR VALKEY_ERR +#define RESP_ERR_IO VALKEY_ERR_IO +#define RESP_CONN_UNIX VALKEY_CONN_UNIX /* * Unfortunately there is no error code for these errors to use. @@ -47,49 +47,49 @@ #define RESP_ELOADDATA "loading the dataset in memory" #define RESP_ENOCLUSTER "ERR This instance has cluster support disabled" -#define RESP_KEEPALIVE_INTERVAL REDIS_KEEPALIVE_INTERVAL +#define RESP_KEEPALIVE_INTERVAL VALKEY_KEEPALIVE_INTERVAL /* * Protocol reply types */ -#define RESP_REPLY_STRING REDIS_REPLY_STRING -#define RESP_REPLY_ARRAY REDIS_REPLY_ARRAY -#define RESP_REPLY_BOOL REDIS_REPLY_BOOL -#define RESP_REPLY_DOUBLE REDIS_REPLY_DOUBLE -#define RESP_REPLY_INTEGER REDIS_REPLY_INTEGER -#define RESP_REPLY_MAP REDIS_REPLY_MAP -#define RESP_REPLY_NIL REDIS_REPLY_NIL -#define RESP_REPLY_SET REDIS_REPLY_SET -#define RESP_REPLY_STATUS REDIS_REPLY_STATUS -#define RESP_REPLY_ERROR REDIS_REPLY_ERROR +#define RESP_REPLY_STRING VALKEY_REPLY_STRING +#define RESP_REPLY_ARRAY VALKEY_REPLY_ARRAY +#define RESP_REPLY_BOOL VALKEY_REPLY_BOOL +#define RESP_REPLY_DOUBLE VALKEY_REPLY_DOUBLE +#define RESP_REPLY_INTEGER VALKEY_REPLY_INTEGER +#define RESP_REPLY_MAP VALKEY_REPLY_MAP +#define RESP_REPLY_NIL VALKEY_REPLY_NIL +#define RESP_REPLY_SET VALKEY_REPLY_SET +#define RESP_REPLY_STATUS VALKEY_REPLY_STATUS +#define RESP_REPLY_ERROR VALKEY_REPLY_ERROR -#define respReply redisReply -#define respReader redisReader -#define respReaderCreate redisReaderCreate -#define respReaderFeed redisReaderFeed -#define respReaderFree redisReaderFree -#define respReaderGetReply redisReaderGetReply +#define respReply valkeyReply +#define respReader valkeyReader +#define respReaderCreate valkeyReaderCreate +#define respReaderFeed valkeyReaderFeed +#define respReaderFree valkeyReaderFree +#define respReaderGetReply valkeyReaderGetReply -#define keysAsyncContext redisAsyncContext -#define keysAsyncEnableKeepAlive redisAsyncEnableKeepAlive -#define keysKeepAlive redisKeepAlive +#define keysAsyncContext valkeyAsyncContext +#define keysAsyncEnableKeepAlive valkeyAsyncEnableKeepAlive +#define keysKeepAlive valkeyKeepAlive -#define keyClusterAsyncFree redisClusterAsyncFree -#define keyClusterAsyncContext redisClusterAsyncContext -#define keyClusterAsyncContextInit redisClusterAsyncContextInit -#define keyClusterCallbackFn redisClusterCallbackFn -#define keyClusterConnect2 redisClusterConnect2 -#define keyClusterAsyncDisconnect redisClusterAsyncDisconnect -#define keyClusterSetOptionAddNodes redisClusterSetOptionAddNodes -#define keyClusterSetOptionPassword redisClusterSetOptionPassword -#define keyClusterSetOptionUsername redisClusterSetOptionUsername -#define keyClusterSetOptionConnectTimeout redisClusterSetOptionConnectTimeout -#define keyClusterSetOptionTimeout redisClusterSetOptionTimeout -#define keyClusterLibuvAttach redisClusterLibuvAttach -#define keyClusterAsyncSetConnectCallback redisClusterAsyncSetConnectCallback -#define keyClusterAsyncSetDisconnectCallback redisClusterAsyncSetDisconnectCallback -#define keyClusterAsyncFormattedCommand redisClusterAsyncFormattedCommand -#define keyClusterAsyncFormattedCommandToNode redisClusterAsyncFormattedCommandToNode +#define keyClusterAsyncFree valkeyClusterAsyncFree +#define keyClusterAsyncContext valkeyClusterAsyncContext +#define keyClusterAsyncContextInit valkeyClusterAsyncConnectWithOptions +#define keyClusterCallbackFn valkeyClusterCallbackFn +#define keyClusterConnect2 valkeyClusterConnectWithOptions +#define keyClusterAsyncDisconnect valkeyClusterAsyncDisconnect +#define keyClusterSetOptionAddNodes valkeyClusterOptions.initial_nodes +#define keyClusterSetOptionPassword valkeyClusterOptions.password +#define keyClusterSetOptionUsername valkeyClusterOptions.username +#define keyClusterSetOptionConnectTimeout valkeyClusterOptions.connect_timeout +#define keyClusterSetOptionTimeout valkeyClusterSetOptionTimeout +#define keyLibuvAttachAdapter valkeyLibuvAttachAdapter +#define keyClusterAsyncSetConnectCallback valkeyClusterOptions.async_connect_callback +#define keyClusterAsyncSetDisconnectCallback valkeyClusterOptions.async_disconnect_callback +#define keyClusterAsyncFormattedCommand valkeyClusterAsyncFormattedCommand +#define keyClusterAsyncFormattedCommandToNode valkeyClusterAsyncFormattedCommandToNode extern const char *resp_reply_type(respReply *); extern int keysAsyncEnableKeepAlive(keysAsyncContext *); diff --git a/src/pmproxy/src/keys.c b/src/pmproxy/src/keys.c index 75a6c0a5425..b49d040a204 100644 --- a/src/pmproxy/src/keys.c +++ b/src/pmproxy/src/keys.c @@ -16,6 +16,12 @@ #define KEY_SERVER_RECONNECT_INTERVAL 2 +/* Struct to hold proxy and options for the callback */ +typedef struct key_server_connect_data { + struct proxy *proxy; /* proxy instance */ + valkeyClusterOptions *opts; /* connection options for reconnection */ +} key_server_connect_data_t; + static int search_queries; static int series_queries; static int key_server_resp; @@ -196,7 +202,9 @@ get_key_slots_flags() static void key_server_reconnect_worker(void *arg) { - struct proxy *proxy = (struct proxy *)arg; + key_server_connect_data_t *connect_data = (key_server_connect_data_t *)arg; + struct proxy *proxy = connect_data->proxy; + valkeyClusterOptions *opts = connect_data->opts; static unsigned int wait_sec = KEY_SERVER_RECONNECT_INTERVAL; /* wait X seconds, because this timer callback is called every second */ @@ -213,11 +221,11 @@ key_server_reconnect_worker(void *arg) return; if (pmDebugOptions.desperate) - proxylog(PMLOG_INFO, "Trying to connect to key server ...", arg); + proxylog(PMLOG_INFO, "Trying to connect to key server ...", proxy); keySlotsFlags flags = get_key_slots_flags(); keySlotsReconnect(proxy->slots, flags, proxylog, on_key_server_connected, - proxy, proxy->events, proxy); + proxy, proxy->events, proxy, opts); } /* @@ -229,6 +237,8 @@ void setup_keys_module(struct proxy *proxy) { sds option; + key_server_connect_data_t *connect_data; + keySlotsContext *context; if ((option = pmIniFileLookup(config, "keys", "enabled")) && (strcmp(option, "false") == 0)) @@ -256,12 +266,23 @@ setup_keys_module(struct proxy *proxy) mmv_registry_t *registry = proxymetrics(proxy, METRICS_KEYS); keySlotsFlags flags = get_key_slots_flags(); - proxy->slots = keySlotsConnect(proxy->config, + context = keySlotsConnect(proxy->config, flags, proxylog, on_key_server_connected, proxy, proxy->events, proxy); + + proxy->slots = &context->slots; + keySlotsSetMetricRegistry(proxy->slots, registry); keySlotsSetupMetrics(proxy->slots); - pmWebTimerRegister(key_server_reconnect_worker, proxy); + + if ((connect_data = (key_server_connect_data_t *)calloc(1, sizeof(key_server_connect_data_t))) == NULL) { + pmNotifyErr(LOG_ERR, "Failed to allocate connect data for key server reconnection\n"); + return; + } + connect_data->proxy = proxy; + connect_data->opts = &context->opts; + + pmWebTimerRegister(key_server_reconnect_worker, connect_data); } } From 6650e22cd2469997a196ae17d5ef8c2948e33e56 Mon Sep 17 00:00:00 2001 From: Sam Feifer Date: Thu, 30 Oct 2025 12:56:35 -0400 Subject: [PATCH 06/11] vendor libvalkey library --- .../valkey-io/libvalkey/.clang-format | 25 + .../libvalkey/.git-blame-ignore-revs | 11 + .../libvalkey/.github/dependabot.yml | 14 + .../.github/release-drafter-config.yml | 48 + .../libvalkey/.github/spellcheck-settings.yml | 29 + .../valkey-io/libvalkey/.github/typos.toml | 20 + .../valkey-io/libvalkey/.github/wordlist.txt | 105 + .../libvalkey/.github/workflows/build.yml | 108 + .../libvalkey/.github/workflows/ci.yml | 302 ++ .../libvalkey/.github/workflows/coverity.yml | 31 + .../.github/workflows/db-compatibility.yml | 110 + .../.github/workflows/release-drafter.yml | 19 + .../.github/workflows/spellcheck.yml | 28 + .../github.com/valkey-io/libvalkey/.gitignore | 6 + .../valkey-io/libvalkey/CMakeLists.txt | 334 ++ .../valkey-io/libvalkey/CONTRIBUTING.md | 85 + vendor/github.com/valkey-io/libvalkey/COPYING | 53 + .../github.com/valkey-io/libvalkey/Makefile | 350 ++ .../github.com/valkey-io/libvalkey/README.md | 69 + .../valkey-io/libvalkey/docs/cluster.md | 430 +++ .../libvalkey/docs/migration-guide.md | 105 + .../valkey-io/libvalkey/docs/standalone.md | 376 ++ .../libvalkey/examples/CMakeLists.txt | 96 + .../valkey-io/libvalkey/examples/Makefile | 124 + .../valkey-io/libvalkey/examples/async-ae.c | 64 + .../valkey-io/libvalkey/examples/async-glib.c | 68 + .../libvalkey/examples/async-ivykis.c | 63 + .../libvalkey/examples/async-libev.c | 57 + .../libvalkey/examples/async-libevent-tls.c | 92 + .../libvalkey/examples/async-libevent.c | 68 + .../libvalkey/examples/async-libhv.c | 73 + .../libvalkey/examples/async-libsdevent.c | 89 + .../libvalkey/examples/async-libuv.c | 84 + .../libvalkey/examples/async-macosx.c | 96 + .../valkey-io/libvalkey/examples/async-poll.c | 64 + .../valkey-io/libvalkey/examples/async-qt.cpp | 47 + .../valkey-io/libvalkey/examples/async-qt.h | 31 + .../examples/async-valkeymoduleapi.c | 92 + .../libvalkey/examples/blocking-push.c | 161 + .../libvalkey/examples/blocking-tls.c | 112 + .../valkey-io/libvalkey/examples/blocking.c | 148 + .../libvalkey/examples/cluster-async-tls.c | 103 + .../libvalkey/examples/cluster-async.c | 101 + .../cluster-clientside-caching-async.c | 163 + .../libvalkey/examples/cluster-simple.c | 33 + .../libvalkey/examples/cluster-tls.c | 58 + .../libvalkey/include/valkey/adapters/ae.h | 154 + .../libvalkey/include/valkey/adapters/glib.h | 167 + .../include/valkey/adapters/ivykis.h | 102 + .../libvalkey/include/valkey/adapters/libev.h | 207 + .../include/valkey/adapters/libevent.h | 196 + .../libvalkey/include/valkey/adapters/libhv.h | 143 + .../include/valkey/adapters/libsdevent.h | 198 + .../libvalkey/include/valkey/adapters/libuv.h | 217 ++ .../include/valkey/adapters/macosx.h | 163 + .../libvalkey/include/valkey/adapters/poll.h | 214 ++ .../libvalkey/include/valkey/adapters/qt.h | 135 + .../include/valkey/adapters/valkeymoduleapi.h | 143 + .../libvalkey/include/valkey/alloc.h | 97 + .../libvalkey/include/valkey/async.h | 158 + .../libvalkey/include/valkey/cluster.h | 342 ++ .../valkey-io/libvalkey/include/valkey/net.h | 53 + .../valkey-io/libvalkey/include/valkey/rdma.h | 69 + .../valkey-io/libvalkey/include/valkey/read.h | 130 + .../libvalkey/include/valkey/sockcompat.h | 101 + .../valkey-io/libvalkey/include/valkey/tls.h | 162 + .../libvalkey/include/valkey/valkey.h | 387 ++ .../libvalkey/include/valkey/visibility.h | 49 + .../libvalkey/scripts/format-files.sh | 5 + .../libvalkey/scripts/gencommands.py | 234 ++ .../valkey-io/libvalkey/src/adlist.c | 334 ++ .../valkey-io/libvalkey/src/adlist.h | 94 + .../valkey-io/libvalkey/src/alloc.c | 92 + .../valkey-io/libvalkey/src/async.c | 1152 ++++++ .../valkey-io/libvalkey/src/async_private.h | 85 + .../valkey-io/libvalkey/src/cluster.c | 3394 +++++++++++++++++ .../valkey-io/libvalkey/src/cmddef.h | 379 ++ .../valkey-io/libvalkey/src/command.c | 387 ++ .../valkey-io/libvalkey/src/command.h | 87 + .../github.com/valkey-io/libvalkey/src/conn.c | 59 + .../valkey-io/libvalkey/src/crc16.c | 83 + .../github.com/valkey-io/libvalkey/src/dict.c | 380 ++ .../github.com/valkey-io/libvalkey/src/dict.h | 106 + .../valkey-io/libvalkey/src/fmacros.h | 14 + .../github.com/valkey-io/libvalkey/src/net.c | 707 ++++ .../github.com/valkey-io/libvalkey/src/rdma.c | 1007 +++++ .../github.com/valkey-io/libvalkey/src/read.c | 821 ++++ .../github.com/valkey-io/libvalkey/src/sds.c | 1436 +++++++ .../github.com/valkey-io/libvalkey/src/sds.h | 281 ++ .../valkey-io/libvalkey/src/sdsalloc.h | 44 + .../valkey-io/libvalkey/src/sockcompat.c | 306 ++ .../github.com/valkey-io/libvalkey/src/tls.c | 624 +++ .../valkey-io/libvalkey/src/valkey.c | 1253 ++++++ .../valkey-io/libvalkey/src/valkey_private.h | 136 + .../valkey-io/libvalkey/src/vkutil.c | 54 + .../valkey-io/libvalkey/src/vkutil.h | 86 + .../valkey-io/libvalkey/src/win32.h | 101 + .../valkey-io/libvalkey/tests/CMakeLists.txt | 298 ++ .../valkey-io/libvalkey/tests/client_test.c | 2886 ++++++++++++++ .../valkey-io/libvalkey/tests/clusterclient.c | 156 + .../libvalkey/tests/clusterclient_async.c | 299 ++ .../valkey-io/libvalkey/tests/ct_async.c | 83 + .../valkey-io/libvalkey/tests/ct_async_glib.c | 66 + .../libvalkey/tests/ct_async_libev.c | 62 + .../libvalkey/tests/ct_async_libuv.c | 66 + .../valkey-io/libvalkey/tests/ct_commands.c | 496 +++ .../valkey-io/libvalkey/tests/ct_connection.c | 576 +++ .../libvalkey/tests/ct_connection_ipv6.c | 39 + .../tests/ct_out_of_memory_handling.c | 534 +++ .../valkey-io/libvalkey/tests/ct_pipeline.c | 146 + .../libvalkey/tests/ct_specific_nodes.c | 531 +++ .../ask-redirect-connection-error-test.sh | 83 + .../tests/scripts/ask-redirect-test.sh | 75 + .../ask-redirect-using-cluster-nodes-test.sh | 79 + .../tests/scripts/client-disconnect-test.sh | 75 + ...-disconnect-without-slotmap-update-test.sh | 104 + .../tests/scripts/cluster-down-test.sh | 102 + .../tests/scripts/cluster-scale-down-test.sh | 110 + .../scripts/command-from-callback-test.sh | 119 + .../connect-during-cluster-startup-test.sh | 90 + ...luster-startup-using-cluster-nodes-test.sh | 68 + .../connect-error-using-cluster-nodes-test.sh | 56 + .../tests/scripts/connection-error-test.sh | 95 + ...o-all-nodes-during-scaledown-test-async.sh | 94 + ...size-to-all-nodes-during-scaledown-test.sh | 103 + .../tests/scripts/dbsize-to-all-nodes-test.sh | 66 + .../tests/scripts/moved-redirect-test.sh | 106 + ...moved-redirect-using-cluster-nodes-test.sh | 72 + .../scripts/redirect-with-hostname-test.sh | 99 + .../tests/scripts/redirect-with-ipv6-test.sh | 90 + .../libvalkey/tests/scripts/redis-cluster | 45 + .../libvalkey/tests/scripts/set-get-test.sh | 52 + .../tests/scripts/simulated-valkey.pl | 259 ++ .../scripts/slots-not-served-test-async.sh | 67 + .../tests/scripts/slots-not-served-test.sh | 70 + .../tests/scripts/timeout-handling-test.sh | 104 + .../libvalkey/tests/scripts/valkey-cluster | 40 + .../valkey-io/libvalkey/tests/test.sh | 145 + .../valkey-io/libvalkey/tests/test_utils.c | 65 + .../valkey-io/libvalkey/tests/test_utils.h | 83 + .../valkey-io/libvalkey/tests/ut_parse_cmd.c | 204 + .../libvalkey/tests/ut_slotmap_update.c | 821 ++++ .../libvalkey/valkey-config.cmake.in | 13 + .../valkey-io/libvalkey/valkey.pc.in | 12 + .../libvalkey/valkey_rdma-config.cmake.in | 13 + .../valkey-io/libvalkey/valkey_rdma.pc.in | 13 + .../libvalkey/valkey_tls-config.cmake.in | 15 + .../valkey-io/libvalkey/valkey_tls.pc.in | 13 + 148 files changed, 32031 insertions(+) create mode 100644 vendor/github.com/valkey-io/libvalkey/.clang-format create mode 100644 vendor/github.com/valkey-io/libvalkey/.git-blame-ignore-revs create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/dependabot.yml create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/release-drafter-config.yml create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/spellcheck-settings.yml create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/typos.toml create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/wordlist.txt create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/workflows/build.yml create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/workflows/ci.yml create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/workflows/coverity.yml create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/workflows/db-compatibility.yml create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/workflows/release-drafter.yml create mode 100644 vendor/github.com/valkey-io/libvalkey/.github/workflows/spellcheck.yml create mode 100644 vendor/github.com/valkey-io/libvalkey/.gitignore create mode 100644 vendor/github.com/valkey-io/libvalkey/CMakeLists.txt create mode 100644 vendor/github.com/valkey-io/libvalkey/CONTRIBUTING.md create mode 100644 vendor/github.com/valkey-io/libvalkey/COPYING create mode 100644 vendor/github.com/valkey-io/libvalkey/Makefile create mode 100644 vendor/github.com/valkey-io/libvalkey/README.md create mode 100644 vendor/github.com/valkey-io/libvalkey/docs/cluster.md create mode 100644 vendor/github.com/valkey-io/libvalkey/docs/migration-guide.md create mode 100644 vendor/github.com/valkey-io/libvalkey/docs/standalone.md create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/CMakeLists.txt create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/Makefile create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-ae.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-glib.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-ivykis.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-libev.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-libevent-tls.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-libevent.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-libhv.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-libsdevent.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-libuv.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-macosx.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-poll.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-qt.cpp create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-qt.h create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/async-valkeymoduleapi.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/blocking-push.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/blocking-tls.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/blocking.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/cluster-async-tls.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/cluster-async.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/cluster-clientside-caching-async.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/cluster-simple.c create mode 100644 vendor/github.com/valkey-io/libvalkey/examples/cluster-tls.c create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/ae.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/glib.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/ivykis.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/libev.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/libevent.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/libhv.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/libsdevent.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/libuv.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/macosx.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/poll.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/qt.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/adapters/valkeymoduleapi.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/alloc.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/async.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/cluster.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/net.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/rdma.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/read.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/sockcompat.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/tls.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/valkey.h create mode 100644 vendor/github.com/valkey-io/libvalkey/include/valkey/visibility.h create mode 100755 vendor/github.com/valkey-io/libvalkey/scripts/format-files.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/scripts/gencommands.py create mode 100644 vendor/github.com/valkey-io/libvalkey/src/adlist.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/adlist.h create mode 100644 vendor/github.com/valkey-io/libvalkey/src/alloc.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/async.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/async_private.h create mode 100644 vendor/github.com/valkey-io/libvalkey/src/cluster.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/cmddef.h create mode 100644 vendor/github.com/valkey-io/libvalkey/src/command.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/command.h create mode 100644 vendor/github.com/valkey-io/libvalkey/src/conn.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/crc16.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/dict.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/dict.h create mode 100644 vendor/github.com/valkey-io/libvalkey/src/fmacros.h create mode 100644 vendor/github.com/valkey-io/libvalkey/src/net.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/rdma.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/read.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/sds.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/sds.h create mode 100644 vendor/github.com/valkey-io/libvalkey/src/sdsalloc.h create mode 100644 vendor/github.com/valkey-io/libvalkey/src/sockcompat.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/tls.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/valkey.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/valkey_private.h create mode 100644 vendor/github.com/valkey-io/libvalkey/src/vkutil.c create mode 100644 vendor/github.com/valkey-io/libvalkey/src/vkutil.h create mode 100644 vendor/github.com/valkey-io/libvalkey/src/win32.h create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/CMakeLists.txt create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/client_test.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/clusterclient.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/clusterclient_async.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ct_async.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ct_async_glib.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ct_async_libev.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ct_async_libuv.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ct_commands.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ct_connection.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ct_connection_ipv6.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ct_out_of_memory_handling.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ct_pipeline.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ct_specific_nodes.c create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/ask-redirect-connection-error-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/ask-redirect-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/ask-redirect-using-cluster-nodes-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/client-disconnect-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/client-disconnect-without-slotmap-update-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/cluster-down-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/cluster-scale-down-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/command-from-callback-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/connect-during-cluster-startup-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/connect-during-cluster-startup-using-cluster-nodes-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/connect-error-using-cluster-nodes-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/connection-error-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/dbsize-to-all-nodes-during-scaledown-test-async.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/dbsize-to-all-nodes-during-scaledown-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/dbsize-to-all-nodes-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/moved-redirect-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/moved-redirect-using-cluster-nodes-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/redirect-with-hostname-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/redirect-with-ipv6-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/redis-cluster create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/set-get-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/simulated-valkey.pl create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/slots-not-served-test-async.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/slots-not-served-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/timeout-handling-test.sh create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/scripts/valkey-cluster create mode 100755 vendor/github.com/valkey-io/libvalkey/tests/test.sh create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/test_utils.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/test_utils.h create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ut_parse_cmd.c create mode 100644 vendor/github.com/valkey-io/libvalkey/tests/ut_slotmap_update.c create mode 100644 vendor/github.com/valkey-io/libvalkey/valkey-config.cmake.in create mode 100644 vendor/github.com/valkey-io/libvalkey/valkey.pc.in create mode 100644 vendor/github.com/valkey-io/libvalkey/valkey_rdma-config.cmake.in create mode 100644 vendor/github.com/valkey-io/libvalkey/valkey_rdma.pc.in create mode 100644 vendor/github.com/valkey-io/libvalkey/valkey_tls-config.cmake.in create mode 100644 vendor/github.com/valkey-io/libvalkey/valkey_tls.pc.in diff --git a/vendor/github.com/valkey-io/libvalkey/.clang-format b/vendor/github.com/valkey-io/libvalkey/.clang-format new file mode 100644 index 00000000000..cc1765e38c2 --- /dev/null +++ b/vendor/github.com/valkey-io/libvalkey/.clang-format @@ -0,0 +1,25 @@ +BasedOnStyle: LLVM +ColumnLimit: 0 +IndentWidth: 4 +BreakBeforeTernaryOperators: false +ReflowComments: false +AllowAllArgumentsOnNextLine: true +AlignTrailingComments: Always +IncludeBlocks: Regroup +IncludeCategories: + # Headers that must always be first since they define macros that affect the + # other includes are listed with priority = -1 + - Regex: '^"(fmacros|win32).h"' + Priority: -1 + - Regex: '^"' + Priority: 1 + - Regex: '^<(sds|dict).h>' + Priority: 2 + - Regex: '^