Introduced command PROXYSQL FLUSH CONFIGDB #923

New command `PROXYSQL FLUSH CONFIGDB` allows to close and reopen configdb (`proxysql.db` on disk).

Note:
It is important that the (new) configdb is a valid one.
A misconfigured configdb will cause undefined behaviors.
v1.4.0-955
René Cannaò 9 years ago
parent 011b0f8749
commit f183ea1651

@ -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 */

@ -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;

Loading…
Cancel
Save