diff --git a/include/maxscale/router.h b/include/maxscale/router.h index fe4ac857a..fbfa0aaed 100644 --- a/include/maxscale/router.h +++ b/include/maxscale/router.h @@ -113,4 +113,26 @@ typedef enum TYPE_ALL } mxs_target_t; +/** + * @brief Convert mxs_target_t to a string + * + * @param target Target to convert + * + * @return Target type as string + */ +static inline const char* mxs_target_to_str(mxs_target_t target) +{ + switch (target) + { + case TYPE_MASTER: + return "master"; + + case TYPE_ALL: + return "all"; + + default: + return "UNDEFINED"; + } +} + MXS_END_DECLS diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index 1a2374dc9..71a979717 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -596,6 +596,27 @@ static void diagnostics(MXS_ROUTER *instance, DCB *dcb) char *weightby; double master_pct = 0.0, slave_pct = 0.0, all_pct = 0.0; + dcb_printf(dcb, "\n"); + dcb_printf(dcb, "\tuse_sql_variables_in: %s\n", + mxs_target_to_str(router->rwsplit_config.use_sql_variables_in)); + dcb_printf(dcb, "\tslave_selection_criteria: %s\n", + select_criteria_to_str(router->rwsplit_config.slave_selection_criteria)); + dcb_printf(dcb, "\tmaster_failure_mode: %s\n", + failure_mode_to_str(router->rwsplit_config.master_failure_mode)); + dcb_printf(dcb, "\tmax_slave_replication_lag: %d\n", + router->rwsplit_config.max_slave_replication_lag); + dcb_printf(dcb, "\tretry_failed_reads: %s\n", + router->rwsplit_config.retry_failed_reads ? "true" : "false"); + dcb_printf(dcb, "\tstrict_multi_stmt: %s\n", + router->rwsplit_config.strict_multi_stmt ? "true" : "false"); + dcb_printf(dcb, "\tdisable_sescmd_history: %s\n", + router->rwsplit_config.disable_sescmd_history ? "true" : "false"); + dcb_printf(dcb, "\tmax_sescmd_history: %d\n", + router->rwsplit_config.max_sescmd_history); + dcb_printf(dcb, "\tmaster_accept_reads: %s\n", + router->rwsplit_config.master_accept_reads ? "true" : "false"); + dcb_printf(dcb, "\n"); + if (router->stats.n_queries > 0) { master_pct = ((double)router->stats.n_master / (double)router->stats.n_queries) * 100.0; diff --git a/server/modules/routing/readwritesplit/readwritesplit.h b/server/modules/routing/readwritesplit/readwritesplit.h index 536a391be..b00bd1e25 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.h +++ b/server/modules/routing/readwritesplit/readwritesplit.h @@ -110,6 +110,55 @@ typedef enum select_criteria LAST_CRITERIA /*< not used except for an index */ } select_criteria_t; +static inline const char* select_criteria_to_str(select_criteria_t type) +{ + switch (type) + { + case LEAST_GLOBAL_CONNECTIONS: + return "LEAST_GLOBAL_CONNECTIONS"; + + case LEAST_ROUTER_CONNECTIONS: + return "LEAST_ROUTER_CONNECTIONS"; + + case LEAST_BEHIND_MASTER: + return "LEAST_BEHIND_MASTER"; + + case LEAST_CURRENT_OPERATIONS: + return "LEAST_CURRENT_OPERATIONS"; + + default: + return "UNDEFINED_CRITERIA"; + } +} + +/** + * Controls how master failure is handled + */ +enum failure_mode +{ + RW_FAIL_INSTANTLY, /**< Close the connection as soon as the master is lost */ + RW_FAIL_ON_WRITE, /**< Close the connection when the first write is received */ + RW_ERROR_ON_WRITE /**< Don't close the connection but send an error for writes */ +}; + +static inline const char* failure_mode_to_str(enum failure_mode type) +{ + switch (type) + { + case RW_FAIL_INSTANTLY: + return "fail_instantly"; + + case RW_FAIL_ON_WRITE: + return "fail_on_write"; + + case RW_ERROR_ON_WRITE: + return "error_on_write"; + + default: + ss_dassert(false); + return "UNDEFINED_MODE"; + } +} /** default values for rwsplit configuration parameters */ #define CONFIG_MAX_SLAVE_CONN 1 @@ -209,16 +258,6 @@ typedef struct backend_ref_st int closed_at; /** DEBUG: Line number where this backend reference was closed */ } backend_ref_t; -/** - * Controls how master failure is handled - */ -enum failure_mode -{ - RW_FAIL_INSTANTLY, /**< Close the connection as soon as the master is lost */ - RW_FAIL_ON_WRITE, /**< Close the connection when the first write is received */ - RW_ERROR_ON_WRITE /**< Don't close the connection but send an error for writes */ -}; - typedef struct rwsplit_config_st { int rw_max_slave_conn_percent; /**< Maximum percentage of slaves