From 2a280ede39f8dfacd2645a9bafdf616f1d02dc78 Mon Sep 17 00:00:00 2001 From: KeyserSosa Date: Mon, 27 Apr 2009 12:07:56 -0700 Subject: [PATCH] service monitor updates, fixing a bug when max_connections is erroneously returned as zero --- r2/r2/lib/db/tdb_sql.py | 2 ++ r2/r2/lib/services.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) 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