Skip to content

Add settings to disable/enable MySQL/PostgreSQL module - Closes #4951 #4960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: v3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/PgSQL_HostGroups_Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#define MYHGM_PgSQL_SERVERS "CREATE TABLE pgsql_servers ( hostgroup_id INT NOT NULL DEFAULT 0 , hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 5432 , weight INT NOT NULL DEFAULT 1 , status INT NOT NULL DEFAULT 0 , compression INT NOT NULL DEFAULT 0 , max_connections INT NOT NULL DEFAULT 1000 , max_replication_lag INT NOT NULL DEFAULT 0 , use_ssl INT NOT NULL DEFAULT 0 , max_latency_ms INT UNSIGNED NOT NULL DEFAULT 0 , comment VARCHAR NOT NULL DEFAULT '' , mem_pointer INT NOT NULL DEFAULT 0 , PRIMARY KEY (hostgroup_id, hostname, port) )"
#define MYHGM_PgSQL_SERVERS_INCOMING "CREATE TABLE pgsql_servers_incoming ( hostgroup_id INT NOT NULL DEFAULT 0 , hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 5432 , weight INT NOT NULL DEFAULT 1 , status INT NOT NULL DEFAULT 0 , compression INT NOT NULL DEFAULT 0 , max_connections INT NOT NULL DEFAULT 1000 , max_replication_lag INT NOT NULL DEFAULT 0 , use_ssl INT NOT NULL DEFAULT 0 , max_latency_ms INT UNSIGNED NOT NULL DEFAULT 0 , comment VARCHAR NOT NULL DEFAULT '' , PRIMARY KEY (hostgroup_id, hostname, port))"
#endif /* DEBUG */
#define MYHGM_PgSQL_REPLICATION_HOSTGROUPS "CREATE TABLE pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only','innodb_read_only','super_read_only','read_only|innodb_read_only','read_only&innodb_read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '' , UNIQUE (reader_hostgroup))"
#define MYHGM_PgSQL_REPLICATION_HOSTGROUPS "CREATE TABLE pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '' , UNIQUE (reader_hostgroup))"

#define PGHGM_GEN_ADMIN_RUNTIME_SERVERS "SELECT hostgroup_id, hostname, port, CASE status WHEN 0 THEN \"ONLINE\" WHEN 1 THEN \"SHUNNED\" WHEN 2 THEN \"OFFLINE_SOFT\" WHEN 3 THEN \"OFFLINE_HARD\" WHEN 4 THEN \"SHUNNED\" END status, weight, compression, max_connections, max_replication_lag, use_ssl, max_latency_ms, comment FROM pgsql_servers ORDER BY hostgroup_id, hostname, port"

