@@ -59,7 +59,8 @@ local function main(dbname, hostname, lsn, source_dbname, source_hosts)
5959 " WHERE p.source_dbname = t.dbname AND p.source_host = t.host " ..
6060 " AND p.dbname = c.dbname AND p.host = c.host " ..
6161 " AND (c.file >= " .. pfile .. " AND " ..
62- " (c.firstfile IS NULL OR c.firstfile <= " .. pfile .. " ))), " ..
62+ " (c.firstfile IS NULL OR c.firstfile <= " .. pfile .. " ))" ..
63+ " AND (c.last_keepalive > (NOW() - cast (600 as sec)))), " ..
6364 " child_count (dbname, host, tier, cnt) AS " ..
6465 " (SELECT t.dbname, t.host, t.tier, count (*) c" ..
6566 " FROM tiers t LEFT OUTER JOIN comdb2_physrep_connections p " ..
@@ -78,8 +79,10 @@ local function main(dbname, hostname, lsn, source_dbname, source_hosts)
7879 " host IN (" .. source_hosts .. " ) " ..
7980 " UNION ALL " ..
8081 " SELECT p.dbname, p.host, t.tier+1 " ..
81- " FROM comdb2_physrep_connections p, tiers t " ..
82- " WHERE p.source_dbname = t.dbname AND p.source_host = t.host), " ..
82+ " FROM comdb2_physrep_connections p, tiers t, comdb2_physreps c" ..
83+ " WHERE p.source_dbname = t.dbname AND p.source_host = t.host" ..
84+ " AND p.dbname = c.dbname AND p.host = c.host " ..
85+ " AND (c.last_keepalive > (NOW() - cast (600 as sec)))), " ..
8386 " child_count (dbname, host, tier, cnt) AS " ..
8487 " (SELECT t.dbname, t.host, t.tier, count (*) " ..
8588 " FROM tiers t LEFT OUTER JOIN comdb2_physrep_connections p " ..
0 commit comments