Skip to content

Commit 26f2663

Browse files
authored
Drastically reduce the default Mongo count timeout (#2247)
1 parent 07edb32 commit 26f2663

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

optimade/server/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class ServerConfig(BaseSettings):
219219
] = None
220220

221221
mongo_count_timeout: Annotated[
222-
int,
222+
float,
223223
Field(
224224
description=(
225225
"Number of seconds to allow MongoDB to perform a full database count "
@@ -229,7 +229,7 @@ class ServerConfig(BaseSettings):
229229
"response times."
230230
),
231231
),
232-
] = 5
232+
] = 0.5
233233

234234
mongo_database: Annotated[
235235
str,

optimade/server/entry_collections/mongo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def count(self, **kwargs: Any) -> int | None:
8585
return self.collection.estimated_document_count()
8686
else:
8787
if "maxTimeMS" not in kwargs:
88-
kwargs["maxTimeMS"] = 1000 * CONFIG.mongo_count_timeout
88+
kwargs["maxTimeMS"] = int(1000 * CONFIG.mongo_count_timeout)
8989
try:
9090
return self.collection.count_documents(**kwargs)
9191
except ExecutionTimeout:

0 commit comments

Comments
 (0)