Expand Down
4 changes: 2 additions & 2 deletions include/ProxySQL_Admin_Tables_Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
#define ADMIN_SQLITE_TABLE_PGSQL_FIREWALL_WHITELIST_SQLI_FINGERPRINTS "CREATE TABLE pgsql_firewall_whitelist_sqli_fingerprints (active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , fingerprint VARCHAR NOT NULL , PRIMARY KEY (fingerprint) )"
#define ADMIN_SQLITE_TABLE_PGSQL_QUERY_RULES_FAST_ROUTING "CREATE TABLE pgsql_query_rules_fast_routing (username VARCHAR NOT NULL , database VARCHAR NOT NULL , flagIN INT NOT NULL DEFAULT 0 , destination_hostgroup INT CHECK (destination_hostgroup >= 0) NOT NULL , comment VARCHAR NOT NULL , PRIMARY KEY (username, database, flagIN) )"
#define ADMIN_SQLITE_TABLE_PGSQL_HOSTGROUP_ATTRIBUTES "CREATE TABLE pgsql_hostgroup_attributes (hostgroup_id INT NOT NULL PRIMARY KEY , max_num_online_servers INT CHECK (max_num_online_servers>=0 AND max_num_online_servers <= 1000000) NOT NULL DEFAULT 1000000 , autocommit INT CHECK (autocommit IN (-1, 0, 1)) NOT NULL DEFAULT -1 , free_connections_pct INT CHECK (free_connections_pct >= 0 AND free_connections_pct <= 100) NOT NULL DEFAULT 10 , init_connect VARCHAR NOT NULL DEFAULT '' , multiplex INT CHECK (multiplex IN (0, 1)) NOT NULL DEFAULT 1 , connection_warming INT CHECK (connection_warming IN (0, 1)) NOT NULL DEFAULT 0 , throttle_connections_per_sec INT CHECK (throttle_connections_per_sec >= 1 AND throttle_connections_per_sec <= 1000000) NOT NULL DEFAULT 1000000 , ignore_session_variables VARCHAR CHECK (JSON_VALID(ignore_session_variables) OR ignore_session_variables = '') NOT NULL DEFAULT '' , hostgroup_settings VARCHAR CHECK (JSON_VALID(hostgroup_settings) OR hostgroup_settings = '') NOT NULL DEFAULT '' , servers_defaults VARCHAR CHECK (JSON_VALID(servers_defaults) OR servers_defaults = '') NOT NULL DEFAULT '' , comment VARCHAR NOT NULL DEFAULT '')"
#define ADMIN_SQLITE_TABLE_PGSQL_REPLICATION_HOSTGROUPS "CREATE TABLE pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only','innodb_read_only','super_read_only','read_only|innodb_read_only','read_only&innodb_read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '', UNIQUE (reader_hostgroup))"
#define ADMIN_SQLITE_TABLE_PGSQL_REPLICATION_HOSTGROUPS "CREATE TABLE pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '', UNIQUE (reader_hostgroup))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since 3.0.1 we can't simply change table definition. We need an upgrade procedure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this may need a PR on its own.

Copy link
Collaborator Author

@JavierJF JavierJF May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if that is really worth it, the check type is never used in the PostgreSQL implementation, since only read_only (the default) is supported, which value is never really used either. A migration procedure for a unused settings seems unnecessary... But I can split it into another PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary because during bootstrap ProxySQL will delete any table that do not have the expected table definition. So even removing unused constraint should cause ProxySQL to drop and recreate the table.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh right! now I remember. The table is being rebuild automatically, so the entries already stored will be missing without the upgrade due to the rebuilding. Should I pack those changes in another PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, a dedicated PR is better, as it has nothing to do with start-up options.
Thanks!


