From 32b1711684af69011ce896dd3b2179a1a90601e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 10 Aug 2018 23:18:54 +0300 Subject: [PATCH] MXS-2005: Remove logging to shared memory The feature was rarely used and was only useful in extremely rare cases. The functionality can still be emulated, if for some reason needed, by pointing `logdir` to `/dev/shm` or another tmpfs mount. --- .../Getting-Started/Configuration-Guide.md | 32 +++---------------- .../MaxScale-2.3.0-Release-Notes.md | 9 ++++++ include/maxscale/config.h | 1 - include/maxscale/log_manager.h | 7 ++-- server/core/config.cc | 1 - server/core/gateway.cc | 23 ++++--------- 6 files changed, 24 insertions(+), 49 deletions(-) diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index 78aa7d974..4ff64be65 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -301,34 +301,12 @@ disable use the value 0. #### `log_to_shm` -Enable or disable the writing of the *maxscale.log* file to shared memory. If -enabled, then the actual log file will be created under `/dev/shm` and a -symbolic link to that file will be created in the *MaxScale* log directory. +**Note:** This parameter is deprecated and it is ignored by MaxScale versions + 2.3.0 and newer. If you want to store the log in shared memory, define the + directory with `logdir` in `/dev/shm`. -Logging to shared memory may be appropriate if *log_info* and/or *log_debug* are -enabled, as logging to a regular file may in that case cause performance -degradation, due to the amount of data logged. However, as shared memory is a -scarce resource, logging to shared memory should be used only temporarily and -not regularly. - -Since *MariaDB MaxScale* can log to both file and *syslog* an approach that -provides maximum flexibility is to enable *syslog* and *log_to_shm*, and to -disable *maxlog*. That way messages will normally be logged to *syslog*, but if -there is something to investigate, *log_debug* and *maxlog* can be enabled from -*maxadmin*, in which case informational messages will be logged to the -*maxscale.log* file that resides in shared memory. But note that *log_debug* -messages will only be available if MaxScale has been built in debug mode. - -By default, logging to shared memory is disabled. - -``` -# Valid options are: -# log_to_shm=<0|1> -log_to_shm=1 -``` - -To enable logging to shared memory use the value 1 and to disable use the value -0. +In older MaxScale versions, the actual log file was created in `/dev/shm` and a +symbolic link to that file was stored in place of the normal MaxScale log. #### `log_warning` diff --git a/Documentation/Release-Notes/MaxScale-2.3.0-Release-Notes.md b/Documentation/Release-Notes/MaxScale-2.3.0-Release-Notes.md index f658b0b0d..bf283b9b5 100644 --- a/Documentation/Release-Notes/MaxScale-2.3.0-Release-Notes.md +++ b/Documentation/Release-Notes/MaxScale-2.3.0-Release-Notes.md @@ -61,6 +61,15 @@ deprecated. If you need to explicitly set the stack size, do so using ## Dropped Features +### `log_to_shm` parameter and `--log=shm` option + +The following commands no longer create the log files in shared memory and will +be ignored. MaxScale will behave as if `--log=file` was provided when +`--log=shm` is used. The `log_to_shm` parameter is ignored. Both the parameter +and the optino value are deprecated and will be removed in a later relesae. + +Logs can still be created in shared memory by pointing `logdir` to `/dev/shm`. + ### Configuration Reloading The deprecated `maxadmin reload config` command has been removed. diff --git a/include/maxscale/config.h b/include/maxscale/config.h index b9dada22f..d8112ee74 100644 --- a/include/maxscale/config.h +++ b/include/maxscale/config.h @@ -250,7 +250,6 @@ typedef struct unsigned int pollsleep; /**< Wait time in blocking polls */ int syslog; /**< Log to syslog */ int maxlog; /**< Log to MaxScale's own logs */ - int log_to_shm; /**< Write log-file to shared memory */ unsigned int auth_conn_timeout; /**< Connection timeout for the user authentication */ unsigned int auth_read_timeout; /**< Read timeout for the user authentication */ unsigned int auth_write_timeout; /**< Write timeout for the user authentication */ diff --git a/include/maxscale/log_manager.h b/include/maxscale/log_manager.h index acb69aaef..5b08f126d 100644 --- a/include/maxscale/log_manager.h +++ b/include/maxscale/log_manager.h @@ -51,10 +51,9 @@ MXS_BEGIN_DECLS typedef enum { - MXS_LOG_TARGET_DEFAULT = 0, - MXS_LOG_TARGET_FS = 1, // File system - MXS_LOG_TARGET_SHMEM = 2, // Shared memory - MXS_LOG_TARGET_STDOUT = 3, // Standard output + MXS_LOG_TARGET_DEFAULT, + MXS_LOG_TARGET_FS, // File system + MXS_LOG_TARGET_STDOUT, // Standard output } mxs_log_target_t; /** diff --git a/server/core/config.cc b/server/core/config.cc index 52bd57ee6..1723ab401 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -2595,7 +2595,6 @@ void config_set_global_defaults() gateway.skip_permission_checks = false; gateway.syslog = 1; gateway.maxlog = 1; - gateway.log_to_shm = 0; gateway.admin_port = DEFAULT_ADMIN_HTTP_PORT; gateway.admin_auth = true; gateway.admin_log_auth_failures = true; diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 62f898a51..7d97f929f 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -952,7 +952,7 @@ static void usage(void) " -e, --export-config=FILE export configuration to a single file\n" " -d, --nodaemon enable running in terminal process\n" " -f, --config=FILE relative or absolute pathname of config file\n" - " -l, --log=[file|shm|stdout] log to file, shared memory or stdout\n" + " -l, --log=[file|stdout] log to file or stdout\n" " (default: file)\n" " -L, --logdir=PATH path to log file directory\n" " -A, --cachedir=PATH path to cache directory\n" @@ -1327,7 +1327,6 @@ int main(int argc, char **argv) ss_dassert(cnf); int *syslog_enabled = &cnf->syslog; /** Log to syslog */ int *maxlog_enabled = &cnf->maxlog; /** Log with MaxScale */ - int *log_to_shm = &cnf->log_to_shm; /** Log to shared memory */ sigset_t sigpipe_mask; sigset_t saved_mask; bool to_stdout = false; @@ -1441,19 +1440,17 @@ int main(int argc, char **argv) case 'l': if (strncasecmp(optarg, "file", PATH_MAX) == 0) { - *log_to_shm = false; - log_to_shm_configured = true; + to_stdout = false; } else if (strncasecmp(optarg, "shm", PATH_MAX) == 0) { - *log_to_shm = true; - log_to_shm_configured = true; + // Removed in 2.3 + to_stdout = false; + fprintf(stderr, "Warning: Use of `--log=shm` is deprecated. Data will be logged to file.\n"); } else if (strncasecmp(optarg, "stdout", PATH_MAX) == 0) { to_stdout = true; - *log_to_shm = false; - log_to_shm_configured = true; } else { @@ -1873,10 +1870,6 @@ int main(int argc, char **argv) { log_target = MXS_LOG_TARGET_STDOUT; } - else if (*log_to_shm) - { - log_target = MXS_LOG_TARGET_SHMEM; - } succp = mxs_log_init(NULL, get_logdir(), log_target); @@ -2769,10 +2762,8 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons } else if (strcmp(name, CN_LOG_TO_SHM) == 0) { - if (!log_to_shm_configured) - { - cnf->log_to_shm = config_truth_value((char*)value); - } + fprintf(stderr, "Warning: '%s' has been removed in MaxScale 2.3.0 " + "and will be ignored\n", CN_LOG_TO_SHM); } else if (strcmp(name, CN_SUBSTITUTE_VARIABLES) == 0) {