diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index 53229c717..a78fcb100 100644 --- a/include/proxysql_admin.h +++ b/include/proxysql_admin.h @@ -203,5 +203,7 @@ class ProxySQL_Admin { // wrapper to call a private function unsigned long long scheduler_run_once() { return scheduler->run_once(); } + void flush_configdb(); // 923 + }; #endif /* __CLASS_PROXYSQL_ADMIN_H */ diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 32f87a321..9aebcdaa0 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -490,6 +490,17 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_ return false; } + if ( + (query_no_space_length==strlen("PROXYSQL FLUSH CONFIGDB") && !strncasecmp("PROXYSQL FLUSH CONFIGDB",query_no_space, query_no_space_length)) // see #923 + ) { + proxy_info("Received %s command\n", query_no_space); + proxy_warning("A misconfigured configdb will cause undefined behaviors\n"); + ProxySQL_Admin *SPA=(ProxySQL_Admin *)pa; + SPA->flush_configdb(); + SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL); + return false; + } + #ifndef NOJEM if (query_no_space_length==strlen("PROXYSQL MEMPROFILE START") && !strncasecmp("PROXYSQL MEMPROFILE START",query_no_space, query_no_space_length)) { bool en=true; @@ -1211,6 +1222,15 @@ bool admin_handler_command_load_or_save(char *query_no_space, unsigned int query return true; } +void ProxySQL_Admin::flush_configdb() { // see #923 + wrlock(); + admindb->execute((char *)"DETACH DATABASE disk"); + delete configdb; + configdb=new SQLite3DB(); + configdb->open((char *)GloVars.admindb, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX); + __attach_db(admindb, configdb, (char *)"disk"); + wrunlock(); +} void ProxySQL_Admin::GenericRefreshStatistics(const char *query_no_space, unsigned int query_no_space_length, bool admin) { bool refresh=false;