#define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_SERVERS "CREATE TABLE runtime_pgsql_servers (hostgroup_id INT CHECK (hostgroup_id>=0) NOT NULL DEFAULT 0 , hostname VARCHAR NOT NULL , port INT CHECK (port >= 0 AND port <= 65535) NOT NULL DEFAULT 5432 , status VARCHAR CHECK (UPPER(status) IN ('ONLINE','SHUNNED','OFFLINE_SOFT', 'OFFLINE_HARD')) NOT NULL DEFAULT 'ONLINE' , weight INT CHECK (weight >= 0 AND weight <=10000000) NOT NULL DEFAULT 1 , compression INT CHECK (compression IN(0,1)) NOT NULL DEFAULT 0 , max_connections INT CHECK (max_connections >=0) NOT NULL DEFAULT 1000 , max_replication_lag INT CHECK (max_replication_lag >= 0 AND max_replication_lag <= 126144000) NOT NULL DEFAULT 0 , use_ssl INT CHECK (use_ssl IN(0,1)) NOT NULL DEFAULT 0 , max_latency_ms INT UNSIGNED CHECK (max_latency_ms>=0) NOT NULL DEFAULT 0 , comment VARCHAR NOT NULL DEFAULT '' , PRIMARY KEY (hostgroup_id, hostname, port) )"
#define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_USERS "CREATE TABLE runtime_pgsql_users (username VARCHAR NOT NULL , password VARCHAR , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , use_ssl INT CHECK (use_ssl IN (0,1)) NOT NULL DEFAULT 0 , default_hostgroup INT NOT NULL DEFAULT 0 , transaction_persistent INT CHECK (transaction_persistent IN (0,1)) NOT NULL DEFAULT 1 , fast_forward INT CHECK (fast_forward IN (0,1)) NOT NULL DEFAULT 0 , backend INT CHECK (backend IN (0,1)) NOT NULL DEFAULT 1 , frontend INT CHECK (frontend IN (0,1)) NOT NULL DEFAULT 1 , max_connections INT CHECK (max_connections >=0) NOT NULL DEFAULT 10000 , attributes VARCHAR CHECK (JSON_VALID(attributes) OR attributes = '') NOT NULL DEFAULT '', comment VARCHAR NOT NULL DEFAULT '' , PRIMARY KEY (username, backend) , UNIQUE (username, frontend))"
Expand All @@ -287,7 +287,7 @@
#define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_FIREWALL_WHITELIST_SQLI_FINGERPRINTS "CREATE TABLE runtime_pgsql_firewall_whitelist_sqli_fingerprints (active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , fingerprint VARCHAR NOT NULL , PRIMARY KEY (fingerprint) )"
#define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_QUERY_RULES_FAST_ROUTING "CREATE TABLE runtime_pgsql_query_rules_fast_routing (username VARCHAR NOT NULL , database VARCHAR NOT NULL , flagIN INT NOT NULL DEFAULT 0 , destination_hostgroup INT CHECK (destination_hostgroup >= 0) NOT NULL , comment VARCHAR NOT NULL , PRIMARY KEY (username, database, flagIN) )"
#define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_HOSTGROUP_ATTRIBUTES "CREATE TABLE runtime_pgsql_hostgroup_attributes (hostgroup_id INT NOT NULL PRIMARY KEY , max_num_online_servers INT CHECK (max_num_online_servers>=0 AND max_num_online_servers <= 1000000) NOT NULL DEFAULT 1000000 , autocommit INT CHECK (autocommit IN (-1, 0, 1)) NOT NULL DEFAULT -1 , free_connections_pct INT CHECK (free_connections_pct >= 0 AND free_connections_pct <= 100) NOT NULL DEFAULT 10 , init_connect VARCHAR NOT NULL DEFAULT '' , multiplex INT CHECK (multiplex IN (0, 1)) NOT NULL DEFAULT 1 , connection_warming INT CHECK (connection_warming IN (0, 1)) NOT NULL DEFAULT 0 , throttle_connections_per_sec INT CHECK (throttle_connections_per_sec >= 1 AND throttle_connections_per_sec <= 1000000) NOT NULL DEFAULT 1000000 , ignore_session_variables VARCHAR CHECK (JSON_VALID(ignore_session_variables) OR ignore_session_variables = '') NOT NULL DEFAULT '' , hostgroup_settings VARCHAR CHECK (JSON_VALID(hostgroup_settings) OR hostgroup_settings = '') NOT NULL DEFAULT '' , servers_defaults VARCHAR CHECK (JSON_VALID(servers_defaults) OR servers_defaults = '') NOT NULL DEFAULT '' , comment VARCHAR NOT NULL DEFAULT '')"
#define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_REPLICATION_HOSTGROUPS "CREATE TABLE runtime_pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only','innodb_read_only','super_read_only','read_only|innodb_read_only','read_only&innodb_read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '', UNIQUE (reader_hostgroup))"
#define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_REPLICATION_HOSTGROUPS "CREATE TABLE runtime_pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '', UNIQUE (reader_hostgroup))"

