diff --git a/kobo/settings/base.py b/kobo/settings/base.py index adc4803b21..1e5342544b 100644 --- a/kobo/settings/base.py +++ b/kobo/settings/base.py @@ -700,6 +700,8 @@ def __init__(self, *args, **kwargs): MONGO_CONNECTION_URL, j=True, tz_aware=True, connect=False) MONGO_DB = MONGO_CONNECTION[MONGO_DATABASE['NAME']] +MONGO_DB_MAX_TIME_MS = CELERY_TASK_TIME_LIMIT * 60 * 1000 + SESSION_ENGINE = "redis_sessions.session" SESSION_REDIS = RedisHelper.config(default="redis://redis_cache:6380/2") diff --git a/kpi/utils/mongo_helper.py b/kpi/utils/mongo_helper.py index 2761e78c08..71c31c84ba 100644 --- a/kpi/utils/mongo_helper.py +++ b/kpi/utils/mongo_helper.py @@ -292,7 +292,11 @@ def _get_cursor_and_count(cls, mongo_userform_id, hide_deleted=True, # Retrieve all fields except `cls.USERFORM_ID` fields_to_select = {cls.USERFORM_ID: 0} - cursor = settings.MONGO_DB.instances.find(query, fields_to_select) + cursor = settings.MONGO_DB.instances.find( + query, + fields_to_select, + max_time_ms=settings.MONGO_DB_MAX_TIME_MS + ) return cursor, cursor.count() @classmethod