-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix AWS RDS Blue/Green discovery for Aurora-only hostgroup configurations #6158
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
base: v3.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1046,11 +1046,13 @@ | |
| void MySQL_HostGroups_Manager::update_hostgroup_manager_mappings() { | ||
|
|
||
| if (hgsm_mysql_servers_checksum != table_resultset_checksum[HGM_TABLES::MYSQL_SERVERS] || | ||
| hgsm_mysql_replication_hostgroups_checksum != table_resultset_checksum[HGM_TABLES::MYSQL_REPLICATION_HOSTGROUPS]) | ||
| hgsm_mysql_replication_hostgroups_checksum != table_resultset_checksum[HGM_TABLES::MYSQL_REPLICATION_HOSTGROUPS] || | ||
| hgsm_mysql_aws_aurora_hostgroups_checksum != table_resultset_checksum[HGM_TABLES::MYSQL_AWS_AURORA_HOSTGROUPS]) | ||
| { | ||
| proxy_info("Rebuilding 'Hostgroup_Manager_Mapping' due to checksums change - mysql_servers { old: 0x%lX, new: 0x%lX }, mysql_replication_hostgroups { old:0x%lX, new:0x%lX }\n", | ||
| proxy_info("Rebuilding 'Hostgroup_Manager_Mapping' due to checksums change - mysql_servers { old: 0x%lX, new: 0x%lX }, mysql_replication_hostgroups { old:0x%lX, new:0x%lX }, mysql_aws_aurora_hostgroups { old:0x%lX, new:0x%lX }\n", | ||
| hgsm_mysql_servers_checksum, table_resultset_checksum[HGM_TABLES::MYSQL_SERVERS], | ||
| hgsm_mysql_replication_hostgroups_checksum, table_resultset_checksum[HGM_TABLES::MYSQL_REPLICATION_HOSTGROUPS]); | ||
| hgsm_mysql_replication_hostgroups_checksum, table_resultset_checksum[HGM_TABLES::MYSQL_REPLICATION_HOSTGROUPS], | ||
| hgsm_mysql_aws_aurora_hostgroups_checksum, table_resultset_checksum[HGM_TABLES::MYSQL_AWS_AURORA_HOSTGROUPS]); | ||
|
|
||
| char* error = NULL; | ||
| int cols = 0; | ||
|
|
@@ -1059,10 +1061,21 @@ | |
|
|
||
| hostgroup_server_mapping.clear(); | ||
|
|
||
| const char* query = "SELECT DISTINCT hostname, port, '1' is_writer, status, reader_hostgroup, writer_hostgroup, mem_pointer FROM mysql_replication_hostgroups JOIN mysql_servers ON hostgroup_id=writer_hostgroup WHERE status<>3 \ | ||
| UNION \ | ||
| SELECT DISTINCT hostname, port, '0' is_writer, status, reader_hostgroup, writer_hostgroup, mem_pointer FROM mysql_replication_hostgroups JOIN mysql_servers ON hostgroup_id=reader_hostgroup WHERE status<>3 \ | ||
| ORDER BY hostname, port"; | ||
| const char* query = | ||
| "SELECT DISTINCT hostname, port, '1' is_writer, status, reader_hostgroup, writer_hostgroup, mem_pointer " | ||
| "FROM mysql_replication_hostgroups JOIN mysql_servers ON hostgroup_id=writer_hostgroup WHERE status<>3 " | ||
| "UNION " | ||
| "SELECT DISTINCT hostname, port, '0' is_writer, status, reader_hostgroup, writer_hostgroup, mem_pointer " | ||
| "FROM mysql_replication_hostgroups JOIN mysql_servers ON hostgroup_id=reader_hostgroup WHERE status<>3 " | ||
| "UNION " | ||
| "SELECT DISTINCT srv.hostname, srv.port, '1' is_writer, srv.status, aur.reader_hostgroup, aur.writer_hostgroup, srv.mem_pointer " | ||
| "FROM mysql_aws_aurora_hostgroups aur JOIN mysql_servers srv ON srv.hostgroup_id=aur.writer_hostgroup " | ||
| "WHERE aur.active=1 AND srv.status<>3 " | ||
| "UNION " | ||
| "SELECT DISTINCT srv.hostname, srv.port, '0' is_writer, srv.status, aur.reader_hostgroup, aur.writer_hostgroup, srv.mem_pointer " | ||
| "FROM mysql_aws_aurora_hostgroups aur JOIN mysql_servers srv ON srv.hostgroup_id=aur.reader_hostgroup " | ||
| "WHERE aur.active=1 AND srv.status<>3 " | ||
| "ORDER BY hostname, port"; | ||
|
|
||
| mydb->execute_statement(query, &error, &cols, &affected_rows, &resultset); | ||
|
|
||
|
|
@@ -1106,6 +1119,7 @@ | |
|
|
||
| hgsm_mysql_servers_checksum = table_resultset_checksum[HGM_TABLES::MYSQL_SERVERS]; | ||
| hgsm_mysql_replication_hostgroups_checksum = table_resultset_checksum[HGM_TABLES::MYSQL_REPLICATION_HOSTGROUPS]; | ||
| hgsm_mysql_aws_aurora_hostgroups_checksum = table_resultset_checksum[HGM_TABLES::MYSQL_AWS_AURORA_HOSTGROUPS]; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -6966,6 +6980,16 @@ | |
| pthread_mutex_unlock(&AWS_Aurora_Info_mutex); | ||
| } | ||
|
|
||
| const std::string aurora_hostname { std::string(_server_id) + std::string(domain_name) }; | ||
| if (GloMyMon != nullptr && GloMyMon->is_aws_rds_bgd_server_in_progress(aurora_hostname, aurora_port)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: A BGD switchover can begin after this check and before the Aurora movement commits, so the guard does not eliminate the race it is intended to prevent. Coordinate the flag with the movement, or recheck under a lock held through the update. Prompt for AI agents |
||
| proxy_info( | ||
| "AWS Aurora: skipping writer update for %s:%d because AWS RDS BGD switchover is in progress\n", | ||
| aurora_hostname.c_str(), aurora_port | ||
| ); | ||
| free(domain_name); | ||
| return; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: When BGD is already in progress, this return skips the writer transition but the caller still records an Aurora failover. Return whether movement occurred and suppress the failover log when it did not. Prompt for AI agents |
||
| } | ||
|
|
||
| query=(char *)malloc(strlen(q)+strlen(_server_id)+strlen(domain_name)+1024*1024); | ||
| sprintf(query, q, _server_id, domain_name, aurora_port, _whid, _rhid); | ||
| mydb->execute_statement(query, &error, &cols , &affected_rows , &resultset); | ||
|
|
@@ -7182,7 +7206,7 @@ | |
| if (it2!=AWS_Aurora_Info_Map.end()) { | ||
| info=it2->second; | ||
| if (info->domain_name) { | ||
| free(domain_name); | ||
|
Check failure on line 7209 in lib/MySQL_HostGroups_Manager.cpp
|
||
| domain_name = strdup(info->domain_name); | ||
| } | ||
| aurora_port = info->aurora_port; | ||
|
|
@@ -7190,6 +7214,17 @@ | |
| } | ||
| pthread_mutex_unlock(&AWS_Aurora_Info_mutex); | ||
| } | ||
|
|
||
| const std::string aurora_hostname { std::string(_server_id) + std::string(domain_name) }; | ||
| if (GloMyMon != nullptr && GloMyMon->is_aws_rds_bgd_server_in_progress(aurora_hostname, aurora_port)) { | ||
| proxy_info( | ||
| "AWS Aurora: skipping reader update for %s:%d because AWS RDS BGD switchover is in progress\n", | ||
| aurora_hostname.c_str(), aurora_port | ||
| ); | ||
| free(domain_name); | ||
|
Check failure on line 7224 in lib/MySQL_HostGroups_Manager.cpp
|
||
| return; | ||
| } | ||
|
|
||
| q = (char*)"SELECT hostgroup_id FROM mysql_servers JOIN mysql_aws_aurora_hostgroups ON hostgroup_id=writer_hostgroup OR hostgroup_id=reader_hostgroup WHERE hostname='%s%s' AND port=%d AND status<>3 AND hostgroup_id IN (%d,%d)"; | ||
| query=(char *)malloc(strlen(q)+strlen(_server_id)+strlen(domain_name)+32+32+32); | ||
| sprintf(query, q, _server_id, domain_name, aurora_port, _whid, _rhid); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The new member
hgsm_mysql_aws_aurora_hostgroups_checksumis added inside the#if 0block (lines 605–965) ofBase_HostGroups_Manager.h, which contains a legacy, never-compiled copy of theMySQL_HostGroups_Managerclass. This addition has no effect; the live class isMySQL_HostGroups_Managerininclude/MySQL_HostGroups_Manager.h, where the same member was added. Keeping the dead copy in sync is misleading and the change here is dead code — remove it (or drop the whole#if 0block).Prompt for AI agents