@ -2756,6 +2756,7 @@ __exit_monitor_replication_lag_thread:
ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
// 'replication_lag' to be feed to 'replication_lag_action'
int repl_lag = - 2 ;
bool override_repl_lag = true ;
rc = ( * proxy_sqlite3_bind_text ) ( statement , 1 , mmsd - > hostname , - 1 , SQLITE_TRANSIENT ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
rc = ( * proxy_sqlite3_bind_int ) ( statement , 2 , mmsd - > port ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
unsigned long long time_now = realtime_time ( ) ;
@ -2792,14 +2793,16 @@ __exit_monitor_replication_lag_thread:
MYSQL_ROW row = mysql_fetch_row ( mmsd - > result ) ;
if ( row ) {
repl_lag = - 1 ; // this is old behavior
override_repl_lag = true ;
if ( row [ j ] ) { // if Seconds_Behind_Master is not NULL
repl_lag = atoi ( row [ j ] ) ;
override_repl_lag = false ;
} else {
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : proxysql , mmsd - > hostgroup_id , mmsd - > hostname , mmsd - > port , ER_PROXYSQL_SRV_NULL_REPLICATION_LAG ) ;
}
}
}
if ( repl_lag > = 0 ) {
if ( /*repl_lag >= 0 ||*/ override_repl_lag = = false ) {
rc = ( * proxy_sqlite3_bind_int64 ) ( statement , 5 , repl_lag ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
} else {
rc = ( * proxy_sqlite3_bind_null ) ( statement , 5 ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
@ -2820,7 +2823,7 @@ __exit_monitor_replication_lag_thread:
rc = ( * proxy_sqlite3_clear_bindings ) ( statement ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
rc = ( * proxy_sqlite3_reset ) ( statement ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
MyHGM - > replication_lag_action ( std : : list < replication_lag_server_t > {
replication_lag_server_t { mmsd - > hostgroup_id , mmsd - > hostname , mmsd - > port , repl_lag }
replication_lag_server_t { mmsd - > hostgroup_id , mmsd - > hostname , mmsd - > port , repl_lag , override_repl_lag }
} ) ;
( * proxy_sqlite3_finalize ) ( statement ) ;
if ( mmsd - > mysql_error_msg = = NULL ) {
@ -7739,8 +7742,7 @@ void MySQL_Monitor::monitor_gr_async_actions_handler(
bool MySQL_Monitor : : monitor_replication_lag_process_ready_tasks ( const std : : vector < MySQL_Monitor_State_Data * > & mmsds ) {
std : : list < std : : tuple < int , std : : string , unsigned int , int > > mysql_servers ;
std : : list < replication_lag_server_t > mysql_servers ;
for ( auto & mmsd : mmsds ) {
@ -7782,6 +7784,7 @@ bool MySQL_Monitor::monitor_replication_lag_process_ready_tasks(const std::vecto
ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
// 'replication_lag' to be feed to 'replication_lag_action'
int repl_lag = - 2 ;
bool override_repl_lag = true ;
rc = ( * proxy_sqlite3_bind_text ) ( statement , 1 , mmsd - > hostname , - 1 , SQLITE_TRANSIENT ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
rc = ( * proxy_sqlite3_bind_int ) ( statement , 2 , mmsd - > port ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
unsigned long long time_now = realtime_time ( ) ;
@ -7818,14 +7821,16 @@ bool MySQL_Monitor::monitor_replication_lag_process_ready_tasks(const std::vecto
MYSQL_ROW row = mysql_fetch_row ( mmsd - > result ) ;
if ( row ) {
repl_lag = - 1 ; // this is old behavior
override_repl_lag = true ;
if ( row [ j ] ) { // if Seconds_Behind_Master is not NULL
repl_lag = atoi ( row [ j ] ) ;
override_repl_lag = false ;
} else {
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : proxysql , mmsd - > hostgroup_id , mmsd - > hostname , mmsd - > port , ER_PROXYSQL_SRV_NULL_REPLICATION_LAG ) ;
}
}
}
if ( repl_lag > = 0 ) {
if ( /*repl_lag >= 0 ||*/ override_repl_lag = = false ) {
rc = ( * proxy_sqlite3_bind_int64 ) ( statement , 5 , repl_lag ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
} else {
rc = ( * proxy_sqlite3_bind_null ) ( statement , 5 ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
@ -7847,7 +7852,7 @@ bool MySQL_Monitor::monitor_replication_lag_process_ready_tasks(const std::vecto
rc = ( * proxy_sqlite3_reset ) ( statement ) ; ASSERT_SQLITE_OK ( rc , mmsd - > mondb ) ;
//MyHGM->replication_lag_action(mmsd->hostgroup_id, mmsd->hostname, mmsd->port, repl_lag);
( * proxy_sqlite3_finalize ) ( statement ) ;
mysql_servers . push_back ( std: : tuple < int , std : : string , int , int > { mmsd - > hostgroup_id , mmsd - > hostname , mmsd - > port , repl_lag } ) ;
mysql_servers . push_back ( replication_lag_server_t { mmsd - > hostgroup_id , mmsd - > hostname , mmsd - > port , repl_lag, override_ repl_lag } ) ;
}
//executing replication lag action