diff --git a/r2/r2/lib/db/tdb_sql.py b/r2/r2/lib/db/tdb_sql.py index e4997b952..819558eb2 100644 --- a/r2/r2/lib/db/tdb_sql.py +++ b/r2/r2/lib/db/tdb_sql.py @@ -298,6 +298,8 @@ def get_read_table(tables): #prune high-connection machines if conns < .9 * max_conns: candidates.append((ip, max(load, avg_load))) + else: + all_ips.append(ip) #add the least loaded machine to all_ips if candidates: diff --git a/r2/r2/lib/services.py b/r2/r2/lib/services.py index 04401efed..ddfa84567 100644 --- a/r2/r2/lib/services.py +++ b/r2/r2/lib/services.py @@ -236,12 +236,12 @@ class Database(object): return datetime.utcnow() - update if update else None def track(self, conn = 0, ip_conn = {}, db_conn = {}, vacuums = {}, - query_count = None, max_connections = None, + query_count = None, max_connections = -1, failures = [], disk_usage = 0): #log the number of connections self.connections.add(conn) - if self.max_connections: + if max_connections and max_connections > 0: self.max_connections = max_connections # log usage by ip