Project

Profile

Help

Issue #3018

mongo 3.4 warning over the use of aggregates

Added by mihai.ibanescu@gmail.com over 4 years ago. Updated over 1 year ago.

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.

Associated revisions

Revision d17f8d80 View on GitHub
Added by mihai.ibanescu@gmail.com over 4 years ago

Silence aggregation warning with mongo 3.4 and newer.

closes #3018

History

#1 Updated by mihai.ibanescu@gmail.com over 4 years ago

  • Status changed from NEW to MODIFIED

#2 Updated by pcreech over 4 years ago

  • Platform Release set to 2.14.1

#3 Updated by pcreech over 4 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

#5 Updated by bmbouter almost 3 years ago

  • Tags Pulp 2 added

#6 Updated by bmbouter over 1 year ago

  • Category deleted (14)

We are removing the 'API' category per open floor discussion June 16, 2020.

Also available in: Atom PDF