Actions
Issue #3018
closedmongo 3.4 warning over the use of aggregates
Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
1. Low
Version:
2.10.3
Platform Release:
2.14.1
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Easy Fix, Pulp 2
Sprint:
Quarter:
Description
After moving to Mongo 3.4, we started seeing these warnings in the Mongo logs:
########################
2017-08-21T07:03:34.521-0400 W COMMAND [conn330]
Use of the aggregate command without the 'cursor' option is deprecated. See http://dochub.mongodb.org/core/aggregate-without-cursor-deprecation.
We have isolated the problem, and here is the proposed fix:
--- pulp/server/controllers/repository.py.orig 2017-09-15 11:15:16.915548622 -0400
+++ pulp/server/controllers/repository.py 2017-09-15 11:22:25.754073661 -0400
@@ -301,11 +301,11 @@
pipeline = [
{'$match': {'repo_id': repository.repo_id}},
{'$group': {'_id': '$unit_type_id', 'sum': {'$sum': 1}}}]
- q = db.command('aggregate', 'repo_content_units', pipeline=pipeline)
+ q = db.repo_content_units.aggregate(pipeline=pipeline)
# Flip this into the form that we need
counts = {}
- for result in q['result']:
+ for result in q:
counts[result['_id']] = result['sum']
repository.content_unit_counts = counts
I believe pymongo is setting useCursor=True when dealing with aggregates in a collection, but not if invoked as a command.
Added by mihai.ibanescu@gmail.com over 5 years ago
Updated by mihai.ibanescu@gmail.com over 5 years ago
- Status changed from NEW to MODIFIED
Applied in changeset pulp|d17f8d809243e478a4c170f49353a480337c0d4c.
Updated by pcreech over 5 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Updated by bmbouter almost 3 years ago
- Category deleted (
14)
We are removing the 'API' category per open floor discussion June 16, 2020.
Actions
Silence aggregation warning with mongo 3.4 and newer.
closes #3018