From 46db621b5cd47cbe4d0fc44aa50b8f1911349b56 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Sun, 15 Jan 2017 18:53:43 +0100 Subject: [PATCH 1/2] fix leak of redis fildes (2) --- src/blockserver/server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/blockserver/server.py b/src/blockserver/server.py index 6a8ada9..ba4285a 100644 --- a/src/blockserver/server.py +++ b/src/blockserver/server.py @@ -295,6 +295,7 @@ def delete(self, prefix, file_path): 'prefix': prefix, 'path': path, }) + yield pubsub.close() self.finish() def on_finish(self): From 1c2225ecbeddf1400ceb8951007a06e7d863ac78 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Sun, 15 Jan 2017 18:55:08 +0100 Subject: [PATCH 2/2] monitor PUBSUB_OPEN_CONNECTIONS --- src/blockserver/backend/pubsub.py | 2 ++ src/blockserver/monitoring.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/blockserver/backend/pubsub.py b/src/blockserver/backend/pubsub.py index 51c18d9..7704312 100644 --- a/src/blockserver/backend/pubsub.py +++ b/src/blockserver/backend/pubsub.py @@ -41,10 +41,12 @@ async def redis(self): if not self._redis: loop = ioloop.IOLoop.current().asyncio_loop self._redis = await aioredis.create_redis((self.host, self.port), loop=loop) + monitoring.PUBSUB_OPEN_CONNECTIONS.inc() return self._redis async def close(self): (await self.redis()).close() + monitoring.PUBSUB_OPEN_CONNECTIONS.dec() async def subscribe(self, channel, wildcard=False): if wildcard: diff --git a/src/blockserver/monitoring.py b/src/blockserver/monitoring.py index 9c334b8..f01f12c 100644 --- a/src/blockserver/monitoring.py +++ b/src/blockserver/monitoring.py @@ -55,6 +55,9 @@ PUBSUB_PUBLISHED = Counter('pubsub_published', 'Messages published via pubsub') +PUBSUB_OPEN_CONNECTIONS = Gauge('pubsub_connections', + 'Open connections to the pubsub broker (normally redis)') + def time(metric): @asyncio.coroutine