@@ -70,7 +70,6 @@ int gbl_deferred_phys_flag = 0;
7070int gbl_physrep_slow_replicant_check_freq_sec = 60 ;
7171int gbl_physrep_keepalive_freq_sec = 60 ;
7272int gbl_physrep_hung_replicant_check_freq_sec = 60 ;
73- int gbl_physrep_check_minlog_freq_sec = 600 ;
7473int gbl_physrep_hung_replicant_threshold = 60 ;
7574int gbl_physrep_revconn_check_interval = 60 ;
7675int gbl_physrep_update_registry_interval = 60 ;
@@ -79,7 +78,6 @@ int gbl_physrep_i_am_metadb = 0;
7978int gbl_physrep_filter_by_class = 1 ;
8079int gbl_started_physrep_threads = 0 ;
8180
82- unsigned int physrep_min_logfile ;
8381unsigned int gbl_deferred_phys_update ;
8482
8583char * gbl_physrep_source_dbname ;
@@ -1205,10 +1203,6 @@ static int send_keepalive(void)
12051203 return 0 ;
12061204}
12071205
1208- unsigned int physrep_min_filenum () {
1209- return physrep_min_logfile ;
1210- }
1211-
12121206extern int gbl_reverse_hosts_v2 ;
12131207
12141208static int check_for_reverse_conn (cdb2_hndl_tp * hndl ) {
@@ -1248,38 +1242,6 @@ static int check_for_reverse_conn(cdb2_hndl_tp *hndl) {
12481242 return (rc == 0 ) ? do_wait : -1 ;
12491243}
12501244
1251- void physrep_update_low_file_num (int * lowfilenum , int * local_lowfilenum ) {
1252- unsigned int physrep_minfilenum ;
1253- if ((get_dbtable_by_name ("comdb2_physreps" )) == NULL ) {
1254- return ;
1255- }
1256-
1257- physrep_minfilenum = physrep_min_filenum ();
1258- if (physrep_minfilenum <= 0 ) {
1259- if (gbl_physrep_debug ) {
1260- physrep_logmsg (LOGMSG_USER , "%s:%d: lowfilenum unchanged (physrep_minfilenum: %d)\n" ,
1261- __func__ , __LINE__ , physrep_minfilenum );
1262- }
1263- } else {
1264- if (physrep_minfilenum <= * lowfilenum ) {
1265- if (gbl_physrep_debug ) {
1266- physrep_logmsg (LOGMSG_USER , "%s:%d: lowfilenum %d being changed "
1267- "physical replicant(s) (physrep_minfilenum: %d)\n" ,
1268- __func__ , __LINE__ , * lowfilenum , physrep_minfilenum );
1269- }
1270- * lowfilenum = physrep_minfilenum - 1 ;
1271- }
1272- if (physrep_minfilenum <= * local_lowfilenum ) {
1273- * local_lowfilenum = physrep_minfilenum - 1 ;
1274- }
1275- }
1276-
1277- if (gbl_physrep_debug ) {
1278- physrep_logmsg (LOGMSG_USER , "%s:%d: lowfilenum: %d (physrep_minfilenum: %d)\n" ,
1279- __func__ , __LINE__ , * lowfilenum , physrep_minfilenum );
1280- }
1281- }
1282-
12831245static int slow_replicants_count_int (cdb2_hndl_tp * metadb , unsigned int * count )
12841246{
12851247 char query [400 ];
@@ -1340,94 +1302,6 @@ static int slow_replicants_count(unsigned int *count)
13401302 return badrc ? -1 : 0 ;
13411303}
13421304
1343- static int update_min_logfile_int (cdb2_hndl_tp * metadb )
1344- {
1345- char cmd [120 + nodes_list_sz ];
1346- char * buf ;
1347- size_t buf_len ;
1348- int bytes_written ;
1349- int rc = 0 ;
1350-
1351- if (gbl_ready == 0 )
1352- return 0 ;
1353-
1354- bytes_written = 0 ;
1355- buf = cmd ;
1356- buf_len = sizeof (cmd );
1357-
1358- bytes_written +=
1359- snprintf (buf + bytes_written , buf_len - bytes_written ,
1360- "WITH RECURSIVE replication_tree(dbname, host, file) AS "
1361- " (SELECT dbname, host, file FROM comdb2_physreps "
1362- " WHERE dbname='%s' AND host IN (" ,
1363- gbl_dbname );
1364- if (bytes_written >= buf_len ) {
1365- physrep_logmsg (LOGMSG_ERROR , "%s:%d Buffer is not long enough!\n" , __func__ , __LINE__ );
1366- return 1 ;
1367- }
1368-
1369- bytes_written += append_quoted_local_hosts (buf + bytes_written , buf_len - bytes_written , "," );
1370- if (bytes_written >= buf_len ) {
1371- physrep_logmsg (LOGMSG_ERROR , "%s:%d Buffer is not long enough!\n" , __func__ , __LINE__ );
1372- return 1 ;
1373- }
1374-
1375- bytes_written += snprintf (buf + bytes_written , buf_len - bytes_written ,
1376- " ) "
1377- " UNION "
1378- " SELECT p.dbname, p.host, p.file FROM comdb2_physreps p, "
1379- " comdb2_physrep_connections c, replication_tree t "
1380- " WHERE p.state = 'Active' AND p.file <> 0 AND "
1381- " t.dbname = c.source_dbname AND c.dbname = p.dbname) "
1382- " SELECT file FROM replication_tree WHERE file IS NOT NULL ORDER BY file LIMIT 1" );
1383- if (bytes_written >= buf_len ) {
1384- physrep_logmsg (LOGMSG_ERROR , "%s:%d Buffer is not long enough!\n" , __func__ , __LINE__ );
1385- return 1 ;
1386- }
1387-
1388- if (gbl_physrep_debug ) {
1389- physrep_logmsg (LOGMSG_USER , "%s:%d Executing: %s\n" , __func__ , __LINE__ , cmd );
1390- }
1391-
1392- ATOMIC_ADD64 (gbl_physrep_metadb_sql_count , 1 );
1393- rc = cdb2_run_statement (metadb , cmd );
1394- if (rc == CDB2_OK ) {
1395- while ((rc = cdb2_next_record (metadb )) == CDB2_OK ) {
1396- int64_t * minfile = (int64_t * )cdb2_column_value (metadb , 0 );
1397- physrep_min_logfile = minfile ? (unsigned int )* minfile : 0 ;
1398- }
1399- if (rc == CDB2_OK_DONE )
1400- rc = 0 ;
1401- } else {
1402- physrep_logmsg (LOGMSG_ERROR , "%s:%d Failed to execute (rc: %d)\n" , __func__ , __LINE__ , rc );
1403- }
1404-
1405- return rc ;
1406- }
1407-
1408- static int update_min_logfile (void )
1409- {
1410- cdb2_hndl_tp * metadb ;
1411- int rc , altcnt = gbl_altmetadb_count ;
1412-
1413- if ((rc = physrep_get_metadb_or_local_hndl (& metadb )) != 0 ) {
1414- logmsg (LOGMSG_ERROR , "%s: failed to get metadb handle rc=%d\n" , __func__ , rc );
1415- } else {
1416- update_min_logfile_int (metadb );
1417- cdb2_close (metadb );
1418- }
1419-
1420- for (int i = 0 ; i < altcnt ; i ++ ) {
1421- if ((rc = get_alt_metadb_hndl (& metadb , i )) != 0 ) {
1422- logmsg (LOGMSG_ERROR , "%s: failed to get alt metadb handle %d rc=%d\n" , __func__ , i , rc );
1423- continue ;
1424- }
1425- update_min_logfile_int (metadb );
1426- cdb2_close (metadb );
1427- }
1428- return 0 ;
1429- }
1430-
14311305/*
14321306 Check whether we need to wait for a connection from one of the nodes
14331307 in the source db.
@@ -1994,7 +1868,6 @@ static void *physrep_watcher(void *args) {
19941868 static int physrep_slow_replicant_last_checked ;
19951869 static int physrep_keepalive_last_sent ;
19961870 static int physrep_hung_replicant_last_checked ;
1997- static int physrep_minlog_last_checked ;
19981871
19991872 while (!gbl_exit && stop_physrep_watcher == 0 ) {
20001873 sleep (1 );
@@ -2030,13 +1903,6 @@ static void *physrep_watcher(void *args) {
20301903 send_keepalive ();
20311904 physrep_keepalive_last_sent = now ;
20321905 }
2033-
2034- // Update the 'minimum log file' marker upto which it is safe to
2035- // delete log files.
2036- if ((now - physrep_minlog_last_checked ) >= gbl_physrep_check_minlog_freq_sec ) {
2037- update_min_logfile ();
2038- physrep_minlog_last_checked = now ;
2039- }
20401906 }
20411907 return NULL ;
20421908}
0 commit comments