#define STATS_SQLITE_TABLE_PGSQL_GLOBAL "CREATE TABLE stats_pgsql_global (Variable_Name VARCHAR NOT NULL PRIMARY KEY , Variable_Value VARCHAR NOT NULL)"
#define STATS_SQLITE_TABLE_PGSQL_CONNECTION_POOL "CREATE TABLE stats_pgsql_connection_pool (hostgroup INT , srv_host VARCHAR , srv_port INT , status VARCHAR , ConnUsed INT , ConnFree INT , ConnOK INT , ConnERR INT , MaxConnUsed INT , Queries INT , Bytes_data_sent INT , Bytes_data_recv INT , Latency_us INT)"
Expand Down
4 changes: 4 additions & 0 deletions include/proxysql_glovars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class ProxySQL_GlobalVariables {
bool gdbg;
bool nostart;
bool my_monitor;
bool mysql_workers;
bool pgsql_workers;
bool mysql_admin;
bool pgsql_admin;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking: we should follow a pattern, either first all mysql variables then all posgres variables (or viceversa), or follow some order: *_monitor , *-workers , *_admin .

bool pg_monitor;
bool version_check;
#ifdef SO_REUSEPORT
Expand Down
10 changes: 6 additions & 4 deletions lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2060,8 +2060,10 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi
}
}
if (!strcasecmp(name,"threads")) {
unsigned int intv=atoi(value);
if ((num_threads==0 || num_threads==intv || mysql_threads==NULL) && intv > 0 && intv < 256) {
const uint32_t intv { !GloVars.global.mysql_workers ? uint32_t(0) : atoi(value) };
const bool valid_val { (intv > 0 && intv < 256) || (!GloVars.global.mysql_workers && intv == 0) };

if ((num_threads==0 || num_threads==intv || mysql_threads==NULL) && valid_val) {
num_threads=intv;
this->status_variables.p_gauge_array[p_th_gauge::mysql_thread_workers]->Set(intv);
return true;
Expand Down Expand Up @@ -2405,7 +2407,7 @@ void MySQL_Threads_Handler::init(unsigned int num, size_t stack) {
num_threads=num;
this->status_variables.p_gauge_array[p_th_gauge::mysql_thread_workers]->Set(num);
} else {
if (num_threads==0) {
if (num_threads==0 && GloVars.global.mysql_workers) {
num_threads=DEFAULT_NUM_THREADS; //default
this->status_variables.p_gauge_array[p_th_gauge::mysql_thread_workers]->Set(DEFAULT_NUM_THREADS);
}
Expand Down Expand Up @@ -2460,7 +2462,7 @@ proxysql_mysql_thread_t * MySQL_Threads_Handler::create_thread(unsigned int tn,
if (GloVars.set_thread_name == true) {
char thr_name[16];
snprintf(thr_name, sizeof(thr_name), "MySQLIdle%d", tn);
pthread_setname_np(mysql_threads[tn].thread_id, thr_name);
pthread_setname_np(mysql_threads_idles[tn].thread_id, thr_name);
}
}
#endif // defined(__linux__) || defined(__FreeBSD__)
Expand Down
8 changes: 5 additions & 3 deletions lib/PgSQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1997,8 +1997,10 @@ bool PgSQL_Threads_Handler::set_variable(char* name, const char* value) { // thi
}
}
if (!strcasecmp(name, "threads")) {
unsigned int intv = atoi(value);
if ((num_threads == 0 || num_threads == intv || pgsql_threads == NULL) && intv > 0 && intv < 256) {
const uint32_t intv { !GloVars.global.pgsql_workers ? uint32_t(0) : atoi(value) };
const bool valid_val { (intv > 0 && intv < 256) || (!GloVars.global.pgsql_workers && intv == 0) };

if ((num_threads == 0 || num_threads == intv || pgsql_threads == NULL) && valid_val) {
num_threads = intv;
//this->status_variables.p_gauge_array[p_th_gauge::mysql_thread_workers]->Set(intv);
return true;
Expand Down Expand Up @@ -2317,7 +2319,7 @@ void PgSQL_Threads_Handler::init(unsigned int num, size_t stack) {
//this->status_variables.p_gauge_array[p_th_gauge::mysql_thread_workers]->Set(num);
}
else {
if (num_threads == 0) {
if (num_threads==0 && GloVars.global.pgsql_workers) {
num_threads = DEFAULT_NUM_THREADS; //default
//this->status_variables.p_gauge_array[p_th_gauge::mysql_thread_workers]->Set(DEFAULT_NUM_THREADS);
}
Expand Down
34 changes: 15 additions & 19 deletions lib/ProxySQL_Admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2258,9 +2258,6 @@ void * admin_main_loop(void *arg) {
__sync_fetch_and_add(&admin_load_main_,1);
while (glovars.shutdown==0 && *shutdown==0)
{
//int *client;
//int client_t;
//socklen_t addr_size = sizeof(addr);
pthread_t child;
size_t stacks;
unsigned long long curtime=monotonic_time();
Expand Down Expand Up @@ -2293,13 +2290,9 @@ void * admin_main_loop(void *arg) {
passarg->addr_size = sizeof(custom_sockaddr);
memset(passarg->addr, 0, sizeof(custom_sockaddr));
passarg->client_t = accept(fds[i].fd, (struct sockaddr*)passarg->addr, &passarg->addr_size);
// printf("Connected: %s:%d sock=%d\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port), client_t);
pthread_attr_getstacksize (&attr, &stacks);
// printf("Default stack size = %d\n", stacks);
pthread_mutex_lock (&sock_mutex);
//client=(int *)malloc(sizeof(int));
//*client= client_t;
//if ( pthread_create(&child, &attr, child_func[callback_func[i]], client) != 0 ) {

if ( pthread_create(&child, &attr, child_func[callback_func[i]], passarg) != 0 ) {
// LCOV_EXCL_START
perror("pthread_create");
Expand All @@ -2325,12 +2318,15 @@ void * admin_main_loop(void *arg) {
if (resultset) {
SQLite3_result * resultset2 = NULL;

// In debug, run the code to generate metrics so that it can be tested even if the web interface plugin isn't loaded.
#ifdef DEBUG
if (true) {
#else
if (GloVars.web_interface_plugin) {
#endif
// In debug, run the code to generate metrics so that it can be tested even if
// the 'web_interface_plugin' isn't loaded.
if (
#ifdef DEBUG
true
#else
GloVars.web_interface_plugin
#endif
) {
resultset2 = MyHGM->SQL3_Connection_Pool(false);
}
GloProxyStats->MyHGM_Handler_sets(resultset, resultset2);
Expand Down Expand Up @@ -2388,7 +2384,7 @@ void * admin_main_loop(void *arg) {
nfds++;
unsigned int j;
i=0; j=0;
for (j=0; j<S_amll.ifaces_mysql->ifaces->len; j++) {
for (j=0; j < S_amll.ifaces_mysql->ifaces->len && GloVars.global.mysql_admin; j++) {
char *add=NULL; char *port=NULL; char *sn=(char *)S_amll.ifaces_mysql->ifaces->index(j);
bool is_ipv6 = false;
char *h = NULL;
Expand All @@ -2412,7 +2408,7 @@ void * admin_main_loop(void *arg) {
#else
int s = ( atoi(port) ? listen_on_port(add, atoi(port), 128) : listen_on_unix(add, 128));
#endif
//if (s>0) { fds[nfds].fd=s; fds[nfds].events=POLLIN; fds[nfds].revents=0; callback_func[nfds]=0; socket_names[nfds]=strdup(sn); nfds++; }

if (s > 0) {
fds[nfds].fd = s;
fds[nfds].events = POLLIN;
Expand All @@ -2428,7 +2424,7 @@ void * admin_main_loop(void *arg) {
}

i = 0; j = 0;
for (; j < S_amll.ifaces_pgsql->ifaces->len; j++) {
for (; j < S_amll.ifaces_pgsql->ifaces->len && GloVars.global.pgsql_admin; j++) {
char* add = NULL; char* port = NULL; char* sn = (char*)S_amll.ifaces_pgsql->ifaces->index(j);
bool is_ipv6 = false;
char* h = NULL;
Expand All @@ -2453,7 +2449,7 @@ void * admin_main_loop(void *arg) {
#else
int s = (atoi(port) ? listen_on_port(add, atoi(port), 128) : listen_on_unix(add, 128));
#endif
//if (s>0) { fds[nfds].fd=s; fds[nfds].events=POLLIN; fds[nfds].revents=0; callback_func[nfds]=0; socket_names[nfds]=strdup(sn); nfds++; }

if (s > 0) {
fds[nfds].fd = s;
fds[nfds].events = POLLIN;
Expand All @@ -2471,7 +2467,7 @@ void * admin_main_loop(void *arg) {
}

}
//if (__sync_add_and_fetch(shutdown,0)==0) __sync_add_and_fetch(shutdown,1);

for (i=0; i<nfds; i++) {
char *add=NULL; char *port=NULL;
close(fds[i].fd);
Expand Down
64 changes: 64 additions & 0 deletions lib/ProxySQL_GloVars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ ProxySQL_GlobalVariables::ProxySQL_GlobalVariables() :
global.gdbg=false;
global.nostart=false;
global.foreground=false;
global.mysql_workers=true;
global.pgsql_workers=true;
global.mysql_admin=true;
global.pgsql_admin=true;
global.my_monitor=true;
global.pg_monitor=true;
#ifdef IDLE_THREADS
Expand Down Expand Up @@ -261,6 +265,12 @@ ProxySQL_GlobalVariables::ProxySQL_GlobalVariables() :
#endif /* DEBUG */
opt->add((const char *)"",0,0,0,(const char *)"Starts only the admin service",(const char *)"-n",(const char *)"--no-start");
opt->add((const char *)"",0,0,0,(const char *)"Do not start Monitor Module",(const char *)"-M",(const char *)"--no-monitor");
opt->add((const char *)"",0,1,0,(const char *)"Do not start MySQL Monitor Module",(const char *)"--mysql-monitor");
opt->add((const char *)"",0,1,0,(const char *)"Do not start PgSQL Monitor Module",(const char *)"--pgsql-monitor");
opt->add((const char *)"",0,1,0,(const char *)"Do not start MySQL Worker Threads",(const char *)"--mysql-workers");
opt->add((const char *)"",0,1,0,(const char *)"Do not start PgSQL Worker Threads",(const char *)"--pgsql-workers");
opt->add((const char *)"",0,1,0,(const char *)"Do not start MySQL Admin Module",(const char *)"--mysql-admin");
opt->add((const char *)"",0,1,0,(const char *)"Do not start PgSQL Admin Module",(const char *)"--pgsql-admin");
opt->add((const char *)"",0,0,0,(const char *)"Run in foreground",(const char *)"-f",(const char *)"--foreground");
#ifdef SO_REUSEPORT
opt->add((const char *)"",0,0,0,(const char *)"Use SO_REUSEPORT",(const char *)"-r",(const char *)"--reuseport");
Expand Down Expand Up @@ -486,6 +496,60 @@ void ProxySQL_GlobalVariables::process_opts_post() {
global.pg_monitor=false;
}

if (opt->isSet("--mysql-monitor")) {
string val {};
opt->get("--mysql-monitor")->getString(val);

if (val == "false" || val == "0") {
global.my_monitor = false;
}
}

if (opt->isSet("--pgsql-monitor")) {
string val {};
opt->get("--pgsql-monitor")->getString(val);

if (val == "false" || val == "0") {
global.pg_monitor = false;
}
}

if (opt->isSet("--mysql-workers")) {
string val {};
opt->get("--mysql-workers")->getString(val);

if (val == "false" || val == "0") {
global.mysql_workers = false;
}
}

if (opt->isSet("--pgsql-workers")) {
string val {};
opt->get("--pgsql-workers")->getString(val);

if (val == "false" || val == "0") {
global.pgsql_workers = false;
}
}

if (opt->isSet("--mysql-admin")) {
string val {};
opt->get("--mysql-admin")->getString(val);

if (val == "false" || val == "0") {
global.mysql_admin = false;
}
}

if (opt->isSet("--pgsql-admin")) {
string val {};
opt->get("--pgsql-admin")->getString(val);

if (val == "false" || val == "0") {
global.pgsql_admin = false;
}
}

#ifdef SO_REUSEPORT
{
struct utsname unameData;
Expand Down
Loading