From 37bf9733f69d62308ccfba206902875e6e33eaef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 27 Jul 2016 11:54:49 +0200 Subject: [PATCH] refresh_links_for_backend: lowering batch size MongoDB will close an idle connection after 10 minutes. By lowering the batch size, I hope we'll often request a small batch of data, therefore avoiding the connection to be idle for too long and timing out. --- pillar/application/modules/file_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pillar/application/modules/file_storage.py b/pillar/application/modules/file_storage.py index df8c6b1c..8d07b97a 100644 --- a/pillar/application/modules/file_storage.py +++ b/pillar/application/modules/file_storage.py @@ -466,7 +466,7 @@ def refresh_links_for_backend(backend_name, chunk_size, expiry_seconds): {'$or': [{'backend': backend_name, 'link_expires': None}, {'backend': backend_name, 'link_expires': {'$lt': expire_before}}, {'backend': backend_name, 'link': None}] - }).sort([('link_expires', pymongo.ASCENDING)]).limit(chunk_size) + }).sort([('link_expires', pymongo.ASCENDING)]).limit(chunk_size).batch_size(5) if to_refresh.count() == 0: log.info('No links to refresh.')