diff --git a/marconi/storage/mongodb/controllers.py b/marconi/storage/mongodb/controllers.py index b333cebe0..8e494af3a 100644 --- a/marconi/storage/mongodb/controllers.py +++ b/marconi/storage/mongodb/controllers.py @@ -189,13 +189,12 @@ class MessageController(storage.MessageBase): query = { "c.id": claim_id, + "c.e": {"$gt": expires or timeutils.utcnow_ts()}, "q": utils.to_oid(queue), } if not claim_id: # lookup over c.id to use the index query["c.id"] = {"$ne": None} - if expires: - query["c.e"] = {"$gt": expires} msgs = self._col.find(query, sort=[("_id", 1)])