Skip to content
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

Fix several Cluster memory leaks #4546

Merged
merged 21 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
cf7da4e
Fix memory leak in 'pull_mysql_query_rules_from_peer'
JavierJF May 14, 2024
317ef31
Fix memory leak on GTID 'new_connector'
JavierJF May 14, 2024
742ad8a
Fix memory leak on 'pull_mysql_query_rules_from_peer' statements
JavierJF May 14, 2024
3e8d672
Remove commented code from original GTID impl
JavierJF May 14, 2024
d9430ff
Remove commented code from original Cluster POC
JavierJF May 14, 2024
2b1d576
Replace commented code on Cluster timeouts with comments
JavierJF May 14, 2024
80c30d7
Fix un-initialized variable 'all_modules_started'
JavierJF May 14, 2024
8c83dac
Several improvements for 'test_backend_conn_ping'
JavierJF May 14, 2024
c6fb194
Several improvements for 'test_cluster_sync-t'
JavierJF May 14, 2024
e930d98
Several improvements for test 'eof_packet_mixed_queries'
JavierJF May 14, 2024
b86bbae
Minor cleanup in some TAP tests
JavierJF May 14, 2024
19e4ac2
Mitigate invalid memory accesses from Monitor GR on 'SHUTDOWN SLOW'
JavierJF May 14, 2024
f8fb6fd
Fix compilation for Centos 7
JavierJF May 14, 2024
f962d13
Fix crashes during shutdown due to uninitialized 'AdminHTTPServer'
JavierJF May 16, 2024
54ca795
Fix shutdown crashes due to 'debug_filters' destruction
JavierJF May 16, 2024
abaea17
Fix race condition on 'test_cluster_sync-t'
JavierJF May 16, 2024
6a77d7d
Increase logging for 'test_cluster_sync-t'
JavierJF May 16, 2024
d7f2c44
Increase tolerance of 'reg_test_3765_ssl_pollout' for ASAN builds
JavierJF May 16, 2024
f867451
Increase tolerance of 'test_cacert_load_and_verify_duration-t' for AS…
JavierJF May 16, 2024
63968d6
Increase timeouts of 'restapi_return_codes-t' for ASAN builds
JavierJF May 16, 2024
3d185ec
Further increase timeouts of 'restapi_return_codes-t' for ASAN builds
JavierJF May 16, 2024
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
7 changes: 6 additions & 1 deletion include/ProxySQL_Cluster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ struct fetch_query {
std::string msgs[3];
};

struct cluster_creds_t {
string user;
string pass;
};

class ProxySQL_Cluster {
private:
SQLite3DB* mydb;
Expand Down Expand Up @@ -444,7 +449,7 @@ class ProxySQL_Cluster {

MySQL_Monitor::trigger_dns_cache_update();
}
void get_credentials(char**, char**);
cluster_creds_t get_credentials();
void set_username(char*);
void set_password(char*);
void set_admin_mysql_ifaces(char*);
Expand Down
18 changes: 6 additions & 12 deletions lib/GTID_Server_Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,14 @@ void connect_cb(EV_P_ ev_io *w, int revents) {
}

struct ev_io * new_connector(char *address, uint16_t gtid_port, uint16_t mysql_port) {
//struct sockaddr_in a;
int s;

if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror("socket");
close(s);
return NULL;
}
/*
memset(&a, 0, sizeof(a));
a.sin_port = htons(gtid_port);
a.sin_family = AF_INET;
if (!inet_aton(address, (struct in_addr *) &a.sin_addr.s_addr)) {
perror("bad IP address format");
close(s);
return NULL;
}
*/

ioctl_FIONBIO(s,1);

struct addrinfo hints;
Expand All @@ -142,15 +132,19 @@ struct ev_io * new_connector(char *address, uint16_t gtid_port, uint16_t mysql_p

char str_port[NI_MAXSERV+1];
sprintf(str_port,"%d", gtid_port);

int gai_rc = getaddrinfo(address, str_port, &hints, &res);
if (gai_rc) {
freeaddrinfo(res);
//exit here
return NULL;
}

//int status = connect(s, (struct sockaddr *) &a, sizeof(a));
int status = connect(s, res->ai_addr, res->ai_addrlen);

// Free linked list
freeaddrinfo(res);

if ((status == 0) || ((status == -1) && (errno == EINPROGRESS))) {
struct ev_io *c = (struct ev_io *)malloc(sizeof(struct ev_io));
if (c) {
Expand Down
8 changes: 8 additions & 0 deletions lib/MySQL_Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4091,6 +4091,14 @@ void* monitor_GR_thread_HG(void *arg) {
// 3. Delegate the async fetching + actions of 'MySQL_Monitor_State_Data' with conns on 'Monitor_Poll'.
///////////////////////////////////////////////////////////////////////////////////////

// NOTE: This is just a best effort to avoid invalid memory accesses during 'SHUTDOWN SLOW'. Since the
// previous section is 'time consuming', there are good changes that we can detect a shutdown before
// trying to perform the monitoring actions on the acquired 'mmsd'. This exact scenario and timing has
// been previously observed in the CI.
if (GloMyMon->shutdown) {
break;
}

// Handle 'mmsds' that failed to optain conns
for (const unique_ptr<MySQL_Monitor_State_Data>& mmsd : fail_mmsds) {
async_gr_mon_actions_handler(mmsd.get());
Expand Down
3 changes: 3 additions & 0 deletions lib/ProxySQL_Admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6033,6 +6033,7 @@ ProxySQL_Admin::ProxySQL_Admin() :
variables.p_memory_metrics_interval = 61;
#ifdef DEBUG
variables.debug=GloVars.global.gdbg;
all_modules_started = false;
debug_output = 1;
proxysql_set_admin_debug_output(debug_output);
#endif /* DEBUG */
Expand Down Expand Up @@ -6388,6 +6389,8 @@ bool ProxySQL_Admin::init(const bootstrap_info_t& bootstrap_info) {

Admin_HTTP_Server = NULL;
AdminRestApiServer = NULL;
AdminHTTPServer = NULL;

/*
AdminRestApiServer = new ProxySQL_RESTAPI_Server();
AdminRestApiServer->print_version();
Expand Down
Loading
Loading