From 6dfb8203cc55ec3b05f838eee23ebcc92b953679 Mon Sep 17 00:00:00 2001 From: Eran Liberty Date: Tue, 13 Aug 2024 02:33:23 +0300 Subject: [PATCH] Add debug-context config (#874) A configuration option with zero impact on server operation but is printed out on server crash and can be accessed by gdb for debugging. It can be used by the user/operator to store any free-form string. This string will persist as long as the server is running and will be accessible in the following ways: And printed in crash reports: ``` ------ CONFIG DEBUG OUTPUT ------ lazyfree-lazy-eviction no ... io-threads-do-reads yes debug-context "test2" proto-max-bulk-len 512mb ``` --------- Signed-off-by: Eran Liberty Co-authored-by: Eran Liberty --- src/config.c | 1 + src/server.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/config.c b/src/config.c index ae60dd3fd..afac82be6 100644 --- a/src/config.c +++ b/src/config.c @@ -3135,6 +3135,7 @@ standardConfig static_configs[] = { createStringConfig("req-res-logfile", NULL, IMMUTABLE_CONFIG | HIDDEN_CONFIG, EMPTY_STRING_IS_NULL, server.req_res_logfile, NULL, NULL, NULL), #endif createStringConfig("locale-collate", NULL, MODIFIABLE_CONFIG, ALLOW_EMPTY_STRING, server.locale_collate, "", NULL, updateLocaleCollate), + createStringConfig("debug-context", NULL, MODIFIABLE_CONFIG | DEBUG_CONFIG | HIDDEN_CONFIG, ALLOW_EMPTY_STRING, server.debug_context, "", NULL, NULL), /* SDS Configs */ createSDSConfig("primaryauth", "masterauth", MODIFIABLE_CONFIG | SENSITIVE_CONFIG, EMPTY_STRING_IS_NULL, server.primary_auth, NULL, NULL, NULL), diff --git a/src/server.h b/src/server.h index ccdece20d..10173daac 100644 --- a/src/server.h +++ b/src/server.h @@ -2219,6 +2219,7 @@ struct valkeyServer { sds availability_zone; /* When run in a cloud environment we can configure the availability zone it is running in */ /* Local environment */ char *locale_collate; + char *debug_context; /* A free-form string that has no impact on server except being included in a crash report. */ }; #define MAX_KEYS_BUFFER 256